use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding5.
@Test
public void implicitEncoding5() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(128));
int length = testInteger.encode(berBAOStream, false);
assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, 0x00, (byte) 0x80 };
assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method explicitEncoding2.
@Test
public void explicitEncoding2() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
BerInteger testInteger = new BerInteger(BigInteger.valueOf(5555));
int length = testInteger.encode(berStream, true);
assertEquals(4, length);
byte[] expectedBytes = new byte[] { 0x02, 0x02, 0x15, (byte) 0xb3 };
assertArrayEquals(expectedBytes, berStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerGeneralizedTimeTest method explicitEncoding.
@Test
public void explicitEncoding() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
byte[] byteArray = new byte[] { 0x01, 0x02, 0x03 };
BerGeneralizedTime berGeneralizedTime = new BerGeneralizedTime(byteArray);
int length = berGeneralizedTime.encode(berStream, true);
assertEquals(5, length);
byte[] expectedBytes = new byte[] { 24, 0x03, 0x01, 0x02, 0x03 };
assertArrayEquals(expectedBytes, berStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerReal method encodeAndSave.
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(os, false);
code = os.getArray();
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerRealTest method coding1dot5.
@Test
public void coding1dot5() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
BerReal berReal = new BerReal(1.5);
berReal.encode(berStream, true);
// System.out.println(DatatypeConverter.printHexBinary(berStream.getArray()));
assertArrayEquals(HexString.toBytes("090380FF03"), berStream.getArray());
ByteArrayInputStream berInputStream = new ByteArrayInputStream(berStream.getArray());
BerReal berRealDecoded = new BerReal();
berRealDecoded.decode(berInputStream, true);
assertEquals(1.5, berRealDecoded.value, 0.01);
}
Aggregations