use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class ContextImplTest method get_resource_exists.
@Test
public void get_resource_exists() throws Exception {
String path = "/foo";
URL url = getClass().getResource("ContextImplTest.class");
ServletContext servletContext = newServletContext();
expect(servletContext.getResource(path)).andReturn(url);
replay();
URL result = new ContextImpl(servletContext).getResource(path);
assertSame(result, url);
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class ContextImplTest method get_real_file_exists.
@Test
public void get_real_file_exists() throws IOException {
String path = "/foo.gif";
File file = File.createTempFile("foo", "gif");
String realPath = file.getPath();
ServletContext servletContext = newServletContext();
train_getRealPath(servletContext, path, realPath);
replay();
Context c = new ContextImpl(servletContext);
File f = c.getRealFile(path);
assertEquals(f, file);
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class ContextResourceTest method get_url_file_exists.
@Test
public void get_url_file_exists() throws Exception {
File f = File.createTempFile("Bar", ".txt");
String path = "/foo/" + f.getName();
Context context = mockContext();
expect(context.getRealFile(path)).andReturn(f);
replay();
Resource r = new ContextResource(context, "foo/" + f.getName());
assertEquals(r.toURL(), f.toURL());
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class ContextResourceTest method get_url_no_real_file.
@Test
public void get_url_no_real_file() throws Exception {
String path = "/foo/ContextResourceTest.class";
URL url = getClass().getResource("ContextResourceTest.class");
Context context = mockContext();
expect(context.getRealFile(path)).andReturn(null);
expect(context.getResource("/foo/ContextResourceTest.class")).andReturn(url);
replay();
Resource r = new ContextResource(context, "foo/ContextResourceTest.class");
assertSame(r.toURL(), url);
verify();
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class JavaScriptModule method add.
private static void add(OrderedConfiguration<StackExtension> configuration, StackExtensionType type, String... paths) {
for (String path : paths) {
int slashx = path.lastIndexOf('/');
String id = path.substring(slashx + 1);
configuration.add(id, new StackExtension(type, path));
}
}
Aggregations