protected final <T> void train_peekRequired(Environment env, Class<T> type, T value) { expect(env.peekRequired(type)).andReturn(value); }
public Object get(Object instance, InstanceContext context) { return required ? environment.peekRequired(environmentalType) : environment.peek(environmentalType); }
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { renderer.renderMarkup(writer); environment.peekRequired(JavaScriptSupport.class).importStack(InternalConstants.CORE_STACK_NAME); } };
public void renderMarkup(MarkupWriter writer, JSONObject arg1, PartialMarkupRenderer renderer) { JavaScriptSupport javaScriptSupport = environment.peekRequired(JavaScriptSupport.class); renderer.renderMarkup(writer, arg1); String url = jsSupport.store(); if ( url != null ) { javaScriptSupport.importJavaScriptLibrary(url); javaScriptSupport.addScript("jsOnLoad();"); } } };
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { JavaScriptSupport javaScriptSupport = environment.peekRequired(JavaScriptSupport.class); renderer.renderMarkup(writer); String url = jsSupport.store(); if ( url != null ) { javaScriptSupport.importJavaScriptLibrary(url); javaScriptSupport.addScript("jsOnLoad();"); } } };
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { DocumentLinker linker = environment.peekRequired(DocumentLinker.class); JavaScriptSupportImpl support = new JavaScriptSupportImpl(linker, javascriptStackSource, javascriptStackPathConstructor, suppressCoreStylesheetsHook); environment.push(JavaScriptSupport.class, support); renderer.renderMarkup(writer); environment.pop(JavaScriptSupport.class); support.commit(); } };
void beginRender(MarkupWriter writer) { ValidationDecorator existing = environment.peekRequired(ValidationDecorator.class); environment.push(ValidationDecorator.class, new ChattyValidationDecorator(writer, existing)); }
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) { IdAllocator idAllocator; if (request.getParameter(InternalConstants.SUPPRESS_NAMESPACED_IDS) == null) { String uid = Long.toHexString(System.nanoTime()); String namespace = "_" + uid; idAllocator = new IdAllocator(namespace); } else { // When suppressed, work just like normal rendering. idAllocator = new IdAllocator(); } DocumentLinker linker = environment.peekRequired(DocumentLinker.class); JavaScriptSupportImpl support = new JavaScriptSupportImpl(linker, javascriptStackSource, javascriptStackPathConstructor, idAllocator, true, suppressCoreStylesheetsHook); environment.push(JavaScriptSupport.class, support); renderer.renderMarkup(writer, reply); environment.pop(JavaScriptSupport.class); support.commit(); } };
@Test public void peek_required_when_available() { Environment e = new EnvironmentImpl(); Location l = mockLocation(); replay(); e.push(Location.class, l); assertSame(l, e.peekRequired(Location.class)); verify(); }
@Test public void peek_required_does_not_list_previouly_available() { Environment e = new EnvironmentImpl(); Location l = mockLocation(); replay(); e.push(Location.class, l); e.pop(Location.class); try { e.peekRequired(Location.class); unreachable(); } catch (UnknownValueException ex) { assertEquals( ex.getMessage(), "No object of type org.apache.tapestry5.ioc.Location is available from the Environment."); assertFalse(ex.getAvailableValues().getValues().contains("org.apache.tapestry5.ioc.Location")); } verify(); } }
@Test public void peek_required_without_value_is_error() { Environment e = new EnvironmentImpl(); Location l = mockLocation(); Component c = mockComponent(); replay(); e.push(Location.class, l); e.push(Component.class, c); try { e.peekRequired(List.class); unreachable(); } catch (UnknownValueException ex) { assertEquals( ex.getMessage(), "No object of type java.util.List is available from the Environment."); } verify(); }
FormSupport formSupport = environment.peekRequired(FormSupport.class);