public void process(JsRequest request, JsResponseBuilder response) throws JsException { // JsProcessor defined in preProcessors can determine whether the js process really need to happen // Typically, IfModifiedSinceProcessor is one of the preProcessors, if it sets a 304 status code, // all the remaining JsProcessors in optional and required won't be started. for (JsProcessor processor : preProcessors) { if (!processor.process(request, response)){ return; } } for (JsProcessor processor : optionalProcessors) { if (!processor.process(request, response)) { break; } } // This pipeline sequentially executes JsProcessor, and can stop on any, bypassing // the actual compilation process. This is put here so generated JS will still be // compiled. for (JsProcessor processor : requiredProcessors) { processor.process(request, response); } } }
@Test public void testTwoProcessorsAreRunOneAfterAnother() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(true); EasyMock.expect(processor2.process(request, response)).andReturn(true); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testTwoProcessorsAreRunOneAfterAnother() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(true); EasyMock.expect(processor2.process(request, response)).andReturn(true); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testProcessorStopsProcessingWhenItReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(false); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testProcessorStopsProcessingWhenItReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(true); EasyMock.expect(processor1.process(request, response)).andReturn(false); EasyMock.expect(processor3.process(request, response)).andReturn(true); control.replay(); registry.process(request, response); control.verify(); }
@Test public void testProcessorStopsProcessingWhenPreProcessorsReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(false); control.replay(); registry.process(request, response); control.verify(); } }
@Test public void testProcessorStopsProcessingWhenPreProcessorsReturnsFalse() throws Exception { EasyMock.expect(processor0.process(request, response)).andReturn(false); control.replay(); registry.process(request, response); control.verify(); } }