Skip to content

Commit bc9b170

Browse files
committed
configure test profiles
1 parent 8cdc680 commit bc9b170

6 files changed

Lines changed: 198 additions & 75 deletions

File tree

‎apache-cxf/cxf-introduction/pom.xml‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</parent>
1212
<properties>
1313
<cxf.version>3.1.6</cxf.version>
14+
<surefire.version>2.19.1</surefire.version>
1415
</properties>
1516
<build>
1617
<plugins>
@@ -26,7 +27,7 @@
2627
<version>2.19.1</version>
2728
<configuration>
2829
<excludes>
29-
<exclude>**/StudentTest.java</exclude>
30+
<exclude>**/*LiveTest.java</exclude>
3031
</excludes>
3132
</configuration>
3233
</plugin>
@@ -44,4 +45,66 @@
4445
<version>${cxf.version}</version>
4546
</dependency>
4647
</dependencies>
48+
49+
<profiles>
50+
<profile>
51+
<id>live</id>
52+
<build>
53+
<plugins>
54+
<plugin>
55+
<groupId>org.codehaus.cargo</groupId>
56+
<artifactId>cargo-maven2-plugin</artifactId>
57+
<version>1.4.19</version>
58+
<configuration>
59+
<container>
60+
<containerId>tomcat8x</containerId>
61+
<type>embedded</type>
62+
</container>
63+
<configuration>
64+
<properties>
65+
<cargo.hostname>localhost</cargo.hostname>
66+
<cargo.servlet.port>8082</cargo.servlet.port>
67+
</properties>
68+
</configuration>
69+
</configuration>
70+
<executions>
71+
<execution>
72+
<id>start-server</id>
73+
<phase>pre-integration-test</phase>
74+
<goals>
75+
<goal>start</goal>
76+
</goals>
77+
</execution>
78+
<execution>
79+
<id>stop-server</id>
80+
<phase>post-integration-test</phase>
81+
<goals>
82+
<goal>stop</goal>
83+
</goals>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
88+
<plugin>
89+
<artifactId>maven-surefire-plugin</artifactId>
90+
<version>${surefire.version}</version>
91+
<executions>
92+
<execution>
93+
<phase>integration-test</phase>
94+
<goals>
95+
<goal>test</goal>
96+
</goals>
97+
<configuration>
98+
<excludes>
99+
<exclude>none</exclude>
100+
</excludes>
101+
</configuration>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
</profile>
108+
109+
</profiles>
47110
</project>

apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentTest.java renamed to apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentLiveTest.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22

33
import static org.junit.Assert.assertEquals;
44

5-
import org.junit.Before;
6-
import org.junit.Test;
7-
85
import java.util.Map;
96

107
import javax.xml.namespace.QName;
118
import javax.xml.ws.Service;
129
import javax.xml.ws.soap.SOAPBinding;
1310

14-
import com.baeldung.cxf.introduction.Baeldung;
15-
import com.baeldung.cxf.introduction.Student;
16-
import com.baeldung.cxf.introduction.StudentImpl;
11+
import org.junit.Before;
12+
import org.junit.Test;
1713

18-
public class StudentTest {
14+
public class StudentLiveTest {
1915
private static QName SERVICE_NAME = new QName("http://introduction.cxf.baeldung.com/", "Baeldung");
2016
private static QName PORT_NAME = new QName("http://introduction.cxf.baeldung.com/", "BaeldungPort");
2117

@@ -25,7 +21,7 @@ public class StudentTest {
2521

2622
{
2723
service = Service.create(SERVICE_NAME);
28-
String endpointAddress = "http://localhost:8080/baeldung";
24+
final String endpointAddress = "http://localhost:8082/cxf-introduction/baeldung";
2925
service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
3026
}
3127

@@ -37,28 +33,28 @@ public void reinstantiateBaeldungInstances() {
3733

3834
@Test
3935
public void whenUsingHelloMethod_thenCorrect() {
40-
String endpointResponse = baeldungProxy.hello("Baeldung");
41-
String localResponse = baeldungImpl.hello("Baeldung");
36+
final String endpointResponse = baeldungProxy.hello("Baeldung");
37+
final String localResponse = baeldungImpl.hello("Baeldung");
4238
assertEquals(localResponse, endpointResponse);
4339
}
4440

4541
@Test
4642
public void whenUsingHelloStudentMethod_thenCorrect() {
47-
Student student = new StudentImpl("John Doe");
48-
String endpointResponse = baeldungProxy.helloStudent(student);
49-
String localResponse = baeldungImpl.helloStudent(student);
43+
final Student student = new StudentImpl("John Doe");
44+
final String endpointResponse = baeldungProxy.helloStudent(student);
45+
final String localResponse = baeldungImpl.helloStudent(student);
5046
assertEquals(localResponse, endpointResponse);
5147
}
5248

5349
@Test
5450
public void usingGetStudentsMethod_thenCorrect() {
55-
Student student1 = new StudentImpl("Adam");
51+
final Student student1 = new StudentImpl("Adam");
5652
baeldungProxy.helloStudent(student1);
5753

58-
Student student2 = new StudentImpl("Eve");
54+
final Student student2 = new StudentImpl("Eve");
5955
baeldungProxy.helloStudent(student2);
60-
61-
Map<Integer, Student> students = baeldungProxy.getStudents();
56+
57+
final Map<Integer, Student> students = baeldungProxy.getStudents();
6258
assertEquals("Adam", students.get(1).getName());
6359
assertEquals("Eve", students.get(2).getName());
6460
}

‎apache-cxf/cxf-jaxrs-implementation/pom.xml‎

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414
<cxf.version>3.1.7</cxf.version>
1515
<httpclient.version>4.5.2</httpclient.version>
16+
<surefire.version>2.19.1</surefire.version>
1617
</properties>
1718
<build>
1819
<plugins>
@@ -28,7 +29,7 @@
2829
<version>2.19.1</version>
2930
<configuration>
3031
<excludes>
31-
<exclude>**/ServiceTest</exclude>
32+
<exclude>**/*LiveTest.java</exclude>
3233
</excludes>
3334
</configuration>
3435
</plugin>
@@ -51,4 +52,66 @@
5152
<version>${httpclient.version}</version>
5253
</dependency>
5354
</dependencies>
55+
56+
<profiles>
57+
<profile>
58+
<id>live</id>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<groupId>org.codehaus.cargo</groupId>
63+
<artifactId>cargo-maven2-plugin</artifactId>
64+
<version>1.4.19</version>
65+
<configuration>
66+
<container>
67+
<containerId>tomcat8x</containerId>
68+
<type>embedded</type>
69+
</container>
70+
<configuration>
71+
<properties>
72+
<cargo.hostname>localhost</cargo.hostname>
73+
<cargo.servlet.port>8082</cargo.servlet.port>
74+
</properties>
75+
</configuration>
76+
</configuration>
77+
<executions>
78+
<execution>
79+
<id>start-server</id>
80+
<phase>pre-integration-test</phase>
81+
<goals>
82+
<goal>start</goal>
83+
</goals>
84+
</execution>
85+
<execution>
86+
<id>stop-server</id>
87+
<phase>post-integration-test</phase>
88+
<goals>
89+
<goal>stop</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
95+
<plugin>
96+
<artifactId>maven-surefire-plugin</artifactId>
97+
<version>${surefire.version}</version>
98+
<executions>
99+
<execution>
100+
<phase>integration-test</phase>
101+
<goals>
102+
<goal>test</goal>
103+
</goals>
104+
<configuration>
105+
<excludes>
106+
<exclude>none</exclude>
107+
</excludes>
108+
</configuration>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
</plugins>
113+
</build>
114+
</profile>
115+
116+
</profiles>
54117
</project>

0 commit comments

Comments
 (0)