Skip to content

Commit 74cd823

Browse files
committed
added cobertura to gradle build
organised AllTests classes to be properly picked up.
1 parent e9ec8b2 commit 74cd823

36 files changed

Lines changed: 1024 additions & 167 deletions

File tree

build.gradle

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
8+
dependencies {
9+
classpath "net.saliman:gradle-cobertura-plugin:2.2.8"
10+
}
11+
}
12+
113
allprojects {
2-
apply plugin: 'idea'
14+
apply plugin: 'java'
15+
apply plugin: 'idea'
16+
apply plugin: 'eclipse'
17+
apply plugin: 'net.saliman.cobertura'
18+
19+
repositories {
20+
mavenCentral()
21+
}
22+
23+
dependencies {
24+
testCompile group: 'junit', name: 'junit', version: '4.11'
25+
// Cobertura declares a dependency on the slf4j API, so we need to supply
26+
// a runtime implementation to avoid NoClassDefFoundErrors
27+
testRuntime "org.slf4j:slf4j-log4j12:1.7.5"
28+
testRuntime "log4j:log4j:1.2.17"
29+
}
330
}
431

532
ext {
@@ -11,16 +38,6 @@ task printProperties << {
1138
}
1239

1340
subprojects {
14-
apply plugin: 'eclipse'
15-
apply plugin: 'java'
16-
17-
repositories {
18-
mavenCentral()
19-
}
20-
21-
dependencies {
22-
testCompile group: 'junit', name: 'junit', version: '4.11'
23-
}
2441

2542
sourceCompatibility = 1.5
2643
targetCompatibility = 1.5
@@ -34,3 +51,33 @@ subprojects {
3451
}
3552
}
3653
}
54+
55+
test.dependsOn([':core:test', ':prov:test', ':pkix:test', ':mail:test', 'pg:test'])
56+
57+
cobertura {
58+
coverageDirs = [
59+
"${rootProject.projectDir}/core/build/classes/main",
60+
"${rootProject.projectDir}/mail/build/classes/main",
61+
"${rootProject.projectDir}/pg/build/classes/main",
62+
"${rootProject.projectDir}/pkix/build/classes/main",
63+
"${rootProject.projectDir}/prov/build/classes/main"
64+
]
65+
coverageSourceDirs = [
66+
"${rootProject.projectDir}/core/src/main/java",
67+
"${rootProject.projectDir}/mail/src/main/java",
68+
"${rootProject.projectDir}/pg/src/main/java",
69+
"${rootProject.projectDir}/pkix/src/main/java",
70+
"${rootProject.projectDir}/prov/src/main/java",
71+
]
72+
coverageMergeDatafiles = [
73+
file("${rootProject.projectDir}/core/build/cobertura/cobertura.ser"),
74+
file("${rootProject.projectDir}/mail/build/cobertura/cobertura.ser"),
75+
file("${rootProject.projectDir}/pg/build/cobertura/cobertura.ser"),
76+
file("${rootProject.projectDir}/pkix/build/cobertura/cobertura.ser"),
77+
file("${rootProject.projectDir}/prov/build/cobertura/cobertura.ser"),
78+
]
79+
auxiliaryClasspath += files("${rootProject.projectDir}/core/build/classes/main")
80+
coverageFormats = ['html', 'xml']
81+
coverageReportDir = new File("${rootProject.projectDir}/build/reports/cobertura")
82+
}
83+

core/src/test/java/org/bouncycastle/asn1/test/AllTests.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.asn1.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
@@ -38,6 +39,25 @@ public static Test suite()
3839
suite.addTestSuite(OctetStringTest.class);
3940
suite.addTestSuite(ParseTest.class);
4041

41-
return suite;
42+
return new BCTestSetup(suite);
43+
}
44+
45+
static class BCTestSetup
46+
extends TestSetup
47+
{
48+
public BCTestSetup(Test test)
49+
{
50+
super(test);
51+
}
52+
53+
protected void setUp()
54+
{
55+
56+
}
57+
58+
protected void tearDown()
59+
{
60+
61+
}
4262
}
4363
}

core/src/test/java/org/bouncycastle/crypto/agreement/test/AllTests.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.crypto.agreement.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
@@ -20,6 +21,25 @@ public static Test suite()
2021
suite.addTestSuite(JPAKEPrimeOrderGroupTest.class);
2122
suite.addTestSuite(JPAKEUtilTest.class);
2223

23-
return suite;
24+
return new BCTestSetup(suite);
25+
}
26+
27+
static class BCTestSetup
28+
extends TestSetup
29+
{
30+
public BCTestSetup(Test test)
31+
{
32+
super(test);
33+
}
34+
35+
protected void setUp()
36+
{
37+
38+
}
39+
40+
protected void tearDown()
41+
{
42+
43+
}
2444
}
2545
}

core/src/test/java/org/bouncycastle/crypto/ec/test/AllTests.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.crypto.ec.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
@@ -34,6 +35,26 @@ public static Test suite()
3435

3536
suite.addTestSuite(AllTests.class);
3637

37-
return suite;
38+
return new BCTestSetup(suite);
3839
}
40+
41+
static class BCTestSetup
42+
extends TestSetup
43+
{
44+
public BCTestSetup(Test test)
45+
{
46+
super(test);
47+
}
48+
49+
protected void setUp()
50+
{
51+
52+
}
53+
54+
protected void tearDown()
55+
{
56+
57+
}
58+
}
59+
3960
}

core/src/test/java/org/bouncycastle/crypto/prng/test/AllTests.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.crypto.prng.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
@@ -34,6 +35,25 @@ public static Test suite()
3435

