@Test(groups = {"functional.encode", "service.supplementary"}) public void testEncode() throws Exception { PasswordImpl pass = new PasswordImpl("0123"); GetPasswordResponseImpl impl = new GetPasswordResponseImpl(pass); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); }
@Test(groups = {"functional.decode", "service.supplementary"}) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.STRING_NUMERIC); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); GetPasswordResponseImpl impl = new GetPasswordResponseImpl(); impl.decodeAll(asn); assertEquals(impl.getPassword().getData(), "0123"); }