Sha256: d8232754f019a629ddd99f6b0cf6dc0eb71eef501d3e5dfd9d4009872d0c28d2

Contents?: true

Size: 1.47 KB

Versions: 61

Compression:

Stored size: 1.47 KB

Contents

import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class RandomKeyCipherTest {

    private Cipher cipher;

    @Before
    public void setup() {
        this.cipher = new Cipher();
    }


    @Test
    public void cipherKeyIsMadeOfLetters() {
        assertTrue(cipher.getKey().matches("[a-z]+"));
    }

    @Ignore
    @Test
    public void defaultCipherKeyIs100Characters() {
        assertEquals(100, cipher.getKey().length());
    }

    @Ignore
    @Test
    public void cipherKeysAreRandomlyGenerated() {
        assertTrue(!(new Cipher().getKey().equals(cipher.getKey())));
    }

    /**
     * Here we take advantage of the fact that plaintext of "aaa..." doesn't output the key. This is a critical problem
     * with shift ciphers, some characters will always output the key verbatim.
     */
    @Ignore
    @Test
    public void cipherCanEncode() {
        String expectedOutput = cipher.getKey().substring(0, 10);

        assertEquals(expectedOutput, cipher.encode("aaaaaaaaaa"));
    }

    @Ignore
    @Test
    public void cipherCanDecode() {
        String expectedOutput = "aaaaaaaaaa";

        assertEquals(expectedOutput, cipher.decode(cipher.getKey().substring(0, 10)));
    }

    @Ignore
    @Test
    public void cipherIsReversible() {
        String plainText = "abcdefghij";

        assertEquals(plainText, cipher.decode(cipher.encode(plainText)));
    }
}

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
trackler-2.0.6.5 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.6.4 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.6.3 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.6.2 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.6.1 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.6.0 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.18 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.17 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.16 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.15 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.14 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.13 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.12 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.11 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.10 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.9 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.8 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.7 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.6 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java
trackler-2.0.5.5 tracks/java/exercises/simple-cipher/src/test/java/RandomKeyCipherTest.java