forked from bcgit/bc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added back JVM version testing for prov and tls.
Commented print statements in mls tests.
- Loading branch information
Showing
14 changed files
with
545 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.bouncycastle.test; | ||
|
||
import junit.extensions.TestSetup; | ||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
|
||
import java.security.Security; | ||
|
||
public class AllTests | ||
extends TestCase | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
|
||
PrintTestResult.printResult(junit.textui.TestRunner.run(suite())); | ||
} | ||
|
||
public static Test suite() | ||
{ | ||
TestSuite suite = new TestSuite("JVM Version Tests"); | ||
suite.addTestSuite(JVMVersionTest.class); | ||
|
||
|
||
return new BCTestSetup(suite); | ||
} | ||
|
||
static class BCTestSetup | ||
extends TestSetup | ||
{ | ||
public BCTestSetup(Test test) | ||
{ | ||
super(test); | ||
} | ||
|
||
protected void setUp() | ||
{ | ||
Security.addProvider(new BouncyCastleProvider()); | ||
} | ||
|
||
protected void tearDown() | ||
{ | ||
Security.removeProvider("BC"); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
prov/src/test/java/org/bouncycastle/test/JVMVersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.bouncycastle.test; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.Test; | ||
|
||
|
||
/** | ||
* This test asserts the java version running the tests starts with | ||
* a property value passed in as part of test invocation. | ||
* | ||
* -Dtest.java.version.prefix must match the start of System.getProperty("java.version") | ||
* So: | ||
* if -Dtest.java.version.prefix=17 and System.getProperty("java.version") = 17.0.4.1 | ||
* Then this test will pass. | ||
*/ | ||
public class JVMVersionTest extends TestCase | ||
{ | ||
|
||
private static final String expectedVersionPropName = "test.java.version.prefix"; | ||
|
||
@Test | ||
public void testAssertExpectedJVM() { | ||
|
||
// | ||
// This project produces a multi-release jar, and we need to test it on different jvm versions | ||
// This test compares a property "test.java.version.prefix" with the start of the value reported by the JVM. | ||
// eg: | ||
// -Dtest.java.version.prefix=1.8 | ||
// | ||
// It exists because we have had issues with build systems unexpectedly using a different JVM to one we need to test on. | ||
// It is important for multi-release jars to be exercised on a representative JVM for each JVM they support. | ||
// | ||
// | ||
|
||
String version = System.getProperty("java.version"); | ||
assertNotNull(String.format("property %s is not set, see comment in test for reason why.",expectedVersionPropName),System.getProperty(expectedVersionPropName)); | ||
|
||
|
||
|
||
String expectedPrefix = System.getProperty(expectedVersionPropName); | ||
|
||
TestCase.assertTrue(String.format("JVM Version: '%s' did not start with '%s' see comment in test",version,expectedPrefix), version.startsWith(expectedPrefix)); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.bouncycastle.test; | ||
|
||
import junit.extensions.TestSetup; | ||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
|
||
import java.security.Security; | ||
|
||
public class AllTests | ||
extends TestCase | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
|
||
PrintTestResult.printResult(junit.textui.TestRunner.run(suite())); | ||
} | ||
|
||
public static Test suite() | ||
{ | ||
TestSuite suite = new TestSuite("JVM Version Tests"); | ||
suite.addTestSuite(JVMVersionTest.class); | ||
|
||
|
||
return new BCTestSetup(suite); | ||
} | ||
|
||
static class BCTestSetup | ||
extends TestSetup | ||
{ | ||
public BCTestSetup(Test test) | ||
{ | ||
super(test); | ||
} | ||
|
||
protected void setUp() | ||
{ | ||
Security.addProvider(new BouncyCastleProvider()); | ||
} | ||
|
||
protected void tearDown() | ||
{ | ||
Security.removeProvider("BC"); | ||
} | ||
} | ||
} |
Oops, something went wrong.