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