List of usage examples for org.springframework.mock.env MockEnvironment setActiveProfiles
@Override public void setActiveProfiles(String... profiles)
From source file:com.github.nblair.web.ProfileConditionalDelegatingFilterProxyTest.java
/** * Verify behavior when the single required profile is active (delegate SHOULD be invoked). * //from w w w .j a v a 2 s . c om * @throws ServletException * @throws IOException */ @Test public void doFilter_required_profile_set() throws ServletException, IOException { Filter delegate = mock(Filter.class); ProfileConditionalDelegatingFilterProxy filterProxy = new ProfileConditionalDelegatingFilterProxy(delegate); filterProxy.setRequiredProfile("foo"); MockEnvironment environment = new MockEnvironment(); environment.setActiveProfiles("foo"); ServletContext servletContext = mockServletContextWithEnvironment(environment); filterProxy.setServletContext(servletContext); ServletRequest request = mock(ServletRequest.class); ServletResponse response = mock(ServletResponse.class); FilterChain filterChain = mock(FilterChain.class); filterProxy.doFilter(request, response, filterChain); verify(delegate).doFilter(request, response, filterChain); }
From source file:org.cloudfoundry.identity.uaa.db.DatabaseParametersTests.java
@Override @Before//from www . jav a2 s . co m public void setUp() throws Exception { MockEnvironment environment = new MockEnvironment(); environment.setProperty("database.initialsize", "0"); environment.setProperty("database.validationquerytimeout", "5"); environment.setProperty("database.connecttimeout", "5"); if (System.getProperty("spring.profiles.active") != null) { environment.setActiveProfiles( StringUtils.commaDelimitedListToStringArray(System.getProperty("spring.profiles.active"))); } super.setUp(environment); vendor = webApplicationContext.getBean(DatabaseUrlModifier.class).getDatabaseType(); }