Fixup line endings
This commit is contained in:
parent
b583262211
commit
a6e4744c60
|
|
@ -1,41 +1,41 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starters</artifactId>
|
<artifactId>spring-boot-starters</artifactId>
|
||||||
<version>1.2.0.BUILD-SNAPSHOT</version>
|
<version>1.2.0.BUILD-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||||
<name>Spring Boot Undertow Starter</name>
|
<name>Spring Boot Undertow Starter</name>
|
||||||
<description>Spring Boot Undertow Starter</description>
|
<description>Spring Boot Undertow Starter</description>
|
||||||
<url>http://projects.spring.io/spring-boot/</url>
|
<url>http://projects.spring.io/spring-boot/</url>
|
||||||
<organization>
|
<organization>
|
||||||
<name>Pivotal Software, Inc.</name>
|
<name>Pivotal Software, Inc.</name>
|
||||||
<url>http://www.spring.io</url>
|
<url>http://www.spring.io</url>
|
||||||
</organization>
|
</organization>
|
||||||
<properties>
|
<properties>
|
||||||
<main.basedir>${basedir}/../..</main.basedir>
|
<main.basedir>${basedir}/../..</main.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.undertow</groupId>
|
<groupId>io.undertow</groupId>
|
||||||
<artifactId>undertow-core</artifactId>
|
<artifactId>undertow-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.undertow</groupId>
|
<groupId>io.undertow</groupId>
|
||||||
<artifactId>undertow-servlet</artifactId>
|
<artifactId>undertow-servlet</artifactId>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>org.jboss.spec.javax.servlet</groupId>
|
<groupId>org.jboss.spec.javax.servlet</groupId>
|
||||||
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
|
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Class-Path:
|
Class-Path:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,107 +1,107 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.context.embedded.undertow;
|
package org.springframework.boot.context.embedded.undertow;
|
||||||
|
|
||||||
import io.undertow.Handlers;
|
import io.undertow.Handlers;
|
||||||
import io.undertow.Undertow;
|
import io.undertow.Undertow;
|
||||||
import io.undertow.Undertow.Builder;
|
import io.undertow.Undertow.Builder;
|
||||||
import io.undertow.server.HttpHandler;
|
import io.undertow.server.HttpHandler;
|
||||||
import io.undertow.server.handlers.PathHandler;
|
import io.undertow.server.handlers.PathHandler;
|
||||||
import io.undertow.servlet.api.DeploymentManager;
|
import io.undertow.servlet.api.DeploymentManager;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
|
import org.springframework.boot.context.embedded.EmbeddedServletContainer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
|
import org.springframework.boot.context.embedded.EmbeddedServletContainerException;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EmbeddedServletContainer} that can be used to control an embedded Undertow
|
* {@link EmbeddedServletContainer} that can be used to control an embedded Undertow
|
||||||
* server. Typically this class should be created using
|
* server. Typically this class should be created using
|
||||||
* {@link UndertowEmbeddedServletContainerFactory} and not directly.
|
* {@link UndertowEmbeddedServletContainerFactory} and not directly.
|
||||||
*
|
*
|
||||||
* @author Ivan Sopov
|
* @author Ivan Sopov
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
* @see UndertowEmbeddedServletContainer
|
* @see UndertowEmbeddedServletContainer
|
||||||
*/
|
*/
|
||||||
public class UndertowEmbeddedServletContainer implements EmbeddedServletContainer {
|
public class UndertowEmbeddedServletContainer implements EmbeddedServletContainer {
|
||||||
|
|
||||||
private final DeploymentManager manager;
|
private final DeploymentManager manager;
|
||||||
|
|
||||||
private final Builder builder;
|
private final Builder builder;
|
||||||
|
|
||||||
private final String contextPath;
|
private final String contextPath;
|
||||||
|
|
||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
private final boolean autoStart;
|
private final boolean autoStart;
|
||||||
|
|
||||||
private Undertow undertow;
|
private Undertow undertow;
|
||||||
|
|
||||||
private boolean started = false;
|
private boolean started = false;
|
||||||
|
|
||||||
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
public UndertowEmbeddedServletContainer(Builder builder, DeploymentManager manager,
|
||||||
String contextPath, int port, boolean autoStart) {
|
String contextPath, int port, boolean autoStart) {
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.contextPath = contextPath;
|
this.contextPath = contextPath;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.autoStart = autoStart;
|
this.autoStart = autoStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void start() throws EmbeddedServletContainerException {
|
public synchronized void start() throws EmbeddedServletContainerException {
|
||||||
if (!this.autoStart) {
|
if (!this.autoStart) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.undertow == null) {
|
if (this.undertow == null) {
|
||||||
try {
|
try {
|
||||||
HttpHandler servletHandler = this.manager.start();
|
HttpHandler servletHandler = this.manager.start();
|
||||||
if (StringUtils.isEmpty(this.contextPath)) {
|
if (StringUtils.isEmpty(this.contextPath)) {
|
||||||
this.builder.setHandler(servletHandler);
|
this.builder.setHandler(servletHandler);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PathHandler pathHandler = Handlers.path().addPrefixPath(
|
PathHandler pathHandler = Handlers.path().addPrefixPath(
|
||||||
this.contextPath, servletHandler);
|
this.contextPath, servletHandler);
|
||||||
this.builder.setHandler(pathHandler);
|
this.builder.setHandler(pathHandler);
|
||||||
}
|
}
|
||||||
this.undertow = this.builder.build();
|
this.undertow = this.builder.build();
|
||||||
}
|
}
|
||||||
catch (ServletException ex) {
|
catch (ServletException ex) {
|
||||||
throw new EmbeddedServletContainerException(
|
throw new EmbeddedServletContainerException(
|
||||||
"Unable to start embdedded Undertow", ex);
|
"Unable to start embdedded Undertow", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.undertow.start();
|
this.undertow.start();
|
||||||
this.started = true;
|
this.started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void stop() throws EmbeddedServletContainerException {
|
public synchronized void stop() throws EmbeddedServletContainerException {
|
||||||
if (this.started) {
|
if (this.started) {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.undertow.stop();
|
this.undertow.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return this.port;
|
return this.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,96 +1,96 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.boot.context.embedded.undertow;
|
package org.springframework.boot.context.embedded.undertow;
|
||||||
|
|
||||||
import io.undertow.Undertow.Builder;
|
import io.undertow.Undertow.Builder;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.InOrder;
|
import org.mockito.InOrder;
|
||||||
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
|
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
|
||||||
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactoryTests;
|
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactoryTests;
|
||||||
import org.springframework.boot.context.embedded.ErrorPage;
|
import org.springframework.boot.context.embedded.ErrorPage;
|
||||||
import org.springframework.boot.context.embedded.ExampleServlet;
|
import org.springframework.boot.context.embedded.ExampleServlet;
|
||||||
import org.springframework.boot.context.embedded.ServletRegistrationBean;
|
import org.springframework.boot.context.embedded.ServletRegistrationBean;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.mockito.Matchers.anyObject;
|
import static org.mockito.Matchers.anyObject;
|
||||||
import static org.mockito.Mockito.inOrder;
|
import static org.mockito.Mockito.inOrder;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link UndertowEmbeddedServletContainerFactory} and
|
* Tests for {@link UndertowEmbeddedServletContainerFactory} and
|
||||||
* {@link UndertowEmbeddedServletContainer} .
|
* {@link UndertowEmbeddedServletContainer} .
|
||||||
*
|
*
|
||||||
* @author Ivan Sopov
|
* @author Ivan Sopov
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
public class UndertowEmbeddedServletContainerFactoryTests extends
|
public class UndertowEmbeddedServletContainerFactoryTests extends
|
||||||
AbstractEmbeddedServletContainerFactoryTests {
|
AbstractEmbeddedServletContainerFactoryTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UndertowEmbeddedServletContainerFactory getFactory() {
|
protected UndertowEmbeddedServletContainerFactory getFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory(0);
|
return new UndertowEmbeddedServletContainerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void errorPage404() throws Exception {
|
public void errorPage404() throws Exception {
|
||||||
AbstractEmbeddedServletContainerFactory factory = getFactory();
|
AbstractEmbeddedServletContainerFactory factory = getFactory();
|
||||||
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
|
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
|
||||||
this.container = factory.getEmbeddedServletContainer(new ServletRegistrationBean(
|
this.container = factory.getEmbeddedServletContainer(new ServletRegistrationBean(
|
||||||
new ExampleServlet(), "/hello"));
|
new ExampleServlet(), "/hello"));
|
||||||
this.container.start();
|
this.container.start();
|
||||||
assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
|
assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
|
||||||
assertThat(getResponse(getLocalUrl("/not-found")), equalTo("Hello World"));
|
assertThat(getResponse(getLocalUrl("/not-found")), equalTo("Hello World"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNullUndertowBuilderCustomizersThrows() {
|
public void setNullUndertowBuilderCustomizersThrows() {
|
||||||
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
||||||
this.thrown.expect(IllegalArgumentException.class);
|
this.thrown.expect(IllegalArgumentException.class);
|
||||||
this.thrown.expectMessage("undertowBuilderCustomizers must not be null");
|
this.thrown.expectMessage("undertowBuilderCustomizers must not be null");
|
||||||
factory.setUndertowBuilderCustomizers(null);
|
factory.setUndertowBuilderCustomizers(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addNullContextCustomizersThrows() {
|
public void addNullContextCustomizersThrows() {
|
||||||
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
||||||
this.thrown.expect(IllegalArgumentException.class);
|
this.thrown.expect(IllegalArgumentException.class);
|
||||||
this.thrown.expectMessage("undertowBuilderCustomizers must not be null");
|
this.thrown.expectMessage("undertowBuilderCustomizers must not be null");
|
||||||
factory.addUndertowBuilderCustomizers((UndertowBuilderCustomizer[]) null);
|
factory.addUndertowBuilderCustomizers((UndertowBuilderCustomizer[]) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void builderCustomizers() throws Exception {
|
public void builderCustomizers() throws Exception {
|
||||||
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
||||||
UndertowBuilderCustomizer[] customizers = new UndertowBuilderCustomizer[4];
|
UndertowBuilderCustomizer[] customizers = new UndertowBuilderCustomizer[4];
|
||||||
for (int i = 0; i < customizers.length; i++) {
|
for (int i = 0; i < customizers.length; i++) {
|
||||||
customizers[i] = mock(UndertowBuilderCustomizer.class);
|
customizers[i] = mock(UndertowBuilderCustomizer.class);
|
||||||
}
|
}
|
||||||
factory.setUndertowBuilderCustomizers(Arrays.asList(customizers[0],
|
factory.setUndertowBuilderCustomizers(Arrays.asList(customizers[0],
|
||||||
customizers[1]));
|
customizers[1]));
|
||||||
factory.addUndertowBuilderCustomizers(customizers[2], customizers[3]);
|
factory.addUndertowBuilderCustomizers(customizers[2], customizers[3]);
|
||||||
this.container = factory.getEmbeddedServletContainer();
|
this.container = factory.getEmbeddedServletContainer();
|
||||||
InOrder ordered = inOrder((Object[]) customizers);
|
InOrder ordered = inOrder((Object[]) customizers);
|
||||||
for (UndertowBuilderCustomizer customizer : customizers) {
|
for (UndertowBuilderCustomizer customizer : customizers) {
|
||||||
ordered.verify(customizer).customize((Builder) anyObject());
|
ordered.verify(customizer).customize((Builder) anyObject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue