public void testRepeatedRequestCatching() throws Exception { String event = "theEvent"; String widgetKey = StandardViewPortWidget.CHILD_KEY; adapter = (ServletServiceAdapterComponent) initAdapter("repeatedRequest.xml"); // lets get reference to the bean doing the heavy-lifting // its a singleton, so we're cool BeanFactory factory = servlet.getFactory(); MockViewPortWidget widget = (MockViewPortWidget) factory.getBean("rootWidget"); req.addParameter(StandardWidget.EVENT_HANDLER_ID_KEY, event); req.addParameter(StandardWidgetContainerWidget.EVENT_PATH_KEY, widgetKey); // first request, transactionId will get intialized adapter.service(req, resp); // helper returns true on null transactionId MockEventfulStandardWidget child1 = (MockEventfulStandardWidget) widget.getChildren().get(widgetKey); req.addParameter( StandardTransactionFilterWidget.TRANSACTION_ID_KEY, "" + child1.getTransactionId()); // second request with the valid transactionId adapter.service(req, resp); assertTrue(child1.getEventProcessed()); child1.setEventProcessed(false); req.addParameter( StandardTransactionFilterWidget.TRANSACTION_ID_KEY, "" + child1.getTransactionId()); adapter.service(req, resp); // transactionId used 2nd time, should not process the event assertFalse(child1.getEventProcessed()); }
public void testSerialization() throws Exception { adapter = (ServletServiceAdapterComponent) initAdapter("serializationTestsConf.xml"); BeanFactory factory = servlet.getFactory(); MockViewPortWidget widget = (MockViewPortWidget) factory.getBean("rootWidget"); widget.setChild(new MockStandardWidget()); adapter.service(req, resp); // success if no exception thrown }
public void testDestroyPropagates() throws Exception { adapter = (ServletServiceAdapterComponent) initAdapter("repeatedRequest.xml"); MockViewPortWidget widget = (MockViewPortWidget) servlet.getFactory().getBean("rootWidget"); // initializes everything adapter.service(req, resp); adapter._getComponent().destroy(); MockEventfulStandardWidget child = (MockEventfulStandardWidget) widget.getChildren().get(StandardViewPortWidget.CHILD_KEY); assertTrue(child.getDestroyCalled()); }