You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2019/11/10 18:04:22 UTC

[cxf] branch 3.3.x-fixes updated: CXF-8150: Update to Spring Boot 2.1.10

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.3.x-fixes by this push:
     new 50360a9  CXF-8150: Update to Spring Boot 2.1.10
50360a9 is described below

commit 50360a938a6e6d807560ac89748fb9f931d44fcf
Author: reta <dr...@gmail.com>
AuthorDate: Sun Nov 10 13:01:31 2019 -0500

    CXF-8150: Update to Spring Boot 2.1.10
    
    (cherry picked from commit 041ae41df9d245ec95298dab057eabbcf922de2b)
---
 parent/pom.xml                                     |   9 +-
 systests/pom.xml                                   |   1 +
 systests/spring-boot/pom.xml                       | 123 +++++++++++++++++++++
 .../apache/cxf/systest/jaxrs/resources/Book.java   |  49 ++++++++
 .../cxf/systest/jaxrs/resources/Library.java       |  65 +++++++++++
 .../spring/boot/SpringClassesScanningTest.java     |  57 ++++++++++
 .../spring/boot/SpringComponentScanningTest.java   |  65 +++++++++++
 .../test/resources/application-classes-scan.yml    |   5 +
 .../test/resources/application-component-scan.yml  |   5 +
 9 files changed, 377 insertions(+), 2 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index f68ef16..5d8fad3 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -189,7 +189,7 @@
         <cxf.slf4j.version>1.7.29</cxf.slf4j.version>
         <cxf.snakeyaml.version>1.24</cxf.snakeyaml.version>
         <cxf.specs.jaxws.api.version>1.2</cxf.specs.jaxws.api.version>
-        <cxf.spring.boot.version>2.1.9.RELEASE</cxf.spring.boot.version>
+        <cxf.spring.boot.version>2.1.10.RELEASE</cxf.spring.boot.version>
         <cxf.spring.ldap.version>2.3.2.RELEASE</cxf.spring.ldap.version>
         <cxf.spring.mock>spring-test</cxf.spring.mock>
         <cxf.spring.osgi.version>1.2.1</cxf.spring.osgi.version>
@@ -704,7 +704,12 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.cxf</groupId>
-                <artifactId>cxf-integration-tracing-jca</artifactId>
+                <artifactId>cxf-integration-tracing-brave</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.cxf</groupId>
+                <artifactId>cxf-integration-tracing-opentracing</artifactId>
                 <version>${project.version}</version>
             </dependency>
             <dependency>
diff --git a/systests/pom.xml b/systests/pom.xml
index f52f8a7..2de47e5 100644
--- a/systests/pom.xml
+++ b/systests/pom.xml
@@ -54,5 +54,6 @@
         <module>ws-transfer</module>
         <module>rs-sse</module>
         <module>microprofile</module>
+        <module>spring-boot</module>
     </modules>
 </project>
