samples/preventcyclicdependencies/src-test/org/apidesign/cycles/array/test/Main.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 21:30:10 +0100
changeset 409 40cabcdcd2be
permissions -rw-r--r--
Updating to NBMs from NetBeans 8.0.1 as some of them are required to run on JDK8
jtulach@87
     1
package org.apidesign.cycles.array.test;
jtulach@87
     2
jtulach@87
     3
import org.apidesign.cycles.array.*;
jtulach@87
     4
import java.io.ByteArrayOutputStream;
jtulach@87
     5
import java.io.IOException;
jtulach@87
     6
import java.io.OutputStream;
jtulach@87
     7
import org.apidesign.cycles.crypt.Encryptor;
jtulach@87
     8
jtulach@87
     9
public class Main {
jtulach@87
    10
    public static void main(String[] args) throws Exception {
jtulach@87
    11
        byte[] five = { 1, 2, 3, 4, 5 };
jtulach@87
    12
        MutableArray arr = new MutableArray(five);
jtulach@87
    13
        
jtulach@87
    14
        ByteArrayOutputStream os = new ByteArrayOutputStream();
jtulach@87
    15
        arr.encrypt(os);
jtulach@87
    16
        
jtulach@87
    17
        byte[] out = os.toByteArray();
jtulach@87
    18
        assert out.length == 5;
jtulach@87
    19
        
jtulach@87
    20
        for (int i = 0; i < 5; i++) {
jtulach@87
    21
            int exp = five[i] ^ 0x3d;
jtulach@87
    22
            if (exp != out[i]) {
jtulach@87
    23
                assert false : "Index: " + i + " exp: " + exp + " was: " + out[i];
jtulach@87
    24
            }
jtulach@87
    25
        }
jtulach@87
    26
        System.err.println("OK");
jtulach@87
    27
    }
jtulach@87
    28
}
jtulach@87
    29