forked from I2P_Developers/i2p.i2p
Tests: Add mockito classpath to core tests
javadocs for new test classes
This commit is contained in:
@ -119,8 +119,8 @@ require.gettext=true
|
||||
# Defaults to the ant library path if not set
|
||||
# If set, this must point to a directory containing the files
|
||||
# mockito-core.jar, byte-buddy.jar, objenesis.jar
|
||||
# Tested using Mockito 2.5.0 which requires byte-buddy 1.5.12 and objenesis 2.4
|
||||
#mockito.home=
|
||||
# Tested using Mockito 2.23.0 which requires byte-buddy 1.8.2 and objenesis 3.1
|
||||
#mockito.home=/usr/share/java
|
||||
|
||||
# Optional properties used in tests to enable additional tools.
|
||||
#with.cobertura=/PATH/TO/cobertura.jar
|
||||
|
@ -286,6 +286,7 @@
|
||||
</classpath>
|
||||
</scalac>
|
||||
</target>
|
||||
|
||||
<target name="junit.compileTest" depends="compile">
|
||||
<mkdir dir="./build" />
|
||||
<mkdir dir="./build/obj" />
|
||||
@ -293,10 +294,13 @@
|
||||
<echo message="[DEBUG] ant home is ${ant.home}" />
|
||||
<echo message="[DEBUG] junit home before override is ${junit.home}" />
|
||||
<echo message="[DEBUG] hamcrest home before override is ${hamcrest.home}" />
|
||||
<echo message="[DEBUG] mockito home before override is ${mockito.home}" />
|
||||
<property name="hamcrest.home" value="${ant.home}/lib/" />
|
||||
<property name="junit.home" value="${ant.home}/lib/" />
|
||||
<property name="mockito.home" value="${ant.home}/lib" />
|
||||
<echo message="[DEBUG] junit home after override is ${junit.home}" />
|
||||
<echo message="[DEBUG] hamcrest home after override is ${hamcrest.home}" />
|
||||
<echo message="[DEBUG] mockito home after override is ${mockito.home}" />
|
||||
<javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
|
||||
release="${javac.release}"
|
||||
debuglevel="lines,vars,source"
|
||||
@ -310,11 +314,15 @@
|
||||
<pathelement location="${hamcrest.home}/hamcrest-library.jar" />
|
||||
<pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
|
||||
<pathelement location="${hamcrest.home}/hamcrest-all.jar" />
|
||||
<pathelement location="${mockito.home}/byte-buddy.jar" />
|
||||
<pathelement location="${mockito.home}/objenesis.jar" />
|
||||
<pathelement location="${mockito.home}/mockito-core.jar" />
|
||||
<pathelement location="${junit.home}/junit4.jar" />
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- jars with tests -->
|
||||
<target name="jarScalaTest" depends="scalatest.compileTest">
|
||||
<mkdir dir="./build/obj_scala_jar" />
|
||||
@ -443,6 +451,7 @@
|
||||
<fileset dir="../../reports/core/scalatest/" />
|
||||
</replaceregexp>
|
||||
</target>
|
||||
|
||||
<target name="junit.test" depends="clean, junit.compileTest, prepareTest">
|
||||
<property name="hamcrest.home" value="${ant.home}/lib/" />
|
||||
<property name="junit.home" value="${ant.home}/lib/" />
|
||||
@ -461,6 +470,9 @@
|
||||
<pathelement location="${hamcrest.home}/hamcrest-library.jar" />
|
||||
<pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
|
||||
<pathelement location="${hamcrest.home}/hamcrest-all.jar" />
|
||||
<pathelement location="${mockito.home}/byte-buddy.jar" />
|
||||
<pathelement location="${mockito.home}/objenesis.jar" />
|
||||
<pathelement location="${mockito.home}/mockito-core.jar" />
|
||||
<pathelement location="${junit.home}/junit4.jar" />
|
||||
<pathelement location="./build/obj_cobertura" />
|
||||
<pathelement location="./build/obj" />
|
||||
@ -492,6 +504,7 @@
|
||||
<fileset dir="../../reports/core/junit/" />
|
||||
</replaceregexp>
|
||||
</target>
|
||||
|
||||
<target name="test" depends="junit.test, scalatest.test"/>
|
||||
<!-- test reports -->
|
||||
<target name="scalatest.report">
|
||||
|
@ -1,5 +1,8 @@
|
||||
package net.i2p;
|
||||
|
||||
/**
|
||||
* @since 0.9.49
|
||||
*/
|
||||
public class TestContext extends I2PAppContext {
|
||||
|
||||
public TestContext() {
|
||||
@ -7,7 +10,7 @@ public class TestContext extends I2PAppContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding the existing I2PAppContext with a test context who's fields we may mock as we like
|
||||
* Allows overriding the existing I2PAppContext with a test context whose fields we may mock as we like
|
||||
*
|
||||
* @param ctx Our test context to replace the global context with
|
||||
*/
|
||||
|
@ -15,7 +15,10 @@ import org.mockito.MockitoAnnotations;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ConvertToHashMockTest{
|
||||
/**
|
||||
* @since 0.9.49
|
||||
*/
|
||||
public class ConvertToHashMockTest {
|
||||
|
||||
@Mock private NamingService namingService;
|
||||
@Mock private Destination destination;
|
||||
@ -34,7 +37,7 @@ public class ConvertToHashMockTest{
|
||||
* We would otherwise pollute the other tests that depend on I2PAppContext
|
||||
*/
|
||||
@AfterClass
|
||||
public static void afterClass(){
|
||||
public static void afterClass() {
|
||||
TestContext.setGlobalContext(null);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,9 @@ import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @since 0.9.49
|
||||
*/
|
||||
public class ConvertToHashTest {
|
||||
private static final String zzzDotI2pBase32Hash = "lhbd7ojcaiofbfku7ixh47qj537g572zmhdc4oilvugzxdpdghua";
|
||||
private static final String zzzDotI2pBase64Hash = "WcI~uSICHFCVVPoufn4J7v5u~1lhxi45C60Nm43jMeg=";
|
||||
|
Reference in New Issue
Block a user