public class JU_CertMarshal {
- private static final String fingerprint = "fingerprint";
- private static final String id = "id";
- private static final String x500 = "x500";
-
- private String fingerprintAsString;
-
- private XMLGregorianCalendar expires;
-
- private ByteArrayOutputStream outStream;
-
- @Before
- public void setup() {
- expires = Chrono.timeStamp();
- outStream = new ByteArrayOutputStream();
- StringBuilder sb = new StringBuilder();
- DataWriter.HEX_BINARY.write(fingerprint.getBytes(), sb);
- fingerprintAsString = sb.toString();
- }
-
- @Test
- public void test() throws ParseException, IOException {
- Cert cert = setupCert();
- CertMarshal cm = new CertMarshal();
- OutRaw raw = new OutRaw();
-
- raw.extract(cert, new PrintStream(outStream), cm);
-
- String[] output = outStream.toString().split("\n");
-
- String[] expected = new String[] {
- "{ - ",
- ", - fingerprint : \"" + fingerprintAsString + "\"",
- ", - id : \"" + id + "\"",
- ", - x500 : \"" + x500 + "\"",
- ", - expires : \"" + Chrono.dateTime(expires) + "\"",
- "} - ",
- };
-
- assertThat(output.length, is(expected.length));
-
- for (int i = 0; i < output.length; i++) {
- assertThat(output[i], is(expected[i]));
- }
- }
-
- private Cert setupCert() {
- Cert cert = new Cert();
- cert.setId(id);
- cert.setX500(x500);
- cert.setExpires(expires);
- cert.setFingerprint(fingerprint.getBytes());
- return cert;
- }
+ private static final String fingerprint = "fingerprint";
+ private static final String id = "id";
+ private static final String x500 = "x500";
+
+ private String fingerprintAsString;
+
+ private XMLGregorianCalendar expires;
+
+ private ByteArrayOutputStream outStream;
+
+ @Before
+ public void setup() {
+ expires = Chrono.timeStamp();
+ outStream = new ByteArrayOutputStream();
+ StringBuilder sb = new StringBuilder();
+ DataWriter.HEX_BINARY.write(fingerprint.getBytes(), sb);
+ fingerprintAsString = sb.toString();
+ }
+
+ @Test
+ public void test() throws ParseException, IOException {
+ Cert cert = setupCert();
+ CertMarshal cm = new CertMarshal();
+ OutRaw raw = new OutRaw();
+
+ raw.extract(cert, new PrintStream(outStream), cm);
+
+ String[] output = outStream.toString().split("\n");
+
+ String[] expected = new String[] {
+ "{ - ",
+ ", - fingerprint : \"" + fingerprintAsString + "\"",
+ ", - id : \"" + id + "\"",
+ ", - x500 : \"" + x500 + "\"",
+ ", - expires : \"" + Chrono.dateTime(expires) + "\"",
+ "} - ",
+ };
+
+ assertThat(output.length, is(expected.length));
+
+ for (int i = 0; i < output.length; i++) {
+ assertThat(output[i], is(expected[i]));
+ }
+ }
+
+ private Cert setupCert() {
+ Cert cert = new Cert();
+ cert.setId(id);
+ cert.setX500(x500);
+ cert.setExpires(expires);
+ cert.setFingerprint(fingerprint.getBytes());
+ return cert;
+ }
}