Search in sources :

Example 6 with InvalidAsn1DataException

use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.

the class Asn1NodeTest method testAsBytes_ConstructedTag.

@SmallTest
@Test(expected = IllegalStateException.class)
public void testAsBytes_ConstructedTag() throws InvalidAsn1DataException {
    Asn1Node node = Asn1Node.newBuilder(0xBF37).build();
    node.asBytes();
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 7 with InvalidAsn1DataException

use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.

the class Asn1NodeTest method testAsLong_ConstructedTag.

@SmallTest
@Test(expected = IllegalStateException.class)
public void testAsLong_ConstructedTag() throws InvalidAsn1DataException {
    Asn1Node node = Asn1Node.newBuilder(0xBF37).build();
    node.asRawLong();
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 8 with InvalidAsn1DataException

use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.

the class Asn1NodeTest method testAsString_ConstructedTag.

@SmallTest
@Test(expected = IllegalStateException.class)
public void testAsString_ConstructedTag() throws InvalidAsn1DataException {
    Asn1Node node = Asn1Node.newBuilder(0xBF37).build();
    node.asString();
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 9 with InvalidAsn1DataException

use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.

the class Asn1NodeTest method testWriteToBytes.

@SmallTest
@Test
public void testWriteToBytes() throws InvalidAsn1DataException {
    final String nodeHex = "3031110312D687120F54686973206973206120746573742E310B13040422C4F0" + "1403FF00FF1501FF13040422C4F01403FF00FF";
    Asn1Node node = new Asn1Decoder(nodeHex).nextNode();
    // Writes the bytes before children accessed.
    assertEquals(nodeHex, node.toHex());
    // Writes the bytes after children accessed.
    node.getChildren();
    assertEquals(nodeHex, node.toHex());
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) Asn1Decoder(com.android.internal.telephony.uicc.asn1.Asn1Decoder) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 10 with InvalidAsn1DataException

use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.

the class Asn1NodeTest method testNonExitingChildren.

@SmallTest
@Test
public void testNonExitingChildren() throws TagNotFoundException, InvalidAsn1DataException {
    Asn1Node node = Asn1Node.newBuilder(0x3F34).addChild(Asn1Node.newBuilder(0x34)).addChild(Asn1Node.newBuilder(0x35).addChild(Asn1Node.newBuilder(0x36))).addChildAsInteger(0x11, 123).build();
    assertEquals(0, node.getChild(0x34).getChildren(0x37).size());
    assertEquals(0, node.getChildren(0x37).size());
    assertEquals(0, node.getChild(0x11).getChildren(0x37).size());
    assertEquals(0, node.getChild(0x11).getChildren().size());
    try {
        node.getChild(0x35).getChild(0x37);
        fail("0x37 should not exist.");
    } catch (TagNotFoundException e) {
        assertEquals(0x37, e.getTag());
    }
    try {
        node.getChild(0x35, 0x37);
        fail("0x37 should not exist.");
    } catch (TagNotFoundException e) {
        assertEquals(0x37, e.getTag());
    }
    try {
        node.getChild(0x11).getChild(0x37);
        fail("0x37 should not exist.");
    } catch (TagNotFoundException e) {
        assertEquals(0x37, e.getTag());
    }
}
Also used : Asn1Node(com.android.internal.telephony.uicc.asn1.Asn1Node) TagNotFoundException(com.android.internal.telephony.uicc.asn1.TagNotFoundException) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

Asn1Node (com.android.internal.telephony.uicc.asn1.Asn1Node)23 Test (org.junit.Test)21 SmallTest (android.test.suitebuilder.annotation.SmallTest)20 Asn1Decoder (com.android.internal.telephony.uicc.asn1.Asn1Decoder)8 InvalidAsn1DataException (com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException)3 TagNotFoundException (com.android.internal.telephony.uicc.asn1.TagNotFoundException)2 Nullable (android.annotation.Nullable)1 UiccAccessRule (android.telephony.UiccAccessRule)1 TelephonyTest (com.android.internal.telephony.TelephonyTest)1