@Test public void testInsertApplicationAttribute() throws IOException { InputStream testStream = this.getClass().getClassLoader().getResourceAsStream(issue8); underTest.read(testStream); Attribute attribute = new Attribute("android", "name", "test", AttributeType.STRING, null, underTest.getStringSection()); underTest.injectApplicationAttribute(attribute); StartTag startTag = underTest.getApplicationTag(); assertTrue(startTag.getAttributes().contains(attribute)); }
@Test public void testInsertApplicationAttribute() throws IOException { InputStream testStream = this.getClass().getClassLoader().getResourceAsStream(largeFromMalware); underTest.read(testStream); Attribute attribute = new Attribute("android", "name", "test", AttributeType.STRING, null, underTest.getStringSection()); underTest.injectApplicationAttribute(attribute); StartTag startTag = underTest.getApplicationTag(); assertTrue(startTag.getAttributes().contains(attribute)); }
@Test public void testWriteInsertedApplicationAttribute() throws IOException { InputStream testStream = this.getClass().getClassLoader().getResourceAsStream(largeFromMalware); underTest.read(testStream); Attribute attribute = new Attribute("android", "name", "test", AttributeType.STRING, null, underTest.getStringSection()); underTest.injectApplicationAttribute(attribute); File file = File.createTempFile("axml-func-test", "xml-test"); file.deleteOnExit(); underTest.write(new FileOutputStream(file)); underTest = new AXMLResource(new FileInputStream(file)); StartTag startTag = underTest.getApplicationTag(); assertEquals(underTest.getStringSection().getString(startTag.getAttributes().get(3).getNameIndex()), "name"); assertEquals(underTest.getStringSection().getString(startTag.getAttributes().get(3).getStringDataIndex()), "test"); } }
@Test public void testWriteInsertedApplicationAttribute() throws IOException { InputStream testStream = this.getClass().getClassLoader().getResourceAsStream(issue8); underTest.read(testStream); Attribute attribute = new Attribute("android", "name", "test", AttributeType.STRING, null, underTest.getStringSection()); underTest.injectApplicationAttribute(attribute); File file = File.createTempFile("axml-func-test", "xml-test"); file.deleteOnExit(); underTest.write(new FileOutputStream(file)); underTest = new AXMLResource(new FileInputStream(file)); StartTag startTag = underTest.getApplicationTag(); assertEquals(underTest.getStringSection().getString(startTag.getAttributes().get(3).getNameIndex()), "name"); assertEquals(underTest.getStringSection().getString(startTag.getAttributes().get(3).getStringDataIndex()), "test"); } }