use of org.apache.tapestry5.http.services.Dispatcher in project tapestry-5 by apache.
the class JavaScriptModule method setupModuleDispatchers.
@Contribute(Dispatcher.class)
@Primary
public static void setupModuleDispatchers(OrderedConfiguration<Dispatcher> configuration, ModuleManager moduleManager, OperationTracker tracker, ResourceStreamer resourceStreamer, PathConstructor pathConstructor, JavaScriptStackSource javaScriptStackSource, JavaScriptStackPathConstructor javaScriptStackPathConstructor, LocalizationSetter localizationSetter, @Symbol(SymbolConstants.MODULE_PATH_PREFIX) String modulePathPrefix, @Symbol(SymbolConstants.ASSET_PATH_PREFIX) String assetPathPrefix) {
configuration.add("Modules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, false), "after:Asset", "before:ComponentEvent");
configuration.add("ComnpressedModules", new ModuleDispatcher(moduleManager, resourceStreamer, tracker, pathConstructor, javaScriptStackSource, javaScriptStackPathConstructor, localizationSetter, modulePathPrefix, assetPathPrefix, true), "after:Modules", "before:ComponentEvent");
}
use of org.apache.tapestry5.http.services.Dispatcher in project tapestry-5 by apache.
the class ComponentEventDispatcherTest method request_for_whitelist_only_page_from_valid_client.
@Test
public void request_for_whitelist_only_page_from_valid_client() throws IOException {
String containerPageName = "foo/MyPage";
ComponentRequestHandler handler = mockComponentRequestHandler();
Request request = mockRequest();
Response response = mockResponse();
ComponentClassResolver resolver = mockComponentClassResolver();
LocalizationSetter localizationSetter = mockLocalizationSetter();
MetaDataLocator metaDataLocator = newMock(MetaDataLocator.class);
ClientWhitelist whitelist = newMock(ClientWhitelist.class);
ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters(containerPageName, containerPageName, "", "anevent", new EmptyEventContext(), new EmptyEventContext());
train_getPath(request, "/foo/MyPage:anevent");
expect(localizationSetter.isSupportedLocaleName("foo")).andReturn(false);
train_isPageName(resolver, containerPageName, true);
train_canonicalizePageName(resolver, containerPageName, containerPageName);
expect(metaDataLocator.findMeta(MetaDataConstants.WHITELIST_ONLY_PAGE, containerPageName, boolean.class)).andReturn(true);
expect(whitelist.isClientRequestOnWhitelist()).andReturn(true);
train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, null);
train_getParameter(request, InternalConstants.CONTAINER_PAGE_NAME, null);
expect(request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND)).andStubReturn(null);
train_for_request_locale(request, localizationSetter);
handler.handleComponentEvent(expectedParameters);
replay();
Dispatcher dispatcher = new ComponentEventDispatcher(handler, new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, localizationSetter, response, null, null, null, true, null, "", metaDataLocator, whitelist));
assertTrue(dispatcher.dispatch(request, response));
verify();
}
use of org.apache.tapestry5.http.services.Dispatcher in project tapestry-5 by apache.
the class ComponentEventDispatcherTest method page_activation_context_in_request.
@Test
public void page_activation_context_in_request() throws Exception {
ComponentRequestHandler handler = mockComponentRequestHandler();
Request request = mockRequest();
Response response = mockResponse();
ComponentClassResolver resolver = mockComponentClassResolver();
LocalizationSetter ls = mockLocalizationSetter();
MetaDataLocator metaDataLocator = neverWhitelistProtected();
ComponentEventRequestParameters expectedParameters = new ComponentEventRequestParameters("mypage", "mypage", "", "eventname", new URLEventContext(contextValueEncoder, new String[] { "alpha", "beta" }), new EmptyEventContext());
train_getPath(request, "/mypage:eventname");
expect(ls.isSupportedLocaleName("mypage:eventname")).andReturn(false);
train_isPageName(resolver, "mypage", true);
train_canonicalizePageName(resolver, "mypage", "mypage");
train_getParameter(request, InternalConstants.PAGE_CONTEXT_NAME, "alpha/beta");
train_getParameter(request, InternalConstants.CONTAINER_PAGE_NAME, null);
expect(request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND)).andStubReturn(null);
train_for_request_locale(request, ls);
handler.handleComponentEvent(expectedParameters);
replay();
Dispatcher dispatcher = new ComponentEventDispatcher(handler, new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls, response, null, null, null, true, null, "", metaDataLocator, null));
assertTrue(dispatcher.dispatch(request, response));
verify();
}
Aggregations