@Test
 public void simpleYangDataTest() {
   String jsonOutput;
   jsonOutput =
       TestUtils.convertCompositeNodeDataAndYangToJson(
           TestUtils.loadCompositeNode("/yang-to-json-conversion/simple-data-types/xml/data.xml"),
           "/yang-to-json-conversion/simple-data-types",
           "/yang-to-json-conversion/simple-data-types/xml");
   verifyJsonOutput(jsonOutput);
 }
예제 #2
0
 @Test
 public void testRc4WithEmptyData() throws IOException {
   Closer closer = Closer.create();
   try {
     // generate random input data
     byte[] randomData = TestUtils.randomBytes(0, true);
     InputStream randomInputStream = new ByteArrayInputStream(randomData);
     closer.register(randomInputStream);
     // generate cipher key
     byte[] keyBytes = Rc4Utils.generateKey();
     // encrypt and write
     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
     closer.register(byteArrayOutputStream);
     OutputStream encryptedOutputStream = Rc4Utils.encrypt(byteArrayOutputStream, keyBytes);
     closer.register(encryptedOutputStream);
     ByteStreams.copy(randomInputStream, encryptedOutputStream);
     byte[] encryptedBytes = byteArrayOutputStream.toByteArray();
     // read and decrypt
     InputStream encryptedInputStream = new ByteArrayInputStream(encryptedBytes);
     closer.register(encryptedInputStream);
     InputStream decryptedInputStream = Rc4Utils.decrypt(encryptedInputStream, keyBytes);
     closer.register(decryptedInputStream);
     byte[] decryptedData = ByteStreams.toByteArray(decryptedInputStream);
     // checking data
     Assert.assertArrayEquals(randomData, decryptedData);
     Assert.assertArrayEquals(Rc4Utils.encrypt(randomData, keyBytes), encryptedBytes);
     Assert.assertArrayEquals(Rc4Utils.decrypt(encryptedBytes, keyBytes), randomData);
   } catch (Throwable t) {
     closer.rethrow(t);
   } finally {
     closer.close();
   }
 }
 @BeforeClass
 public static void beforeClass() throws Exception, BrutException {
   sTmpDir = new ExtFile(OS.createTempDirectory());
   sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
   sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
   LOGGER.info("Unpacking testapp...");
   TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/testapp/", sTestOrigDir);
 }
예제 #4
0
  @BeforeClass
  public static void beforeClass() throws Exception, BrutException {
    sTmpDir = new ExtFile(OS.createTempDirectory());
    sTestOrigDir = new ExtFile(sTmpDir, "testapp-orig");
    sTestNewDir = new ExtFile(sTmpDir, "testapp-new");
    LOGGER.info("Unpacking testapp...");
    TestUtils.copyResourceDir(BuildAndDecodeTest.class, "brut/apktool/testapp/", sTestOrigDir);

    LOGGER.info("Building testapp.apk...");
    File testApk = new File(sTmpDir, "testapp.apk");
    new Androlib().build(sTestOrigDir, testApk);

    LOGGER.info("Decoding testapp.apk...");
    ApkDecoder apkDecoder = new ApkDecoder(testApk);
    apkDecoder.setOutDir(sTestNewDir);
    apkDecoder.decode();
  }