|
|
@ -29,7 +29,7 @@ import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.testutil.MockServlet;
|
|
|
|
import org.springframework.boot.testutil.MockServlet;
|
|
|
|
import org.springframework.boot.web.servlet.context.config.ExampleEmbeddedWebApplicationConfiguration;
|
|
|
|
import org.springframework.boot.web.servlet.context.config.ExampleServletWebServerApplicationConfiguration;
|
|
|
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
|
|
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
|
|
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
|
|
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
@ -55,14 +55,15 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void createFromScan() throws Exception {
|
|
|
|
public void createFromScan() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
ExampleEmbeddedWebApplicationConfiguration.class.getPackage().getName());
|
|
|
|
ExampleServletWebServerApplicationConfiguration.class.getPackage()
|
|
|
|
|
|
|
|
.getName());
|
|
|
|
verifyContext();
|
|
|
|
verifyContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void sessionScopeAvailable() throws Exception {
|
|
|
|
public void sessionScopeAvailable() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
ExampleEmbeddedWebApplicationConfiguration.class,
|
|
|
|
ExampleServletWebServerApplicationConfiguration.class,
|
|
|
|
SessionScopedComponent.class);
|
|
|
|
SessionScopedComponent.class);
|
|
|
|
verifyContext();
|
|
|
|
verifyContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -70,7 +71,7 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void sessionScopeAvailableToServlet() throws Exception {
|
|
|
|
public void sessionScopeAvailableToServlet() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
ExampleEmbeddedWebApplicationConfiguration.class,
|
|
|
|
ExampleServletWebServerApplicationConfiguration.class,
|
|
|
|
ExampleServletWithAutowired.class, SessionScopedComponent.class);
|
|
|
|
ExampleServletWithAutowired.class, SessionScopedComponent.class);
|
|
|
|
Servlet servlet = this.context.getBean(ExampleServletWithAutowired.class);
|
|
|
|
Servlet servlet = this.context.getBean(ExampleServletWithAutowired.class);
|
|
|
|
assertThat(servlet).isNotNull();
|
|
|
|
assertThat(servlet).isNotNull();
|
|
|
@ -79,14 +80,14 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void createFromConfigClass() throws Exception {
|
|
|
|
public void createFromConfigClass() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
|
|
|
ExampleEmbeddedWebApplicationConfiguration.class);
|
|
|
|
ExampleServletWebServerApplicationConfiguration.class);
|
|
|
|
verifyContext();
|
|
|
|
verifyContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void registerAndRefresh() throws Exception {
|
|
|
|
public void registerAndRefresh() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
|
|
|
this.context.register(ExampleEmbeddedWebApplicationConfiguration.class);
|
|
|
|
this.context.register(ExampleServletWebServerApplicationConfiguration.class);
|
|
|
|
this.context.refresh();
|
|
|
|
this.context.refresh();
|
|
|
|
verifyContext();
|
|
|
|
verifyContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,8 +95,8 @@ public class AnnotationConfigServletWebServerApplicationContextTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scanAndRefresh() throws Exception {
|
|
|
|
public void scanAndRefresh() throws Exception {
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
|
|
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
|
|
|
this.context.scan(
|
|
|
|
this.context.scan(ExampleServletWebServerApplicationConfiguration.class
|
|
|
|
ExampleEmbeddedWebApplicationConfiguration.class.getPackage().getName());
|
|
|
|
.getPackage().getName());
|
|
|
|
this.context.refresh();
|
|
|
|
this.context.refresh();
|
|
|
|
verifyContext();
|
|
|
|
verifyContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|