From ca0191d050b3dac6e65815ad5662ed8e796ef9d9 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Thu, 29 Oct 2020 12:44:07 +0100 Subject: fix for the Android Java SDK bug in getDeclaredFields nor providing the field order --- .../asn1/test/UperEncodeIntegerExtensionTest.java | 28 ++++++++-------------- 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java') diff --git a/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java b/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java index 5a33368..4c87bae 100644 --- a/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java +++ b/src/net/gcdc/asn1/test/UperEncodeIntegerExtensionTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import java.util.logging.Level; import net.gcdc.asn1.datatypes.Asn1BigInteger; +import net.gcdc.asn1.datatypes.FieldOrder; import net.gcdc.asn1.datatypes.HasExtensionMarker; import net.gcdc.asn1.datatypes.IsExtension; import net.gcdc.asn1.datatypes.Sequence; @@ -51,14 +52,17 @@ Encoded successfully in 21 bytes: @HasExtensionMarker public static class TestRecord { - + @FieldOrder(order = 0) Asn1BigInteger value1; + @FieldOrder(order = 2) + @IsExtension + Asn1BigInteger value3; + + @FieldOrder(order = 1) @IsExtension Asn1BigInteger value2; - @IsExtension - Asn1BigInteger value3; public TestRecord() { value1 = new Asn1BigInteger(12345678909999899L); @@ -74,26 +78,14 @@ Encoded successfully in 21 bytes: TestRecord record = new TestRecord(); byte[] encoded = UperEncoder.encode(record); - String hex = UperEncoder.hexStringFromBytes(encoded); - UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); - assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); - - - } - - @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { - - TestRecord record = new TestRecord(); - byte[] encoded = UperEncoder.encode(record); - String hex = UperEncoder.hexStringFromBytes(encoded); - UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); - assertEquals("8395EE2A2EF8858D81C1814052C8C338C0C09F4040",hex); - TestRecord result = UperEncoder.decode(encoded, TestRecord.class); assertEquals(result.value1.longValue(),record.value1.longValue()); assertEquals(result.value2.longValue(),record.value2.longValue()); assertEquals(result.value3.longValue(),record.value3.longValue()); + } + + } -- cgit v1.2.3