I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Verified Commit 5e588639 authored by zzz's avatar zzz
Browse files

Tests: Add mockito classpath to core tests

javadocs for new test classes
parent 4776080c
No related branches found
No related tags found
No related merge requests found
......@@ -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">
......
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=";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment