Skip to content

Commit 8ce0891

Browse files
committed
minor reorg of test classes - relates to github #1634
1 parent 7d3efae commit 8ce0891

File tree

4 files changed

+46
-37
lines changed

4 files changed

+46
-37
lines changed

ant/bc+-build.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,10 @@
860860
<copyStandardFiles toDir="${pg.target.dir}" />
861861

862862
<copy todir="${pg.target.src.dir}" filtering="true">
863-
<fileset dir="${src.dir}" includes="org/bouncycastle/bcpg/**/*.java" />
863+
<fileset dir="${src.dir}">
864+
<include name="org/bouncycastle/bcpg/**/*.java" />
865+
<exclude name="org/bouncycastle/**/test/**/*.java" />
866+
</fileset>
864867
</copy>
865868

866869
<copy todir="${pg.target.src.dir}">

pg/src/test/java/org/bouncycastle/bcpg/test/AbstractPacketTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.bouncycastle.bcpg.test;
22

33
import org.bouncycastle.bcpg.ContainedPacket;
4-
import org.bouncycastle.bcpg.HexDumpUtil;
4+
import org.bouncycastle.test.DumpUtil;
55
import org.bouncycastle.util.Arrays;
66
import org.bouncycastle.util.test.SimpleTest;
77

@@ -36,8 +36,8 @@ public void isEncodingEqual(String message, byte[] first, byte[] second)
3636
{
3737
sb.append(message).append("\n");
3838
}
39-
sb.append("Expected: \n").append(HexDumpUtil.hexdump(first)).append("\n");
40-
sb.append("Got: \n").append(HexDumpUtil.hexdump(second));
39+
sb.append("Expected: \n").append(DumpUtil.hexdump(first)).append("\n");
40+
sb.append("Got: \n").append(DumpUtil.hexdump(second));
4141

4242
isTrue(sb.toString(), first == second || Arrays.areEqual(first, second));
4343
}
@@ -69,8 +69,8 @@ public void isEncodingEqual(String message, ContainedPacket first, ContainedPack
6969
{
7070
sb.append(message).append("\n");
7171
}
72-
sb.append("Expected: \n").append(HexDumpUtil.hexdump(first)).append("\n");
73-
sb.append("Got: \n").append(HexDumpUtil.hexdump(second));
72+
sb.append("Expected: \n").append(PacketDumpUtil.hexdump(first)).append("\n");
73+
sb.append("Got: \n").append(PacketDumpUtil.hexdump(second));
7474
isTrue(sb.toString(), first == second || Arrays.areEqual(first.getEncoded(), second.getEncoded()));
7575
}
7676

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.bouncycastle.bcpg.test;
2+
3+
import java.io.IOException;
4+
5+
import org.bouncycastle.bcpg.ContainedPacket;
6+
import org.bouncycastle.test.DumpUtil;
7+
8+
public class PacketDumpUtil
9+
{
10+
/**
11+
* Return a formatted hex dump of the packet encoding of the given packet.
12+
* @param packet packet
13+
* @return formatted hex dump
14+
* @throws IOException if an exception happens during packet encoding
15+
*/
16+
public static String hexdump(ContainedPacket packet)
17+
throws IOException
18+
{
19+
return DumpUtil.hexdump(packet.getEncoded());
20+
}
21+
22+
/**
23+
* Return a formatted hex dump of the packet encoding of the given packet.
24+
* If startIndent is non-zero, the hex dump is shifted right by the startIndent octets.
25+
* @param startIndent shift the encodings octet stream by a number of bytes
26+
* @param packet packet
27+
* @return formatted hex dump
28+
* @throws IOException if an exception happens during packet encoding
29+
*/
30+
public static String hexdump(int startIndent, ContainedPacket packet)
31+
throws IOException
32+
{
33+
return DumpUtil.hexdump(startIndent, packet.getEncoded());
34+
}
35+
}

pg/src/test/java/org/bouncycastle/bcpg/HexDumpUtil.java renamed to pg/src/test/java/org/bouncycastle/test/DumpUtil.java

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

33
import org.bouncycastle.util.encoders.Hex;
44

5-
import java.io.IOException;
6-
7-
public class HexDumpUtil
5+
public class DumpUtil
86
{
9-
107
/**
118
* Return a formatted hex dump of the given byte array.
129
* @param array byte array
@@ -65,30 +62,4 @@ public static String hexdump(int startIndent, byte[] array)
6562
}
6663
return out.toString();
6764
}
68-
69-
/**
70-
* Return a formatted hex dump of the packet encoding of the given packet.
71-
* @param packet packet
72-
* @return formatted hex dump
73-
* @throws IOException if an exception happens during packet encoding
74-
*/
75-
public static String hexdump(ContainedPacket packet)
76-
throws IOException
77-
{
78-
return hexdump(packet.getEncoded());
79-
}
80-
81-
/**
82-
* Return a formatted hex dump of the packet encoding of the given packet.
83-
* If startIndent is non-zero, the hex dump is shifted right by the startIndent octets.
84-
* @param startIndent shift the encodings octet stream by a number of bytes
85-
* @param packet packet
86-
* @return formatted hex dump
87-
* @throws IOException if an exception happens during packet encoding
88-
*/
89-
public static String hexdump(int startIndent, ContainedPacket packet)
90-
throws IOException
91-
{
92-
return hexdump(startIndent, packet.getEncoded());
93-
}
9465
}

0 commit comments

Comments
 (0)