@Test
  public void testEnvironmentVariablesAreEvaluatedInTemplate() throws IOException {
    currentTemplate = "test_env_content.ftl";
    System.setProperty("TEST_PROPERTY", "MYVALUE");
    MockServletContext servletContext = (MockServletContext) applicationContext.getServletContext();
    servletContext.setInitParameter("TEST_INIT_PARAM", "MYPARAM");
    try {
      ByteArrayOutputStream outStream = new ByteArrayOutputStream();
      outputFormat.write(fcType, getFeatureInfoRequest, outStream);
      String result = new String(outStream.toByteArray());

      assertEquals("MYVALUE,MYPARAM", result);
    } finally {
      System.clearProperty("TEST_PROPERTY");
    }
  }
예제 #2
0
  @Before
  public void setUp() throws Exception {
    ctx = new MockServletContext();
    ctx.setInitParameter("security-config", "/WEB-INF/security-config.xml");
    ctx.setResourceAsStream(
        "/WEB-INF/security-config.xml", SecConfigTest.getSecurityConfigInputStream());

    MockFilterConfig conf = new MockFilterConfig();
    conf.setupServletContext(ctx);

    req = new MockHttpServletRequest();
    req.setContextPath("contextPath/");

    resp = new MockHttpServletResponse();
    chain = new MockFilterChain();

    me = new SecFilter();
    me.init(conf);
  }