/** Tests {@link ContentInfo#isExtended()} and {@link ContentInfo#extend(CertToken)} methods. */ public void testExtend() throws Asn1FormatException, IOException { InputStream in = new ByteArrayInputStream(CONTENT_INFO); ContentInfo contentInfo = ContentInfo.getInstance(in); // Make sure created content info is NOT extended assertFalse(contentInfo.isExtended()); // Make sure illegal arguments are handled correctly try { contentInfo.extend(null); fail("null accepted as cert token"); } catch (IllegalArgumentException e) { Log.debug("[DBG] (OK) " + e.getMessage()); } // Create extended content info in = new ByteArrayInputStream(CERT_TOKEN); CertToken certToken = CertToken.getInstance(in); ContentInfo extendedContentInfo = contentInfo.extend(certToken); // Make sure created content info is extended; // also make sure initial content info is NOT extended assertFalse(contentInfo.isExtended()); assertTrue(extendedContentInfo.isExtended()); }