Java 类org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory 实例源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:TomcatEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(int port,
AbstractEmbeddedServletContainerFactory factory) {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
((TomcatEmbeddedServletContainerFactory) factory)
.addAdditionalTomcatConnectors(connector);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:UndertowEmbeddedServletContainerFactoryTests.java
@Test
public void errorPage404() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
this.container.start();
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:UndertowEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(final int port,
AbstractEmbeddedServletContainerFactory factory) {
((UndertowEmbeddedServletContainerFactory) factory)
.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
public void customize(Builder builder) {
builder.addHttpListener(port, "0.0.0.0");
}
});
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:JettyEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(final int port,
AbstractEmbeddedServletContainerFactory factory) {
((JettyEmbeddedServletContainerFactory) factory)
.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
server.addConnector(connector);
}
});
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:JettyEmbeddedServletContainerFactoryTests.java
@Override
@SuppressWarnings("serial")
// Workaround for Jetty issue - https://bugs.eclipse.org/bugs/show_bug.cgi?id=470646
protected String setUpFactoryForCompression(final int contentSize, String[] mimeTypes,
String[] excludedUserAgents) throws Exception {
char[] chars = new char[contentSize];
Arrays.fill(chars, 'F');
final String testContent = new String(chars);
AbstractEmbeddedServletContainerFactory factory = getFactory();
Compression compression = new Compression();
compression.setEnabled(true);
if (mimeTypes != null) {
compression.setMimeTypes(mimeTypes);
}
if (excludedUserAgents != null) {
compression.setExcludedUserAgents(excludedUserAgents);
}
factory.setCompression(compression);
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentLength(contentSize);
resp.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
resp.getWriter().print(testContent);
}
}, "/test.txt"));
this.container.start();
return testContent;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithJettyContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomJettyContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
// The server.port environment property was not explicitly set so the container
// factory should take precedence...
assertThat(containerFactory.getPort()).isEqualTo(3000);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithUndertowContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomUndertowContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
assertThat(containerFactory.getPort()).isEqualTo(3000);
}
项目:spring-boot-concourse
文件:TomcatEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(int port,
AbstractEmbeddedServletContainerFactory factory) {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
((TomcatEmbeddedServletContainerFactory) factory)
.addAdditionalTomcatConnectors(connector);
}
项目:spring-boot-concourse
文件:UndertowEmbeddedServletContainerFactoryTests.java
@Test
public void errorPage404() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
this.container.start();
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
项目:spring-boot-concourse
文件:UndertowEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(final int port,
AbstractEmbeddedServletContainerFactory factory) {
((UndertowEmbeddedServletContainerFactory) factory)
.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
public void customize(Builder builder) {
builder.addHttpListener(port, "0.0.0.0");
}
});
}
项目:spring-boot-concourse
文件:JettyEmbeddedServletContainerFactoryTests.java
@Override
protected void addConnector(final int port,
AbstractEmbeddedServletContainerFactory factory) {
((JettyEmbeddedServletContainerFactory) factory)
.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
server.addConnector(connector);
}
});
}
项目:spring-boot-concourse
文件:JettyEmbeddedServletContainerFactoryTests.java
@Override
@SuppressWarnings("serial")
// Workaround for Jetty issue - https://bugs.eclipse.org/bugs/show_bug.cgi?id=470646
protected String setUpFactoryForCompression(final int contentSize, String[] mimeTypes,
String[] excludedUserAgents) throws Exception {
char[] chars = new char[contentSize];
Arrays.fill(chars, 'F');
final String testContent = new String(chars);
AbstractEmbeddedServletContainerFactory factory = getFactory();
Compression compression = new Compression();
compression.setEnabled(true);
if (mimeTypes != null) {
compression.setMimeTypes(mimeTypes);
}
if (excludedUserAgents != null) {
compression.setExcludedUserAgents(excludedUserAgents);
}
factory.setCompression(compression);
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentLength(contentSize);
resp.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
resp.getWriter().print(testContent);
}
}, "/test.txt"));
this.container.start();
return testContent;
}
项目:spring-boot-concourse
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithJettyContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomJettyContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
// The server.port environment property was not explicitly set so the container
// factory should take precedence...
assertThat(containerFactory.getPort()).isEqualTo(3000);
}
项目:spring-boot-concourse
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithUndertowContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomUndertowContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertThat(server).isNotNull();
assertThat(containerFactory.getPort()).isEqualTo(3000);
}
项目:contestparser
文件:UndertowEmbeddedServletContainerFactoryTests.java
@Test
public void errorPage404() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
this.container.start();
assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
assertThat(getResponse(getLocalUrl("/not-found")), equalTo("Hello World"));
}
项目:contestparser
文件:JettyEmbeddedServletContainerFactoryTests.java
@Override
@SuppressWarnings("serial")
// Workaround for Jetty issue - https://bugs.eclipse.org/bugs/show_bug.cgi?id=470646
protected String setUpFactoryForCompression(final int contentSize, String[] mimeTypes,
String[] excludedUserAgents) throws Exception {
char[] chars = new char[contentSize];
Arrays.fill(chars, 'F');
final String testContent = new String(chars);
AbstractEmbeddedServletContainerFactory factory = getFactory();
Compression compression = new Compression();
compression.setEnabled(true);
if (mimeTypes != null) {
compression.setMimeTypes(mimeTypes);
}
if (excludedUserAgents != null) {
compression.setExcludedUserAgents(excludedUserAgents);
}
factory.setCompression(compression);
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentLength(contentSize);
resp.setHeader(HttpHeaders.CONTENT_TYPE, "text/plain");
resp.getWriter().print(testContent);
}
}, "/test.txt"));
this.container.start();
return testContent;
}
项目:contestparser
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithJettyContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomJettyContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertNotNull(server);
// The server.port environment property was not explicitly set so the container
// factory should take precedence...
assertEquals(3000, containerFactory.getPort());
}
项目:contestparser
文件:ServerPropertiesAutoConfigurationTests.java
@Test
public void customizeWithUndertowContainerFactory() throws Exception {
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
this.context.register(CustomUndertowContainerConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
containerFactory = this.context
.getBean(AbstractEmbeddedServletContainerFactory.class);
ServerProperties server = this.context.getBean(ServerProperties.class);
assertNotNull(server);
assertEquals(3000, containerFactory.getPort());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot
文件:ServerPropertiesAutoConfigurationTests.java
@Before
public void init() {
containerFactory = mock(AbstractEmbeddedServletContainerFactory.class);
}
项目:spring-boot-concourse
文件:ServerPropertiesAutoConfigurationTests.java
@Before
public void init() {
containerFactory = mock(AbstractEmbeddedServletContainerFactory.class);
}
项目:contestparser
文件:ServerPropertiesAutoConfigurationTests.java
@Before
public void init() {
containerFactory = mock(AbstractEmbeddedServletContainerFactory.class);
}