Search in sources :

Example 1 with AbstractResource

use of org.apache.tapestry5.ioc.internal.util.AbstractResource in project tapestry-5 by apache.

the class TemplateParserImplTest method resource_that_throws_exception.

@Test
public // TAP5-2516
void resource_that_throws_exception() throws Exception {
    Resource resource = new AbstractResource("throwfoo") {

        @Override
        public URL toURL() {
            return null;
        }

        @Override
        public boolean exists() {
            return true;
        }

        @Override
        protected Resource newResource(String path) {
            return null;
        }

        @Override
        public InputStream openStream() throws IOException {
            throw new IOException("foo");
        }
    };
    try {
        getParser().parseTemplate(resource);
        unreachable();
    } catch (RuntimeException ex) {
        if (ex.getCause() instanceof TapestryException && ex.getCause().getCause() instanceof IOException) {
            assertMessageContains(ex, "foo");
        } else {
            throw ex;
        }
    }
}
Also used : Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) AbstractResource(org.apache.tapestry5.ioc.internal.util.AbstractResource) AbstractResource(org.apache.tapestry5.ioc.internal.util.AbstractResource) IOException(java.io.IOException) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) Test(org.testng.annotations.Test)

Aggregations

IOException (java.io.IOException)1 Resource (org.apache.tapestry5.commons.Resource)1 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)1 AbstractResource (org.apache.tapestry5.ioc.internal.util.AbstractResource)1 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)1 Test (org.testng.annotations.Test)1