Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXF-8848: Get rid of EasyMock in cxf-rt-databinding-jaxb #1379

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rt/databinding/jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${cxf.mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeResponse;

import org.easymock.IMocksControl;
import org.junit.Before;
import org.junit.Test;

import static org.easymock.EasyMock.createNiceControl;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class BareInInterceptorTest {

Expand All @@ -83,14 +82,13 @@ public void setUp() throws Exception {

BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

IMocksControl control = createNiceControl();
BindingFactory bf = control.createMock(BindingFactory.class);
Binding binding = control.createMock(Binding.class);
expect(bf.createBinding(null)).andStubReturn(binding);
expect(binding.getInFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
expect(binding.getOutFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
BindingFactory bf = mock(BindingFactory.class);
Binding binding = mock(Binding.class);
when(bf.createBinding(null)).thenReturn(binding);
when(binding.getInFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());
when(binding.getOutFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());

bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeResponse;

import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import static org.mockito.Mockito.mock;

public class BareOutInterceptorTest extends TestBase {

Expand All @@ -63,10 +61,8 @@ public void setUp() throws Exception {
writer = getXMLStreamWriter(baos);
message.setContent(XMLStreamWriter.class, writer);
message.getExchange().put(BindingOperationInfo.class, operation);
IMocksControl control = EasyMock.createNiceControl();
InterceptorChain ic = control.createMock(InterceptorChain.class);
InterceptorChain ic = mock(InterceptorChain.class);
message.setInterceptorChain(ic);
control.replay();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeResponse;

import org.easymock.IMocksControl;
import org.junit.Before;
import org.junit.Test;

import static org.easymock.EasyMock.createNiceControl;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class DocLiteralInInterceptorTest {
PhaseInterceptorChain chain;
Expand All @@ -80,14 +79,13 @@ public void setUp() throws Exception {

BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

IMocksControl control = createNiceControl();
BindingFactory bf = control.createMock(BindingFactory.class);
Binding binding = control.createMock(Binding.class);
expect(bf.createBinding(null)).andStubReturn(binding);
expect(binding.getInFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
expect(binding.getOutFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
BindingFactory bf = mock(BindingFactory.class);
Binding binding = mock(Binding.class);
when(bf.createBinding(null)).thenReturn(binding);
when(binding.getInFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());
when(binding.getOutFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());

bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeOneWay;

import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -81,6 +79,8 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class JAXBDataBindingTest {

Expand All @@ -89,7 +89,6 @@ public class JAXBDataBindingTest {
private Definition def;
private Service service;

private IMocksControl control;
private Bus bus;
private BindingFactoryManager bindingFactoryManager;
private JAXBDataBinding jaxbDataBinding;
Expand All @@ -106,16 +105,13 @@ public void setUp() throws Exception {
def = wsdlReader.readWSDL(wsdlUrl);


control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
bus = mock(Bus.class);
bindingFactoryManager = mock(BindingFactoryManager.class);
destinationFactoryManager = mock(DestinationFactoryManager.class);

EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class))
.andStubReturn(destinationFactoryManager);

control.replay();
when(bus.getExtension(BindingFactoryManager.class)).thenReturn(bindingFactoryManager);
when(bus.getExtension(DestinationFactoryManager.class))
.thenReturn(destinationFactoryManager);

WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
import org.apache.hello_world_soap_http.types.GreetMe;
import org.apache.hello_world_soap_http.types.GreetMeResponse;

import org.easymock.IMocksControl;
import org.junit.After;
import org.junit.Before;

import static org.easymock.EasyMock.createNiceControl;
import static org.easymock.EasyMock.expect;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class TestBase {

Expand All @@ -77,14 +76,13 @@ public void setUp() throws Exception {

BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);

IMocksControl control = createNiceControl();
BindingFactory bf = control.createMock(BindingFactory.class);
Binding binding = control.createMock(Binding.class);
expect(bf.createBinding(null)).andStubReturn(binding);
expect(binding.getInFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
expect(binding.getOutFaultInterceptors())
.andStubReturn(new ArrayList<Interceptor<? extends Message>>());
BindingFactory bf = mock(BindingFactory.class);
Binding binding = mock(Binding.class);
when(bf.createBinding(null)).thenReturn(binding);
when(binding.getInFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());
when(binding.getOutFaultInterceptors())
.thenReturn(new ArrayList<Interceptor<? extends Message>>());

bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);

Expand Down