Skip to content

Commit 93679b1

Browse files
committed
Rewrite PGPMarkerTest as SimpleTest
1 parent eca7566 commit 93679b1

File tree

1 file changed

+22
-44
lines changed

1 file changed

+22
-44
lines changed

pg/src/test/java/org/bouncycastle/openpgp/test/PGPMarkerTest.java

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
import org.bouncycastle.openpgp.PGPMarker;
55
import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
66
import org.bouncycastle.util.encoders.Base64;
7-
import org.bouncycastle.util.test.SimpleTestResult;
8-
import org.bouncycastle.util.test.Test;
9-
import org.bouncycastle.util.test.TestResult;
7+
import org.bouncycastle.util.test.SimpleTest;
108

119
public class PGPMarkerTest
12-
implements Test
10+
extends SimpleTest
1311
{
1412
private byte[] message1 = Base64.decode(
1513
"qANQR1DBwU4DdrlXatQSHgoQCADWlhY3bWWaOTm4t2espRWPFQmETeinnieHce64"
@@ -44,48 +42,31 @@ public class PGPMarkerTest
4442
+ "ZMyLFqGXiKlyVCPlUTN2uVisYQGr6iNGYSPxpKjwiAzdeeQBPOETG0vd3nTO"
4543
+ "MN4BMKcG+kRJd5FU72SRfmbGwPPjd1gts9xFvtj4Tvpkam8=");
4644

47-
public TestResult perform()
45+
@Override
46+
public void performTest()
47+
throws Exception
4848
{
49-
try
49+
50+
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(message1);
51+
52+
if (pgpFact.nextObject() instanceof PGPMarker)
53+
{
54+
isTrue(pgpFact.nextObject() instanceof PGPEncryptedDataList);
55+
}
56+
else
5057
{
51-
//
52-
// test encrypted message
53-
//
54-
JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(message1);
58+
fail("marker not found");
59+
}
5560

56-
Object o;
57-
58-
if (pgpFact.nextObject() instanceof PGPMarker)
59-
{
60-
if (pgpFact.nextObject() instanceof PGPEncryptedDataList)
61-
{
62-
return new SimpleTestResult(true, getName() + ": Okay");
63-
}
64-
else
65-
{
66-
return new SimpleTestResult(false, getName() + ": error processing after marker.");
67-
}
68-
}
69-
70-
pgpFact = new JcaPGPObjectFactory(message2);
61+
pgpFact = new JcaPGPObjectFactory(message2);
7162

72-
if (pgpFact.nextObject() instanceof PGPMarker)
73-
{
74-
if (pgpFact.nextObject() instanceof PGPEncryptedDataList)
75-
{
76-
return new SimpleTestResult(true, getName() + ": Okay");
77-
}
78-
else
79-
{
80-
return new SimpleTestResult(false, getName() + ": error processing after marker.");
81-
}
82-
}
83-
84-
return new SimpleTestResult(false, getName() + ": marker not found");
63+
if (pgpFact.nextObject() instanceof PGPMarker)
64+
{
65+
isTrue(pgpFact.nextObject() instanceof PGPEncryptedDataList);
8566
}
86-
catch (Exception e)
67+
else
8768
{
88-
return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
69+
fail("marker not found");
8970
}
9071
}
9172

@@ -97,9 +78,6 @@ public String getName()
9778
public static void main(
9879
String[] args)
9980
{
100-
Test test = new PGPMarkerTest();
101-
TestResult result = test.perform();
102-
103-
System.out.println(result.toString());
81+
runTest(new PGPMarkerTest());
10482
}
10583
}

0 commit comments

Comments
 (0)