Examples of NullCipher


Examples of javax.crypto.NullCipher

    // Regression test for HARMONY-6347
    public void testGetObject4() throws Exception {
        try {
            new SealedObject("secret string",
                             new NullCipher()).getObject((Key)null);
            fail("NullPointerException should be thrown when key is null");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

Examples of javax.crypto.NullCipher

     * (related to the InputStream) and that it returns -1 at the end of stream.
     */
    public void testRead1() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        byte res;
        for (int i = 0; i < data.length; i++) {
            if ((res = (byte) cis.read()) != data[i]) {
                fail("read() returned the incorrect value. " + "Expected: "
                        + data[i] + ", Got: " + res + ".");
View Full Code Here

Examples of javax.crypto.NullCipher

     * stream.
     */
    public void testRead2() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());

        int expected = data.length;
        byte[] result = new byte[expected];

        int ind = 0; // index into the data array (to check the got data)
View Full Code Here

Examples of javax.crypto.NullCipher

     * stream.
     */
    public void testRead3() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());

        int expected = data.length;
        byte[] result = new byte[expected];

        int skip = 2;
View Full Code Here

Examples of javax.crypto.NullCipher

     * bytes.
     */
    public void testSkip() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        int expected = data.length;
        byte[] result = new byte[expected];

        int skipped = (int) cis.skip(2);
        int ind = skipped;
View Full Code Here

Examples of javax.crypto.NullCipher

     * available() method testing. Tests that the method always return 0.
     */
    public void testAvailable() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        assertEquals("The returned by available() method value "
                + "should be 0.", cis.available(), 0);
    }
View Full Code Here

Examples of javax.crypto.NullCipher

     * method of the underlying input stream.
     */
    public void testClose() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        cis.close();
        assertTrue("The close() method should call the close() method "
                + "of its underlying input stream.", tis.wasClosed());
    }
View Full Code Here

Examples of javax.crypto.NullCipher

     * markSupported() method testing. Tests that mark is not supported.
     */
    public void testMarkSupported() {
        byte[] data = new byte[] {-127, -100, -50, -10, -1, 0, 1, 10, 50, 127};
        TestInputStream tis = new TestInputStream(data);
        CipherInputStream cis = new CipherInputStream(tis, new NullCipher());
        assertFalse("The returned by markSupported() method value "
                + "should be false.", cis.markSupported());
    }
View Full Code Here

Examples of javax.crypto.NullCipher

     * the underlying output stream.
     */
    public void testWrite1() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestOutputStream tos = new TestOutputStream();
        CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher());
        for (int i = 0; i < data.length; i++) {
            cos.write(data[i]);
        }
        cos.flush();
        byte[] result = tos.toByteArray();
View Full Code Here

Examples of javax.crypto.NullCipher

     * to the underlying output stream.
     */
    public void testWrite2() throws Exception {
        byte[] data = new byte[] { -127, -100, -50, -10, -1, 0, 1, 10, 50, 127 };
        TestOutputStream tos = new TestOutputStream();
        CipherOutputStream cos = new CipherOutputStream(tos, new NullCipher());
        cos.write(data);
        cos.flush();
        byte[] result = tos.toByteArray();
        if (!Arrays.equals(result, data)) {
            fail("CipherOutputStream wrote incorrect data.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.