diff --git a/systests/spring-boot/pom.xml b/systests/spring-boot/pom.xml
new file mode 100644
index 0000000..e85659f
--- /dev/null
+++ b/systests/spring-boot/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<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/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>cxf-parent</artifactId>
+        <groupId>org.apache.cxf</groupId>
+        <version>3.4.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf.systests</groupId>
+    <artifactId>cxf-systests-spring-boot</artifactId>
+    <name>Apache CXF Spring Boot Integration System Tests</name>
+    <description>Apache CXF Spring Boot Integration System Tests</description>
+    <url>https://cxf.apache.org</url>
+    
+    <properties>
+        <cxf.module.name>org.apache.cxf.systests.spring.boot</cxf.module.name>
+    </properties>
+    
+    <build>
+        <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
+        <testResources>
+            <testResource>
+                <directory>src/test/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </testResource>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                        <configuration>
+                            <archive>
+                                <manifestEntries>
+                                    <Automatic-Module-Name>${cxf.module.name}.tests</Automatic-Module-Name>
+                                </manifestEntries>
+                            </archive>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <version>2.0.1.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <version>${cxf.spring.boot.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Book.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Book.java
new file mode 100644
index 0000000..7fd0f20
--- /dev/null
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Book.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.resources;
+
+public class Book {
+    private String title;
+    private String author;
+
+    public Book() {
+    }
+
+    public Book(final String title, final String author) {
+        this.setTitle(title);
+        this.setAuthor(author);
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+}
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Library.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Library.java
new file mode 100644
index 0000000..43fa6da
--- /dev/null
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/resources/Library.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.resources;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.springframework.stereotype.Component;
+
+import io.swagger.v3.oas.annotations.Parameter;
+
+@Component
+@Path("library")
+public class Library {
+    private Map<String, Book> books = Collections.synchronizedMap(
+        new TreeMap<String, Book>(String.CASE_INSENSITIVE_ORDER));
+
+    public Library() {
+        books.put("1", new Book("Book #1", "John Smith"));
+        books.put("2", new Book("Book #2", "Tom Tommyknocker"));
+    }
+
+    @Produces({ MediaType.APPLICATION_JSON })
+    @GET
+    public Response getBooks(@Parameter(required = true) @QueryParam("page") @DefaultValue("1") int page) {
+        return Response.ok(books.values()).build();
+    }
+
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Path("{id}")
+    @GET
+    public Response getBook(@PathParam("id") String id) {
+        return books.containsKey(id) 
+            ? Response.ok().entity(books.get(id)).build() 
+                : Response.status(Status.NOT_FOUND).build();
+    }
+}
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClassesScanningTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClassesScanningTest.java
new file mode 100644
index 0000000..c102b28
--- /dev/null
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClassesScanningTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.spring.boot;
+
+import org.apache.cxf.jaxrs.spring.AbstractJaxrsClassesScanServer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringClassesScanningTest.TestConfig.class)
+@ActiveProfiles("classes-scan")
+public class SpringClassesScanningTest {
+    @Autowired private AbstractJaxrsClassesScanServer scanner;
+    
+    @Configuration
+    @EnableAutoConfiguration
+    static class TestConfig {
+    }
+    
+    @Test
+    public void testCxfClassesScan() {
+        // No features are registered since class scanner only looks for JAX-RS's 
+        // @Provider annotations, not JAX-RS/CXF Features.
+        assertThat(scanner.getFeatures()).isEmpty();
+        assertThat(scanner.getOutInterceptors()).isEmpty();
+        assertThat(scanner.getInInterceptors()).isEmpty();
+        assertThat(scanner.getOutFaultInterceptors()).isEmpty();
+        assertThat(scanner.getInFaultInterceptors()).isEmpty();
+    }
+}
diff --git a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringComponentScanningTest.java b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringComponentScanningTest.java
new file mode 100644
index 0000000..c180125
--- /dev/null
+++ b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringComponentScanningTest.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.spring.boot;
+
+import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
+import org.apache.cxf.jaxrs.spring.AbstractSpringComponentScanServer;
+import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringComponentScanningTest.TestConfig.class)
+@ActiveProfiles("component-scan")
+public class SpringComponentScanningTest {
+    @Autowired private AbstractSpringComponentScanServer scanner; 
+    
+    @Configuration
+    @EnableAutoConfiguration
+    @ComponentScan(basePackageClasses = Library.class)
+    static class TestConfig {
+    }
+    
+    @Test
+    public void testCxfComponentScan() {
+        // The component scanner only looks for CXF's @Provider annotations, 
+        // not JAX-RS Features/@Provider.
+        assertThat(scanner.getFeatures())
+            .hasSize(2)
+            .hasOnlyElementsOfTypes(OpenApiFeature.class, JAXRSBeanValidationFeature.class);
+        
+        assertThat(scanner.getOutInterceptors()).isEmpty();
+        assertThat(scanner.getInInterceptors()).isEmpty();
+        assertThat(scanner.getOutFaultInterceptors()).isEmpty();
+        assertThat(scanner.getInFaultInterceptors()).isEmpty();
+    }
+}
diff --git a/systests/spring-boot/src/test/resources/application-classes-scan.yml b/systests/spring-boot/src/test/resources/application-classes-scan.yml
new file mode 100644
index 0000000..b28b753
--- /dev/null
+++ b/systests/spring-boot/src/test/resources/application-classes-scan.yml
@@ -0,0 +1,5 @@
+cxf:
+  path: /api
+  jaxrs:
+    classes-scan: true
+    classes-scan-packages: org.apache.cxf.systest.jaxrs.resources,com.fasterxml.jackson.jaxrs.json,org.apache.cxf.jaxrs.openapi,org.apache.cxf.jaxrs.validation
diff --git a/systests/spring-boot/src/test/resources/application-component-scan.yml b/systests/spring-boot/src/test/resources/application-component-scan.yml
new file mode 100644
index 0000000..cfa69e4
--- /dev/null
+++ b/systests/spring-boot/src/test/resources/application-component-scan.yml
@@ -0,0 +1,5 @@
+cxf:
+  path: /api
+  jaxrs:
+    component-scan: true
+    classes-scan-packages: org.apache.cxf.systest.jaxrs.resources,com.fasterxml.jackson.jaxrs.json,org.apache.cxf.jaxrs.openapi,org.apache.cxf.jaxrs.validation