Search in sources :

Example 21 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class BerObjectIdentifierTest method explicitEncoding.

@Test
public void explicitEncoding() throws IOException {
    ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
    BerObjectIdentifier oi = new BerObjectIdentifier(objectIdentifierComponents);
    int length = oi.encode(berBAOStream, true);
    assertEquals(7, length);
    assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
Also used : ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 22 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class BerRealTest method coding2dot0.

@Test
public void coding2dot0() throws IOException {
    final BerReal orig = new BerReal(2.0);
    final ReverseByteArrayOutputStream baos = new ReverseByteArrayOutputStream(100, true);
    orig.encode(baos, true);
    final BerReal decoded = new BerReal();
    decoded.decode(new ByteArrayInputStream(baos.getArray()), true);
    assertEquals(orig.value, decoded.value, 0.001);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 23 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class BerRealTest method coding1dot0.

@Test
public void coding1dot0() throws IOException {
    final BerReal orig = new BerReal(1.0);
    final ReverseByteArrayOutputStream baos = new ReverseByteArrayOutputStream(100, true);
    orig.encode(baos, true);
    final BerReal decoded = new BerReal();
    decoded.decode(new ByteArrayInputStream(baos.getArray()), true);
    assertEquals(orig.value, decoded.value, 0.001);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 24 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class BerRealTest method coding0dot2.

@Test
public void coding0dot2() throws IOException {
    final BerReal orig = new BerReal(0.2);
    final ReverseByteArrayOutputStream baos = new ReverseByteArrayOutputStream(100, true);
    orig.encode(baos, true);
    final BerReal decoded = new BerReal();
    decoded.decode(new ByteArrayInputStream(baos.getArray()), true);
    assertEquals(orig.value, decoded.value, 0.001);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 25 with ReverseByteArrayOutputStream

use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.

the class MobileTest method decodeEncodeTest.

@Test
public void decodeEncodeTest() throws Exception {
    String expected = "A1 820237 A0 05 80 00 81 01 01 A1 82022C 30 820228 62 10 82 02 7821 83 02 3F00 8B 01 0E C6 03 01020A 62 11 82 02 4121 83 02 2F05 8B 01 0F 80 01 03 88 01 28 62 0E 82 02 4121 83 02 2FE2 8B 01 0B 80 01 0A 81 0A 98109909002143658739 62 14 82 04 4221002683 02 2F00 8B 01 0A 80 02 0098 88 01 F0 81 1A 61184F10A0000000871002FF33FF01890000010050045553494D 62 11 82 04 42210025 83 02 2F06 8B 01 0A 80 02 01EF 81 1B 8001019000800102A406830101950108800158A40683010A950108 02 01 0A 81 16 800101A40683010195010880015AA40683010A950108 02 01 0F 81 0B 80015BA40683010A950108 02 01 1A 81 0A 800101900080015A9700 02 01 1B 81 16 800103A406830101950108800158A40683010A950108 02 01 0F 81 16 800111A40683010195010880014AA40683010A950108 02 01 0F 81 21 800103A406830101950108800158A40683010A950108840132A406830101950108 02 01 04 81 21 800101A406830101950108800102A406830181950108800158A40683010A950108 02 01 04 81 1B 800101900080011AA406830101950108800140A40683010A950108 02 01 0A 81 10 800101900080015AA40683010A950108 02 01 15 81 15 8001019000800118A40683010A9501088001429700 02 01 0E 81 10 800101A40683010195010880015A9700 02 01 15 81 16 800113A406830101950108800148A40683010A950108 02 01 0D 81 0B 80015EA40683010A950108 02 01 1A81 25 8001019000800102A010A406830101950108A406830102950108800158A40683010A950108 62 0E 82 02 4121 83 02 2F08 8B 01 0A 80 01 05".replaceAll("\\s", "");
    byte[] code = HexString.toBytes(expected);
    ProfileElement rereadProfileElement = new ProfileElement();
    rereadProfileElement.decode(new ByteArrayInputStream(code), null);
    ReverseByteArrayOutputStream reverseOutputStream2 = new ReverseByteArrayOutputStream(2048, true);
    rereadProfileElement.encode(reverseOutputStream2);
    byte[] code2 = reverseOutputStream2.getArray();
    assertArrayEquals(code, code2);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BerUTF8String(com.beanit.asn1bean.ber.types.string.BerUTF8String) BerOctetString(com.beanit.asn1bean.ber.types.BerOctetString) HexString(com.beanit.asn1bean.util.HexString) ProfileElement(com.beanit.asn1bean.compiler.pedefinitions.ProfileElement) ReverseByteArrayOutputStream(com.beanit.asn1bean.ber.ReverseByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Aggregations

ReverseByteArrayOutputStream (com.beanit.asn1bean.ber.ReverseByteArrayOutputStream)51 Test (org.junit.jupiter.api.Test)41 ByteArrayInputStream (java.io.ByteArrayInputStream)25 BerInteger (com.beanit.asn1bean.ber.types.BerInteger)14 BerVisibleString (com.beanit.asn1bean.ber.types.string.BerVisibleString)5 HexString (com.beanit.asn1bean.util.HexString)5 BerOctetString (com.beanit.asn1bean.ber.types.BerOctetString)4 BerUTF8String (com.beanit.asn1bean.ber.types.string.BerUTF8String)4 ProfileElement (com.beanit.asn1bean.compiler.pedefinitions.ProfileElement)4 BerAny (com.beanit.asn1bean.ber.types.BerAny)3 BerBoolean (com.beanit.asn1bean.ber.types.BerBoolean)3 BerNull (com.beanit.asn1bean.ber.types.BerNull)3 ImplicitlyRetaggedTaggedChoice (com.beanit.asn1bean.compiler.tagging_test.ImplicitlyRetaggedTaggedChoice)3 NonExtensibleSequence (com.beanit.asn1bean.compiler.extension_test.non_extensible.NonExtensibleSequence)2 PEHeader (com.beanit.asn1bean.compiler.pedefinitions.PEHeader)2 UInt15 (com.beanit.asn1bean.compiler.pedefinitions.UInt15)2 ArrayList (java.util.ArrayList)2 BerEmbeddedPdv (com.beanit.asn1bean.ber.types.BerEmbeddedPdv)1 BerObjectIdentifier (com.beanit.asn1bean.ber.types.BerObjectIdentifier)1 ExtensibleAccessSequence (com.beanit.asn1bean.compiler.extension_test.extensible_with_access.ExtensibleAccessSequence)1