org.springframework.core.env.DummyEnvironment Java Examples
The following examples show how to use
org.springframework.core.env.DummyEnvironment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DispatcherServletTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void environmentOperations() { DispatcherServlet servlet = new DispatcherServlet(); ConfigurableEnvironment defaultEnv = servlet.getEnvironment(); assertThat(defaultEnv, notNullValue()); ConfigurableEnvironment env1 = new StandardServletEnvironment(); servlet.setEnvironment(env1); // should succeed assertThat(servlet.getEnvironment(), sameInstance(env1)); try { servlet.setEnvironment(new DummyEnvironment()); fail("expected IllegalArgumentException for non-configurable Environment"); } catch (IllegalArgumentException ex) { } class CustomServletEnvironment extends StandardServletEnvironment { } @SuppressWarnings("serial") DispatcherServlet custom = new DispatcherServlet() { @Override protected ConfigurableWebEnvironment createEnvironment() { return new CustomServletEnvironment(); } }; assertThat(custom.getEnvironment(), instanceOf(CustomServletEnvironment.class)); }
Example #2
Source File: DispatcherServletTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void environmentOperations() { DispatcherServlet servlet = new DispatcherServlet(); ConfigurableEnvironment defaultEnv = servlet.getEnvironment(); assertThat(defaultEnv, notNullValue()); ConfigurableEnvironment env1 = new StandardServletEnvironment(); servlet.setEnvironment(env1); // should succeed assertThat(servlet.getEnvironment(), sameInstance(env1)); try { servlet.setEnvironment(new DummyEnvironment()); fail("expected IllegalArgumentException for non-configurable Environment"); } catch (IllegalArgumentException ex) { } class CustomServletEnvironment extends StandardServletEnvironment { } @SuppressWarnings("serial") DispatcherServlet custom = new DispatcherServlet() { @Override protected ConfigurableWebEnvironment createEnvironment() { return new CustomServletEnvironment(); } }; assertThat(custom.getEnvironment(), instanceOf(CustomServletEnvironment.class)); }
Example #3
Source File: DispatcherServletTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void environmentOperations() { DispatcherServlet servlet = new DispatcherServlet(); ConfigurableEnvironment defaultEnv = servlet.getEnvironment(); assertThat(defaultEnv, notNullValue()); ConfigurableEnvironment env1 = new StandardServletEnvironment(); servlet.setEnvironment(env1); // should succeed assertThat(servlet.getEnvironment(), sameInstance(env1)); try { servlet.setEnvironment(new DummyEnvironment()); fail("expected IllegalArgumentException for non-configurable Environment"); } catch (IllegalArgumentException ex) { } class CustomServletEnvironment extends StandardServletEnvironment { } @SuppressWarnings("serial") DispatcherServlet custom = new DispatcherServlet() { @Override protected ConfigurableWebEnvironment createEnvironment() { return new CustomServletEnvironment(); } }; assertThat(custom.getEnvironment(), instanceOf(CustomServletEnvironment.class)); }