3536
suite.addTestSuite(AllTests.class);
3637

37-
return suite;
38+
return new BCTestSetup(suite);
39+
}
40+
41+
static class BCTestSetup
42+
extends TestSetup
43+
{
44+
public BCTestSetup(Test test)
45+
{
46+
super(test);
47+
}
48+
49+
protected void setUp()
50+
{
51+
52+
}
53+
54+
protected void tearDown()
55+
{
56+
57+
}
3858
}
3959
}
Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
11
package org.bouncycastle.crypto.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
45
import junit.framework.TestCase;
56
import junit.framework.TestSuite;
6-
77
import org.bouncycastle.util.test.SimpleTestResult;
88

99
public class AllTests
1010
extends TestCase
11-
{
12-
public void testCrypto()
13-
{
14-
org.bouncycastle.util.test.Test[] tests = RegressionTest.tests;
15-
16-
for (int i = 0; i != tests.length; i++)
17-
{
18-
SimpleTestResult result = (SimpleTestResult)tests[i].perform();
19-
20-
if (!result.isSuccessful())
21-
{
22-
fail(result.toString());
23-
}
24-
}
25-
}
26-
11+
{
2712
public static void main (String[] args)
2813
{
2914
junit.textui.TestRunner.run(suite());
@@ -33,9 +18,51 @@ public static Test suite()
3318
{
3419
TestSuite suite = new TestSuite("Lightweight Crypto Tests");
3520

36-
suite.addTestSuite(AllTests.class);
21+
suite.addTestSuite(SimpleTestTest.class);
3722
suite.addTestSuite(GCMReorderTest.class);
3823

39-
return suite;
24+
return new BCTestSetup(suite);
25+
}
26+
27+
public static class SimpleTestTest
28+
extends TestCase
29+
{
30+
public void testCrypto()
31+
{
32+
org.bouncycastle.util.test.Test[] tests = RegressionTest.tests;
33+
34+
for (int i = 0; i != tests.length; i++)
35+
{
36+
SimpleTestResult result = (SimpleTestResult)tests[i].perform();
37+
38+
if (!result.isSuccessful())
39+
{
40+
if (result.getException() != null)
41+
{
42+
result.getException().printStackTrace();
43+
}
44+
fail(result.toString());
45+
}
46+
}
47+
}
48+
}
49+
50+
static class BCTestSetup
51+
extends TestSetup
52+
{
53+
public BCTestSetup(Test test)
54+
{
55+
super(test);
56+
}
57+
58+
protected void setUp()
59+
{
60+
61+
}
62+
63+
protected void tearDown()
64+
{
65+
66+
}
4067
}
4168
}

core/src/test/java/org/bouncycastle/crypto/tls/test/AllTests.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package org.bouncycastle.crypto.tls.test;
22

3+
import junit.extensions.TestSetup;
34
import junit.framework.Test;
5+
import junit.framework.TestCase;
46
import junit.framework.TestSuite;
57

68
public class AllTests
9+
extends TestCase
710
{
811
public static void main(String[] args)
912
throws Exception
@@ -16,8 +19,33 @@ public static Test suite()
1619
{
1720
TestSuite suite = new TestSuite("TLS tests");
1821

19-
suite.addTest(BasicTlsTest.suite());
22+
suite.addTestSuite(BasicTlsTest.class);
23+
suite.addTestSuite(DTLSProtocolTest.class);
24+
suite.addTestSuite(DTLSTestCase.class);
25+
suite.addTestSuite(TlsProtocolTest.class);
26+
suite.addTestSuite(TlsPSKProtocolTest.class);
27+
suite.addTestSuite(TlsSRPProtocolTest.class);
28+
suite.addTestSuite(TlsTestCase.class);
2029

21-
return suite;
30+
return new BCTestSetup(suite);
31+
}
32+
33+
static class BCTestSetup
34+
extends TestSetup
35+
{
36+
public BCTestSetup(Test test)
37+
{
38+
super(test);
39+
}
40+
41+
protected void setUp()
42+
{
43+
44+
}
45+
46+
protected void tearDown()
47+
{
48+
49+
}
2250
}
2351
}

core/src/test/java/org/bouncycastle/i18n/test/AllTests.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
package org.bouncycastle.i18n.test;
33

4-
import org.bouncycastle.i18n.filter.test.HTMLFilterTest;
5-
import org.bouncycastle.i18n.filter.test.SQLFilterTest;
6-
4+
import junit.extensions.TestSetup;
75
import junit.framework.Test;
86
import junit.framework.TestCase;
97
import junit.framework.TestSuite;
8+
import org.bouncycastle.i18n.filter.test.HTMLFilterTest;
9+
import org.bouncycastle.i18n.filter.test.SQLFilterTest;
1010

1111
public class AllTests extends TestCase
1212
{
@@ -22,7 +22,25 @@ public static Test suite()
2222
suite.addTestSuite(LocalizedMessageTest.class);
2323
suite.addTestSuite(HTMLFilterTest.class);
2424
suite.addTestSuite(SQLFilterTest.class);
25-
return suite;
25+
return new BCTestSetup(suite);
2626
}
2727

28+
static class BCTestSetup
29+
extends TestSetup
30+
{
31+
public BCTestSetup(Test test)
32+
{
33+
super(test);
34+
}
35+
36+
protected void setUp()
37+
{
38+
39+
}
40+
41+
protected void tearDown()
42+
{
43+
44+
}
45+
}
2846
}

0 commit comments

Comments
 (0)