Search in sources :

Example 86 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class IgnoredPathsFilterTest method no_path_info.

@Test
public void no_path_info() throws Exception {
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = mockHttpServletRequestHandler();
    train_getServletPath(request, "/");
    train_getPathInfo(request, null);
    train_service(handler, request, response, true);
    List<String> configuration = CollectionFactory.newList("/fred");
    replay();
    HttpServletRequestFilter filter = new IgnoredPathsFilter(configuration);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter) Test(org.testng.annotations.Test)

Example 87 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class IgnoredPathsFilterTest method no_match.

@Test
public void no_match() throws IOException {
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = mockHttpServletRequestHandler();
    train_getServletPath(request, "/");
    train_getPathInfo(request, "barney");
    train_service(handler, request, response, true);
    List<String> configuration = CollectionFactory.newList("/fred");
    replay();
    HttpServletRequestFilter filter = new IgnoredPathsFilter(configuration);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter) Test(org.testng.annotations.Test)

Example 88 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class FlashPersistentFieldStrategyTest method gather_changes_with_active_session.

@Test
public void gather_changes_with_active_session() {
    Session session = mockSession();
    Request request = mockRequest();
    train_getSession(request, false, session);
    train_getAttributeNames(session, "flash:foo.Bar:", "flash:foo.Bar::root", "flash:foo.Bar:nested:down");
    train_getAttribute(session, "flash:foo.Bar::root", "ROOT");
    session.setAttribute("flash:foo.Bar::root", null);
    train_getAttribute(session, "flash:foo.Bar:nested:down", "DOWN");
    session.setAttribute("flash:foo.Bar:nested:down", null);
    replay();
    PersistentFieldStrategy strategy = new FlashPersistentFieldStrategy(request);
    Collection<PersistentFieldChange> changes = strategy.gatherFieldChanges("foo.Bar");
    assertEquals(changes.size(), 2);
    Iterator<PersistentFieldChange> i = changes.iterator();
    PersistentFieldChange change1 = i.next();
    assertEquals(change1.getComponentId(), "");
    assertEquals(change1.getFieldName(), "root");
    assertEquals(change1.getValue(), "ROOT");
    PersistentFieldChange change2 = i.next();
    assertEquals(change2.getComponentId(), "nested");
    assertEquals(change2.getFieldName(), "down");
    assertEquals(change2.getValue(), "DOWN");
    verify();
}
Also used : PersistentFieldStrategy(org.apache.tapestry5.services.PersistentFieldStrategy) Request(org.apache.tapestry5.http.services.Request) PersistentFieldChange(org.apache.tapestry5.services.PersistentFieldChange) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 89 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class AlertManagerImpl method addAlertStorageCleanupCallback.

private void addAlertStorageCleanupCallback() {
    if (needAlertStorageCleanup.get(true)) {
        ajaxResponseRenderer.addCallback(new JavaScriptCallback() {

            public void run(JavaScriptSupport javascriptSupport) {
                // In an Ajax request, the Alerts are added, just so that they can be removed if not persistent.
                // Again, this is for the rare case where there's a redirect to another page.
                getAlertStorage().dismissNonPersistent();
            }
        });
        needAlertStorageCleanup.set(false);
    }
}
Also used : JavaScriptSupport(org.apache.tapestry5.services.javascript.JavaScriptSupport) JavaScriptCallback(org.apache.tapestry5.services.ajax.JavaScriptCallback)

Example 90 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class PageRenderDispatcher method dispatch.

public boolean dispatch(Request request, final Response response) throws IOException {
    if (request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND) != null) {
        // This needs to be cleared out because the container may submit a request back into the filter
        // for the 404 page and some containers reuse the existing HttpServletRequest. See TAP5-2388.
        request.setAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND, null);
        return false;
    }
    PageRenderRequestParameters parameters = linkEncoder.decodePageRenderRequest(request);
    if (parameters == null)
        return false;
    componentRequestHandler.handlePageRender(parameters);
    return true;
}
Also used : PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters)

Aggregations

Test (org.testng.annotations.Test)86 Request (org.apache.tapestry5.http.services.Request)83 Response (org.apache.tapestry5.http.services.Response)25 HttpServletRequest (javax.servlet.http.HttpServletRequest)19 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)19 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)18 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)17 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)15 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 Session (org.apache.tapestry5.http.services.Session)14 Link (org.apache.tapestry5.http.Link)12 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)11 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)9 Context (org.apache.tapestry5.http.services.Context)8 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 IOException (java.io.IOException)7 BaseURLSourceImpl (org.apache.tapestry5.http.internal.services.BaseURLSourceImpl)7 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)7 Dispatcher (org.apache.tapestry5.http.services.Dispatcher)7