protected void setUp() throws Exception { super.setUp(); System.setProperty("TEST_JDBC_DRIVER", "org.postgresql.Driver"); System.setProperty("TEST_JDBC_URL", "jdbc:postgresql:gttest"); System.setProperty("TEST_JDBC_USER", "test"); System.setProperty("TEST_JDBC_PASSWORD", "toast"); System.setProperty("ALLOW_ENV_PARAMETRIZATION", "true"); GeoWebCacheExtensions gse = new GeoWebCacheExtensions(); GeoWebCacheEnvironment genv = new GeoWebCacheEnvironment(); gse.setApplicationContext(appContext); expect(appContext.getBeanNamesForType(GeoWebCacheEnvironment.class)) .andReturn(new String[] {"environment"}); expect(appContext.getBean("environment")).andReturn(genv); Map<String, GeoWebCacheEnvironment> genvMap = new HashMap<>(); genvMap.put("environment", genv); expect(appContext.getBeansOfType(GeoWebCacheEnvironment.class)) .andReturn(genvMap) .anyTimes(); expect(appContext.getBean("environment")).andReturn(genv).anyTimes(); replay(appContext); }
public void testEnvironment() { ApplicationContext appContext = createMock(ApplicationContext.class); GeoWebCacheEnvironment genv = new GeoWebCacheEnvironment(); assertEquals(0, GeoWebCacheExtensions.extensionsCache.size()); expect(appContext.getBeanNamesForType(GeoWebCacheEnvironment.class)) .andReturn(new String[] {"geoWebCacheEnvironment"}); expect(appContext.getBean("geoWebCacheEnvironment")).andReturn(genv); Map<String, GeoWebCacheEnvironment> genvMap = new HashMap<>(); genvMap.put("geoWebCacheEnvironment", genv); expect(appContext.getBeansOfType(GeoWebCacheEnvironment.class)) .andReturn(genvMap) .anyTimes(); replay(appContext); GeoWebCacheExtensions gse = new GeoWebCacheExtensions(); gse.setApplicationContext(appContext); List<GeoWebCacheEnvironment> extensions = GeoWebCacheExtensions.extensions(GeoWebCacheEnvironment.class); assertNotNull(extensions); assertEquals(1, extensions.size()); assertTrue(extensions.contains(genv)); assertTrue(GeoWebCacheEnvironment.ALLOW_ENV_PARAMETRIZATION); }
public void testSystemProperty() { // check for a property we did set up in the setUp GeoWebCacheEnvironment genv = new GeoWebCacheEnvironment(); assertEquals("ABC", genv.resolveValue("${TEST_SYS_PROPERTY}")); Properties props = new Properties(); props.setProperty("TEST_SYS_PROPERTY", "DEF"); props.setProperty("TEST_PROPERTY", "WWW"); genv.setProps(props); assertEquals("ABC", genv.resolveValue("${TEST_SYS_PROPERTY}")); assertEquals("WWW", genv.resolveValue("${TEST_PROPERTY}")); } }