This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 7e088f4aa5 CXF-8855: Get rid of EasyMock in cxf-rt-ws-transfer (#1390)
7e088f4aa5 is described below
commit 7e088f4aa5ddc849411f70635ed50859bfa236f8
Author: Andriy Redko <[email protected]>
AuthorDate: Fri Aug 25 10:44:53 2023 -0400
CXF-8855: Get rid of EasyMock in cxf-rt-ws-transfer (#1390)
---
rt/ws/transfer/pom.xml | 189 +++++++++++----------
.../transfer/integration/ResourceFactoryTest.java | 27 +--
.../cxf/ws/transfer/integration/ResourceTest.java | 33 ++--
3 files changed, 124 insertions(+), 125 deletions(-)
diff --git a/rt/ws/transfer/pom.xml b/rt/ws/transfer/pom.xml
index 2f594ab1b0..5d5c4cbb21 100644
--- a/rt/ws/transfer/pom.xml
+++ b/rt/ws/transfer/pom.xml
@@ -1,99 +1,100 @@
<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">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>cxf-rt-ws-transfer</artifactId>
- <packaging>jar</packaging>
- <name>Apache CXF Runtime WS Transfer</name>
- <url>https://cxf.apache.org</url>
-
- <parent>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-parent</artifactId>
- <version>4.0.3-SNAPSHOT</version>
- <relativePath>../../../parent/pom.xml</relativePath>
- </parent>
+ <artifactId>cxf-rt-ws-transfer</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache CXF Runtime WS Transfer</name>
+ <url>https://cxf.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <cxf.module.name>org.apache.cxf.ws.transfer</cxf.module.name>
- </properties>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>4.0.3-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.messaging.saaj</groupId>
- <artifactId>saaj-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>cxf-rt-transports-local</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-xjc-plugin</artifactId>
- <version>${cxf.xjc-utils.version}</version>
- <executions>
- <execution>
- <id>generate-transfer</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>xsdtojava</goal>
- </goals>
- <configuration>
- <fork>${cxf.xjcplugin.forkmode}</fork>
-
<additionalJvmArgs>${cxf.xjc.jvmArgs}</additionalJvmArgs>
-
<sourceRoot>${basedir}/target/generated-sources/xjc</sourceRoot>
- <xsdOptions>
- <xsdOption>
-
<xsd>${basedir}/src/main/resources/schemas/transfer.xsd</xsd>
-
<packagename>org.apache.cxf.ws.transfer</packagename>
-
<bindingFile>${basedir}/src/main/resources/schemas/transfer.xjb</bindingFile>
-
<catalog>${basedir}/src/main/resources/schemas/catalog.cat</catalog>
- </xsdOption>
- </xsdOptions>
- </configuration>
- </execution>
- <execution>
- <id>generate-fragment</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>xsdtojava</goal>
- </goals>
- <configuration>
- <fork>${cxf.xjcplugin.forkmode}</fork>
-
<additionalJvmArgs>${cxf.xjc.jvmArgs}</additionalJvmArgs>
-
<sourceRoot>${basedir}/target/generated-sources/xjc</sourceRoot>
- <xsdOptions>
- <xsdOption>
-
<xsd>${basedir}/src/main/resources/schemas/fragment.xsd</xsd>
-
<packagename>org.apache.cxf.ws.transfer.dialect.fragment</packagename>
-
<catalog>${basedir}/src/main/resources/schemas/catalog-fragment.cat</catalog>
- </xsdOption>
- </xsdOptions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <cxf.module.name>org.apache.cxf.ws.transfer</cxf.module.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.messaging.saaj</groupId>
+ <artifactId>saaj-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${cxf.mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-xjc-plugin</artifactId>
+ <version>${cxf.xjc-utils.version}</version>
+ <executions>
+ <execution>
+ <id>generate-transfer</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>xsdtojava</goal>
+ </goals>
+ <configuration>
+ <fork>${cxf.xjcplugin.forkmode}</fork>
+
<additionalJvmArgs>${cxf.xjc.jvmArgs}</additionalJvmArgs>
+
<sourceRoot>${basedir}/target/generated-sources/xjc</sourceRoot>
+ <xsdOptions>
+ <xsdOption>
+
<xsd>${basedir}/src/main/resources/schemas/transfer.xsd</xsd>
+
<packagename>org.apache.cxf.ws.transfer</packagename>
+
<bindingFile>${basedir}/src/main/resources/schemas/transfer.xjb</bindingFile>
+
<catalog>${basedir}/src/main/resources/schemas/catalog.cat</catalog>
+ </xsdOption>
+ </xsdOptions>
+ </configuration>
+ </execution>
+ <execution>
+ <id>generate-fragment</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>xsdtojava</goal>
+ </goals>
+ <configuration>
+ <fork>${cxf.xjcplugin.forkmode}</fork>
+
<additionalJvmArgs>${cxf.xjc.jvmArgs}</additionalJvmArgs>
+
<sourceRoot>${basedir}/target/generated-sources/xjc</sourceRoot>
+ <xsdOptions>
+ <xsdOption>
+
<xsd>${basedir}/src/main/resources/schemas/fragment.xsd</xsd>
+
<packagename>org.apache.cxf.ws.transfer.dialect.fragment</packagename>
+
<catalog>${basedir}/src/main/resources/schemas/catalog-fragment.cat</catalog>
+ </xsdOption>
+ </xsdOptions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git
a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceFactoryTest.java
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceFactoryTest.java
index 01010894ee..ce69c61eee 100644
---
a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceFactoryTest.java
+++
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceFactoryTest.java
@@ -32,10 +32,15 @@ import org.apache.cxf.ws.transfer.Representation;
import org.apache.cxf.ws.transfer.manager.ResourceManager;
import org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory;
-import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
public class ResourceFactoryTest extends IntegrationBaseTest {
private static final String RESOURCE_UUID = "123456";
@@ -74,11 +79,9 @@ public class ResourceFactoryTest extends IntegrationBaseTest
{
@Test
public void createLocalResourceTest() {
ReferenceParametersType refParams = createReferenceParameters();
- ResourceManager manager = EasyMock.createMock(ResourceManager.class);
- EasyMock.expect(manager.create(EasyMock.isA(Representation.class)))
- .andReturn(refParams);
- EasyMock.expectLastCall().once();
- EasyMock.replay(manager);
+ ResourceManager manager = mock(ResourceManager.class);
+ when(manager.create(isA(Representation.class)))
+ .thenReturn(refParams);
Server localResourceFactory = createLocalResourceFactory(manager);
ResourceFactory client = createClient();
@@ -89,7 +92,7 @@ public class ResourceFactoryTest extends IntegrationBaseTest {
createRequest.setRepresentation(representation);
CreateResponse response = client.create(createRequest);
- EasyMock.verify(manager);
+ verify(manager, times(1)).create(isA(Representation.class));
Assert.assertEquals("ResourceAddress is other than expected.",
RESOURCE_ADDRESS,
response.getResourceCreated().getAddress().getValue());
@@ -106,11 +109,9 @@ public class ResourceFactoryTest extends
IntegrationBaseTest {
@Test
public void createRemoteResourceTest() {
ReferenceParametersType refParams = createReferenceParameters();
- ResourceManager manager = EasyMock.createMock(ResourceManager.class);
- EasyMock.expect(manager.create(EasyMock.isA(Representation.class)))
- .andReturn(refParams);
- EasyMock.expectLastCall().once();
- EasyMock.replay(manager);
+ ResourceManager manager = mock(ResourceManager.class);
+ when(manager.create(isA(Representation.class)))
+ .thenReturn(refParams);
Server remoteResourceFactory = createRemoteResourceFactory();
Server remoteResource = createRemoteResource(manager);
@@ -122,7 +123,7 @@ public class ResourceFactoryTest extends
IntegrationBaseTest {
createRequest.setRepresentation(representation);
CreateResponse response = client.create(createRequest);
- EasyMock.verify(manager);
+ verify(manager, times(1)).create(isA(Representation.class));
Assert.assertEquals("ResourceAddress is other than expected.",
RESOURCE_REMOTE_ADDRESS,
response.getResourceCreated().getAddress().getValue());
diff --git
a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceTest.java
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceTest.java
index 50db6d6354..449d7d014e 100644
---
a/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceTest.java
+++
b/rt/ws/transfer/src/test/java/org/apache/cxf/ws/transfer/integration/ResourceTest.java
@@ -40,10 +40,15 @@ import
org.apache.cxf.ws.transfer.manager.MemoryResourceManager;
import org.apache.cxf.ws.transfer.manager.ResourceManager;
import org.apache.cxf.ws.transfer.resource.Resource;
-import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
public class ResourceTest extends IntegrationBaseTest {
private static final String UUID_VALUE = "123456";
@@ -80,10 +85,8 @@ public class ResourceTest extends IntegrationBaseTest {
Representation representation = new Representation();
representation.setAny(representationEl);
- ResourceManager manager = EasyMock.createMock(ResourceManager.class);
-
EasyMock.expect(manager.get(EasyMock.isA(ReferenceParametersType.class))).andReturn(representation);
- EasyMock.expectLastCall().once();
- EasyMock.replay(manager);
+ ResourceManager manager = mock(ResourceManager.class);
+
when(manager.get(isA(ReferenceParametersType.class))).thenReturn(representation);
ReferenceParametersType refParams = new ReferenceParametersType();
Element uuid = DOMUtils.getEmptyDocument().createElementNS(
@@ -95,7 +98,7 @@ public class ResourceTest extends IntegrationBaseTest {
Resource client = createClient(refParams);
GetResponse response = client.get(new Get());
- EasyMock.verify(manager);
+ verify(manager, times(1)).get(isA(ReferenceParametersType.class));
representationEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("Namespace is other than expected.",
@@ -110,12 +113,8 @@ public class ResourceTest extends IntegrationBaseTest {
@Test
public void putRequestTest() {
- ResourceManager manager = EasyMock.createMock(ResourceManager.class);
-
EasyMock.expect(manager.get(EasyMock.isA(ReferenceParametersType.class))).andReturn(new
Representation());
- EasyMock.expectLastCall().once();
- manager.put(EasyMock.isA(ReferenceParametersType.class),
EasyMock.isA(Representation.class));
- EasyMock.expectLastCall().once();
- EasyMock.replay(manager);
+ ResourceManager manager = mock(ResourceManager.class);
+ when(manager.get(isA(ReferenceParametersType.class))).thenReturn(new
Representation());
ReferenceParametersType refParams = new ReferenceParametersType();
Element uuid = DOMUtils.getEmptyDocument().createElementNS(
@@ -136,7 +135,8 @@ public class ResourceTest extends IntegrationBaseTest {
putRequest.setRepresentation(representation);
PutResponse response = client.put(putRequest);
- EasyMock.verify(manager);
+ verify(manager, times(1)).get(isA(ReferenceParametersType.class));
+ verify(manager, times(1)).put(isA(ReferenceParametersType.class),
isA(Representation.class));
representationEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("Namespace is other than expected.",
@@ -151,10 +151,7 @@ public class ResourceTest extends IntegrationBaseTest {
@Test
public void deleteRequestTest() {
- ResourceManager manager = EasyMock.createMock(ResourceManager.class);
- manager.delete(EasyMock.isA(ReferenceParametersType.class));
- EasyMock.expectLastCall().once();
- EasyMock.replay(manager);
+ ResourceManager manager = mock(ResourceManager.class);
ReferenceParametersType refParams = new ReferenceParametersType();
Element uuid = DOMUtils.getEmptyDocument().createElementNS(
@@ -166,7 +163,7 @@ public class ResourceTest extends IntegrationBaseTest {
Resource client = createClient(refParams);
client.delete(new Delete());
- EasyMock.verify(manager);
+ verify(manager, times(1)).delete(isA(ReferenceParametersType.class));
server.destroy();
}