Search in sources :

Example 21 with Path

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();
}
Also used : ServletContext(javax.servlet.ServletContext) ContextImpl(org.apache.tapestry5.http.internal.services.ContextImpl) URL(java.net.URL) Test(org.testng.annotations.Test)

Example 22 with Path

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();
}
Also used : ServletContext(javax.servlet.ServletContext) Context(org.apache.tapestry5.http.services.Context) ServletContext(javax.servlet.ServletContext) ContextImpl(org.apache.tapestry5.http.internal.services.ContextImpl) File(java.io.File) Test(org.testng.annotations.Test)

Example 23 with Path

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();
}
Also used : Context(org.apache.tapestry5.http.services.Context) Resource(org.apache.tapestry5.commons.Resource) File(java.io.File) Test(org.testng.annotations.Test)

Example 24 with Path

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();
}
Also used : Context(org.apache.tapestry5.http.services.Context) Resource(org.apache.tapestry5.commons.Resource) URL(java.net.URL) Test(org.testng.annotations.Test)

Example 25 with Path

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));
    }
}
Also used : StackExtension(org.apache.tapestry5.services.javascript.StackExtension)

Aggregations

Test (org.testng.annotations.Test)22 Request (org.apache.tapestry5.http.services.Request)14 Context (org.apache.tapestry5.http.services.Context)9 Resource (org.apache.tapestry5.commons.Resource)8 Path (io.fabric8.annotations.Path)6 IOException (java.io.IOException)6 URL (java.net.URL)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)5 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)5 Response (org.apache.tapestry5.http.services.Response)5 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)5 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)5 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)5 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)5 Configuration (io.fabric8.annotations.Configuration)4 Endpoint (io.fabric8.annotations.Endpoint)4 External (io.fabric8.annotations.External)4 PortName (io.fabric8.annotations.PortName)4 Protocol (io.fabric8.annotations.Protocol)4