Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockServletConfig


    File testUserRoot = fileEntityRepository.getUserRepoDirectory(getTestUser()).getParentFile();
    FileUtils.deleteQuietly(testUserRoot);
    testUserRoot.mkdirs();
    CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), testUserRoot);
    testUserRoot.deleteOnExit();
    MockServletConfig servletConfig = new MockServletConfig();
    servletConfig.addInitParameter("SVNParentPath", testUserRoot.getAbsolutePath());
    DAVConfig davConfig = new DAVConfig(servletConfig);
    svnController.setDAVConfig(davConfig);
  }
View Full Code Here


        RequestProcessor requestProcessor = new RequestProcessor(configuration);

        MockServletContext servletContext = new MockServletContext();
        servletContext.setAttribute(requestProcessorAttribute, requestProcessor);

        MockServletConfig servletConfig = new MockServletConfig(servletContext);
        servletConfig.addInitParameter("javax.ws.rs.Application", getApplicationClassName());
        servletConfig.addInitParameter("requestProcessorAttribute", requestProcessorAttribute);

        String propertiesFile = getPropertiesFile();
        if (propertiesFile != null) {
            servletConfig.addInitParameter("propertiesLocation", propertiesFile);
        }

        assertNull(configuration.getServletContext());
        assertNull(configuration.getServletConfig());
View Full Code Here

  public void registerServletParamPropertySources_AbstractRefreshableWebApplicationContext() {
    MockServletContext servletContext = new MockServletContext();
    servletContext.addInitParameter("pCommon", "pCommonContextValue");
    servletContext.addInitParameter("pContext1", "pContext1Value");

    MockServletConfig servletConfig = new MockServletConfig(servletContext);
    servletConfig.addInitParameter("pCommon", "pCommonConfigValue");
    servletConfig.addInitParameter("pConfig1", "pConfig1Value");

    AbstractRefreshableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
    ctx.setServletConfig(servletConfig);
    ctx.refresh();
View Full Code Here

  public void registerServletParamPropertySources_StaticWebApplicationContext() {
    MockServletContext servletContext = new MockServletContext();
    servletContext.addInitParameter("pCommon", "pCommonContextValue");
    servletContext.addInitParameter("pContext1", "pContext1Value");

    MockServletConfig servletConfig = new MockServletConfig(servletContext);
    servletConfig.addInitParameter("pCommon", "pCommonConfigValue");
    servletConfig.addInitParameter("pConfig1", "pConfig1Value");

    StaticWebApplicationContext ctx = new StaticWebApplicationContext();
    ctx.setServletConfig(servletConfig);
    ctx.refresh();
View Full Code Here

  public final MockMvc build() {

    WebApplicationContext wac = initWebAppContext();

    ServletContext servletContext = wac.getServletContext();
    MockServletConfig mockServletConfig = new MockServletConfig(servletContext);

    for (MockMvcConfigurer configurer : this.configurers) {
      RequestPostProcessor processor = configurer.beforeMockMvcCreated(this, wac);
      if (processor != null) {
        if (this.defaultRequestBuilder == null) {
View Full Code Here

        wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("test", response.getContentAsString());
View Full Code Here

        wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("test", response.getContentAsString());
View Full Code Here

        wac.registerBeanDefinition("viewResolver", vrDef);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/emptyParameterListHandler");
    MockHttpServletResponse response = new MockHttpServletResponse();

    EmptyParameterListHandlerMethodController.called = false;
View Full Code Here

        wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath1.do");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("test", response.getContentAsString());
View Full Code Here

        wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
    request.addParameter("name", "name1");
    request.addParameter("age", "value2");
    MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockServletConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.