类org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext源码实例Demo

下面列出了怎么用org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext的API类实例代码及写法,或者点击链接到github查看源代码。

@Test
public void mvcEndpoint() throws Throwable {

    AnnotationConfigEmbeddedWebApplicationContext applicationContext = 
        new AnnotationConfigEmbeddedWebApplicationContext(CallbackEmbeddedContainerCustomizer.class, EmbeddedContainerConfiguration.class, EndpointConfiguration.class);

    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
    org.junit.Assert.assertNotNull("the processEngine should not be null", processEngine);

    ProcessEngineEndpoint processEngineEndpoint =
            applicationContext.getBean(ProcessEngineEndpoint.class);
    org.junit.Assert.assertNotNull("the processEngineEndpoint should not be null", processEngineEndpoint);

    RestTemplate restTemplate = applicationContext.getBean(RestTemplate.class);

    ResponseEntity<Map> mapResponseEntity =
            restTemplate.getForEntity("http://localhost:9091/activiti/", Map.class);

    Map map = mapResponseEntity.getBody();

    String[] criticalKeys = {"completedTaskCount", "openTaskCount", "cachedProcessDefinitionCount"};

    Map<?, ?> invokedResults = processEngineEndpoint.invoke();
    for (String k : criticalKeys) {
        org.junit.Assert.assertTrue(map.containsKey(k));
        org.junit.Assert.assertEquals(((Number) map.get(k)).longValue(), ((Number) invokedResults.get(k)).longValue());
    }
}
 
源代码2 项目: moserp   文件: TestEnvironment.java
public int getPort() {
    return ((AnnotationConfigEmbeddedWebApplicationContext)context).getEmbeddedServletContainer().getPort();
}
 
 类所在包
 类方法
 同包方法