Skip to content

Commits on Source 7

......@@ -45,7 +45,7 @@ It is a basic compilation of the application.
### Full build
This build will check code coverage using Jacoco, run findbugs and
This build will check code coverage using Jacoco, run spotbugs and
validate that the license headers are correctly set.
`mvn install -PfullBuild`
......@@ -94,7 +94,7 @@ Configure to deploy to the Sonatype maven repository
http://www.sonatype.com/people/2010/01/how-to-generate-pgp-signatures-with-maven/
To build the maven site (with findbugs, checkstyle, jdepends and JavaNCSS reports)
To build the maven site (with spotbugs, checkstyle, jdepends and JavaNCSS reports)
--------------------------------------------------------------------------------------
- You will to give enough memory to maven with 'set MAVEN_OPTS=-Xmx512m' (or setting it as environment variable)
- Then type `mvn site`
......
This release add support for Java 9 and Java 10 and fixes an issue for interface default methods.
Release notes
-------------
* Java 10 support through an update of ASM and cglib
* Add Java 9 automodule
* Allow to mock interface default methods on a partial mock
This is a patch release with sole purpose to move ASM and CGLIB to their final version with full
Java 11 support.
Change log
----------
* Add Java 9 automodule ([#212](https://github.com/easymock/easymock/issues/212))
* Update asm, cglib and surefire for Java 10 support ([#211](https://github.com/easymock/easymock/pull/211))
* Mocking interface default methods ([#203](https://github.com/easymock/easymock/issues/203))
* Upgrade to cglib 3.2.9 to support Java 11 ([#234](https://github.com/easymock/easymock/issues/234))
* Upgrade TestNG to version 7 ([#233](https://github.com/easymock/easymock/issues/233))
* Update to ASM 7.0 for full Java 11 support ([#232](https://github.com/easymock/easymock/pull/232))
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.easymock</groupId>
<artifactId>easymock-parent</artifactId>
<version>3.6</version>
<version>4.0.1</version>
</parent>
<artifactId>easymock-bench</artifactId>
......@@ -17,8 +17,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.19</jmh.version>
<javac.target>1.6</javac.target>
<jmh.version>1.21</jmh.version>
<uberjar.name>benchmarks</uberjar.name>
</properties>
......@@ -102,7 +101,25 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
/**
/*
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
......@@ -7,7 +7,7 @@
<parent>
<groupId>org.easymock</groupId>
<artifactId>easymock-parent</artifactId>
<version>3.6</version>
<version>4.0.1</version>
</parent>
<artifactId>easymock</artifactId>
......@@ -35,7 +35,7 @@
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.6</version>
<version>3.2.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.ant</groupId>
......@@ -43,18 +43,18 @@
</exclusion>
</exclusions>
</dependency>
<!-- Use version 6.1 to be compliant with Java 10 -->
<!-- Use version 7.0 to be compliant with Java 11 -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version>
<version>7.0</version>
<scope>runtime</scope>
</dependency>
<!-- Used for class mocking -->
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.6</version>
<version>3.0.1</version>
</dependency>
<!-- Used for class mocking on Android (cglib replacement) -->
<dependency>
......@@ -163,13 +163,13 @@
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.1</version>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
<executions>
<execution>
<id>source-java6-check</id>
<id>source-java8-check</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
......@@ -185,8 +185,8 @@
<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -32,17 +32,14 @@ public class Capture<T> implements Serializable {
private static final long serialVersionUID = -4214363692271370781L;
private CaptureType type;
private final CaptureType type;
private final List<T> values = new ArrayList<T>(2);
private final List<T> values = new ArrayList<>(2);
/**
* Default constructor. Only the last element will be captured
*
* @deprecated Use {@link EasyMock#newCapture()} instead
*/
@Deprecated
public Capture() {
private Capture() {
this(CaptureType.LAST);
}
......@@ -51,10 +48,8 @@ public class Capture<T> implements Serializable {
*
* @param type
* capture type
* @deprecated Use {@link org.easymock.EasyMock#newCapture(CaptureType)} instead
*/
@Deprecated
public Capture(CaptureType type) {
private Capture(CaptureType type) {
this.type = type;
}
......@@ -65,7 +60,7 @@ public class Capture<T> implements Serializable {
* @return the new capture object
*/
public static <T> Capture<T> newInstance() {
return new Capture<T>();
return new Capture<>();
}
/**
......@@ -76,7 +71,7 @@ public class Capture<T> implements Serializable {
* @return the new capture object
*/
public static <T> Capture<T> newInstance(CaptureType type) {
return new Capture<T>(type);
return new Capture<>(type);
}
/**
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -55,7 +55,7 @@ import java.util.List;
public class EasyMockSupport {
/** List of all controls created */
protected final List<IMocksControl> controls = new ArrayList<IMocksControl>(5);
protected final List<IMocksControl> controls = new ArrayList<>(5);
/**
* Creates a mock object that implements the given interface, order checking
......@@ -63,6 +63,9 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
......@@ -70,7 +73,7 @@ public class EasyMockSupport {
*
* @since ${project.version}
*/
public <T> T mock(Class<T> toMock) {
public <T, R> R mock(Class<T> toMock) {
return createControl().createMock(toMock);
}
......@@ -86,13 +89,16 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since ${project.version}
*/
public <T> T mock(String name, Class<T> toMock) {
public <T, R> R mock(String name, Class<T> toMock) {
return createControl().createMock(name, toMock);
}
......@@ -107,13 +113,16 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since ${project.version}
*/
public <T> T mock(MockType type, Class<T> toMock) {
public <T, R> R mock(MockType type, Class<T> toMock) {
return createControl(type).createMock(toMock);
}
......@@ -130,13 +139,16 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since ${project.version}
*/
public <T> T mock(String name, MockType type, Class<T> toMock) {
public <T, R> R mock(String name, MockType type, Class<T> toMock) {
return createControl(type).createMock(name, toMock);
}
......@@ -146,6 +158,9 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
......@@ -153,7 +168,7 @@ public class EasyMockSupport {
*
* @since ${project.version}
*/
public <T> T strictMock(Class<T> toMock) {
public <T, R> R strictMock(Class<T> toMock) {
return createStrictControl().createMock(toMock);
}
......@@ -168,13 +183,16 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since ${project.version}
*/
public <T> T strictMock(String name, Class<T> toMock) {
public <T, R> R strictMock(String name, Class<T> toMock) {
return createStrictControl().createMock(name, toMock);
}
......@@ -185,6 +203,9 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
......@@ -192,7 +213,7 @@ public class EasyMockSupport {
*
* @since ${project.version}
*/
public <T> T niceMock(Class<T> toMock) {
public <T, R> R niceMock(Class<T> toMock) {
return createNiceControl().createMock(toMock);
}
......@@ -209,13 +230,16 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*
* @since ${project.version}
*/
public <T> T niceMock(String name, Class<T> toMock) {
public <T, R> R niceMock(String name, Class<T> toMock) {
return createNiceControl().createMock(name, toMock);
}
......@@ -233,7 +257,7 @@ public class EasyMockSupport {
* @since ${project.version}
*/
public <T> IMockBuilder<T> partialMockBuilder(Class<T> toMock) {
return new MockBuilder<T>(toMock, this);
return new MockBuilder<>(toMock, this);
}
/**
......@@ -247,11 +271,14 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
public <T> T createMock(MockType type, Class<T> toMock) {
public <T, R> R createMock(MockType type, Class<T> toMock) {
return mock(type, toMock);
}
......@@ -268,11 +295,14 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
public <T> T createMock(String name, MockType type, Class<T> toMock) {
public <T, R> R createMock(String name, MockType type, Class<T> toMock) {
return mock(name, type, toMock);
}
......@@ -282,12 +312,15 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
* @return the mock object.
*/
public <T> T createStrictMock(Class<T> toMock) {
public <T, R> R createStrictMock(Class<T> toMock) {
return strictMock(toMock);
}
......@@ -302,11 +335,14 @@ public class EasyMockSupport {
* implement.
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
public <T> T createStrictMock(String name, Class<T> toMock) {
public <T, R> R createStrictMock(String name, Class<T> toMock) {
return strictMock(name, toMock);
}
......@@ -316,12 +352,15 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
* @return the mock object.
*/
public <T> T createMock(Class<T> toMock) {
public <T, R> R createMock(Class<T> toMock) {
return mock(toMock);
}
......@@ -334,14 +373,16 @@ public class EasyMockSupport {
* @param toMock
* the class of the interface that the mock object should
* implement.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param <T>
* the interface that the mock object should implement.
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
public <T> T createMock(String name, Class<T> toMock) {
public <T, R> R createMock(String name, Class<T> toMock) {
return mock(name, toMock);
}
......@@ -352,12 +393,15 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the class of the interface that the mock object should
* implement.
* @return the mock object.
*/
public <T> T createNiceMock(Class<T> toMock) {
public <T, R> R createNiceMock(Class<T> toMock) {
return niceMock(toMock);
}
......@@ -374,11 +418,14 @@ public class EasyMockSupport {
*
* @param <T>
* the interface that the mock object should implement.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
public <T> T createNiceMock(String name, Class<T> toMock) {
public <T, R> R createNiceMock(String name, Class<T> toMock) {
return niceMock(name, toMock);
}
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -239,50 +239,68 @@ public interface IMockBuilder<T> {
* Create mock of the request type from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param type the mock type
* @return the newly created mock
* @since 3.2
*/
T createMock(MockType type);
<R> R createMock(MockType type);
/**
* Create a strict mock from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
*/
T createStrictMock();
<R> R createStrictMock();
/**
* Create a default mock from this builder. The same builder can be called
* to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
*/
T createMock();
<R> R createMock();
/**
* Create a nice mock from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
*/
T createNiceMock();
<R> R createNiceMock();
/**
* Create mock from the provided mock control using the arguments passed to
* the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param control
* {@link org.easymock.IMocksControl} used to create the object
* @return the newly created mock
*/
T createMock(IMocksControl control);
<R> R createMock(IMocksControl control);
/**
* Create a named mock of the request type from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @param type
......@@ -290,47 +308,216 @@ public interface IMockBuilder<T> {
* @return the newly created mock
* @since 3.2
*/
T createMock(String name, MockType type);
<R> R createMock(String name, MockType type);
/**
* Create a named strict mock from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
*/
<R> R createStrictMock(String name);
/**
* Create named mock from the provided mock control using the arguments
* passed to the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
*/
<R> R createMock(String name);
/**
* Create a named nice mock from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
*/
<R> R createNiceMock(String name);
/**
* Create named mock from the provided mock control using the arguments
* passed to the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @param control
* {@link org.easymock.IMocksControl} used to create the object
* @return the newly created mock
*/
<R> R createMock(String name, IMocksControl control);
/**
* Create mock of the request type from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param type the mock type
* @return the newly created mock
* @since 4.0
*/
default <R> R mock(MockType type) {
return createMock(type);
}
/**
* Create a strict mock from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
* @since 4.0
*/
default <R> R strictMock() {
return createStrictMock();
}
/**
* Create a default mock from this builder. The same builder can be called
* to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
* @since 4.0
*/
default <R> R mock() {
return createMock();
}
/**
* Create a nice mock from this builder. The same builder can be called to
* create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @return the newly created mock
* @since 4.0
*/
default <R> R niceMock() {
return createNiceMock();
}
/**
* Create mock from the provided mock control using the arguments passed to
* the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param control
* {@link org.easymock.IMocksControl} used to create the object
* @return the newly created mock
* @since 4.0
*/
default <R> R mock(IMocksControl control) {
return createMock(control);
}
/**
* Create a named mock of the request type from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @param type
* the mock type
* @return the newly created mock
* @since 4.0
*/
default <R> R mock(String name, MockType type) {
return createMock(name, type);
}
/**
* Create a named strict mock from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
* @since 4.0
*/
T createStrictMock(String name);
default <R> R strictMock(String name) {
return createStrictMock(name);
}
/**
* Create named mock from the provided mock control using the arguments
* passed to the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
* @since 4.0
*/
T createMock(String name);
default <R> R mock(String name) {
return createMock(name);
}
/**
* Create a named nice mock from this builder. The same builder can be
* called to create multiple mocks.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @return the newly created mock
* @since 4.0
*/
T createNiceMock(String name);
default <R> R niceMock(String name) {
return createNiceMock(name);
}
/**
* Create named mock from the provided mock control using the arguments
* passed to the builder.
*
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the mock name
* @param control
* {@link org.easymock.IMocksControl} used to create the object
* @return the newly created mock
* @since 4.0
*/
T createMock(String name, IMocksControl control);
default <R> R mock(String name, IMocksControl control) {
return createMock(name, control);
}
}
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -31,12 +31,18 @@ public interface IMocksControl {
* @param <T>
* the interface or class that the mock object should
* implement/extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the interface or class that the mock object should
* implement/extend.
* @return the mock object.
* @since 4.0
*/
<T> T createMock(Class<T> toMock);
default <T, R> R mock(Class<T> toMock) {
return createMock(toMock);
}
/**
* Creates a mock object that implements the given interface.
......@@ -44,6 +50,9 @@ public interface IMocksControl {
* @param <T>
* the interface or class that the mock object should
* implement/extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the name of the mock object.
* @param toMock
......@@ -52,8 +61,11 @@ public interface IMocksControl {
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
* @since 4.0
*/
<T> T createMock(String name, Class<T> toMock);
default <T, R> R mock(String name, Class<T> toMock) {
return createMock(name, toMock);
}
/**
* Creates a mock object that implements the given class. Using this method directly in a test class
......@@ -62,6 +74,69 @@ public interface IMocksControl {
*
* @param <T>
* the class that the mock object should extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the name of the mock object.
* @param toMock
* the class that the mock object should extend.
* @param constructorArgs
* constructor and parameters used to instantiate the mock. If null, no constructor will be called
* @param mockedMethods
* methods that will be mocked, other methods will behave
* normally. If empty, all methods will be mocked
* @return the mock object.
* @since 4.0
*/
default <T, R> R mock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods) {
return createMock(name, toMock, constructorArgs, mockedMethods);
}
/**
* Same as {@link #mock(Class)} but using the old naming.
*
* @param <T>
* the interface or class that the mock object should
* implement/extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param toMock
* the interface or class that the mock object should
* implement/extend.
* @return the mock object.
*/
<T, R> R createMock(Class<T> toMock);
/**
* Same as {@link #mock(String, Class)} but using the old naming.
*
* @param <T>
* the interface or class that the mock object should
* implement/extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the name of the mock object.
* @param toMock
* the interface or class that the mock object should
* implement/extend.
* @return the mock object.
* @throws IllegalArgumentException
* if the name is not a valid Java identifier.
*/
<T, R> R createMock(String name, Class<T> toMock);
/**
* Same as {@link #mock(String, Class, ConstructorArgs, Method...)} but using the old naming
*
* @param <T>
* the class that the mock object should extend.
* @param <R>
* the returned type. In general T == R but when mocking a generic type, it won't so to be nice with the
* caller, we return a different type
* @param name
* the name of the mock object.
* @param toMock
......@@ -73,7 +148,7 @@ public interface IMocksControl {
* normally. If empty, all methods will be mocked
* @return the mock object.
*/
<T> T createMock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods);
<T, R> R createMock(String name, Class<T> toMock, ConstructorArgs constructorArgs, Method... mockedMethods);
/**
* Removes all expectations for the mock objects of this control.
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -52,9 +52,9 @@ public enum LogicalOperator {
}
};
private String symbol;
private final String symbol;
private LogicalOperator(String symbol) {
LogicalOperator(String symbol) {
this.symbol = symbol;
}
......
/**
/*
* Copyright 2001-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
......