Replaced generic exceptions with custom exceptions
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestAutokey.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-26-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestAutokey{
|
||||
@Test
|
||||
public void testDecode() throws Exception{
|
||||
public void testDecode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -59,7 +61,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceDecode() throws Exception{
|
||||
public void testNoWhitespaceDecode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, false, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -106,7 +108,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws Exception{
|
||||
public void testNoCapitalDecode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -153,7 +155,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolDecode() throws Exception{
|
||||
public void testNoSymbolDecode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -200,7 +202,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws Exception{
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -249,7 +251,7 @@ public class TestAutokey{
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncode() throws Exception{
|
||||
public void testEncode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -296,7 +298,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws Exception{
|
||||
public void testNoWhitespaceEncode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, false, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -343,7 +345,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalEncode() throws Exception{
|
||||
public void testNoCapitalEncode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -390,7 +392,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws Exception{
|
||||
public void testNoSymbolEncode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -437,7 +439,7 @@ public class TestAutokey{
|
||||
assertEquals("Autokey failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws Exception{
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -486,7 +488,7 @@ public class TestAutokey{
|
||||
|
||||
|
||||
@Test
|
||||
public void testKeyword() throws Exception{
|
||||
public void testKeyword() throws InvalidKeywordException{
|
||||
Autokey cipher = new Autokey();
|
||||
|
||||
//Test keyword with whitespace
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java
|
||||
//Mattrixwv
|
||||
// Created: 01-08-22
|
||||
//Modified: 01-08-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidBaseException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -14,7 +15,7 @@ import org.junit.Test;
|
||||
|
||||
public class TestBaseX{
|
||||
@Test
|
||||
public void testBinaryDecode() throws InvalidCharacterException, Exception{
|
||||
public void testBinaryDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||
BaseX cipher = new BaseX();
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -47,7 +48,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed binary mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testOctalDecode() throws InvalidCharacterException, Exception{
|
||||
public void testOctalDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||
BaseX cipher = new BaseX(8);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -80,7 +81,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed octal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testDecimalDecode() throws InvalidCharacterException, Exception{
|
||||
public void testDecimalDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||
BaseX cipher = new BaseX(10);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -113,7 +114,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed decimal mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testHexDecode() throws InvalidCharacterException, Exception{
|
||||
public void testHexDecode() throws InvalidCharacterException, InvalidBaseException{
|
||||
BaseX cipher = new BaseX(16);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -146,7 +147,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed hex mixed case, whitespace, and symbol decoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testBinaryEncode() throws Exception{
|
||||
public void testBinaryEncode() throws InvalidBaseException{
|
||||
BaseX cipher = new BaseX();
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -179,7 +180,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed binary mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testOctalEncode() throws Exception{
|
||||
public void testOctalEncode() throws InvalidBaseException{
|
||||
BaseX cipher = new BaseX(8);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -212,7 +213,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed octal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testDecimalEncode() throws Exception{
|
||||
public void testDecimalEncode() throws InvalidBaseException{
|
||||
BaseX cipher = new BaseX(10);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -245,7 +246,7 @@ public class TestBaseX{
|
||||
assertEquals("Binary failed decimal mixed case, whitespace, and symbol encoding.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testHexEncode() throws Exception{
|
||||
public void testHexEncode() throws InvalidBaseException{
|
||||
BaseX cipher = new BaseX(16);
|
||||
|
||||
//Test lowercase encoding
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestVigenere.java
|
||||
//Matthew Ellison
|
||||
// Created: 07-25-21
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.monoSubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidKeywordException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestVigenere{
|
||||
@Test
|
||||
public void testDecode() throws Exception{
|
||||
public void testDecode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -59,7 +61,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceDecode() throws Exception{
|
||||
public void testNoWhitespaceDecode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, false, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -106,7 +108,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws Exception{
|
||||
public void testNoCapitalDecode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -153,7 +155,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolDecode() throws Exception{
|
||||
public void testNoSymbolDecode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -200,7 +202,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws Exception{
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -249,7 +251,7 @@ public class TestVigenere{
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncode() throws Exception{
|
||||
public void testEncode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -296,7 +298,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws Exception{
|
||||
public void testNoWhitespaceEncode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, false, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -343,7 +345,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalEncode() throws Exception{
|
||||
public void testNoCapitalEncode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(false, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -390,7 +392,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws Exception{
|
||||
public void testNoSymbolEncode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(true, true, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -437,7 +439,7 @@ public class TestVigenere{
|
||||
assertEquals("Vigenere failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws Exception{
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere(false, false, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -486,7 +488,7 @@ public class TestVigenere{
|
||||
|
||||
|
||||
@Test
|
||||
public void testKeyword() throws Exception{
|
||||
public void testKeyword() throws InvalidKeywordException{
|
||||
Vigenere cipher = new Vigenere();
|
||||
|
||||
//Test keyword with whitespace
|
||||
|
||||
@@ -8,13 +8,14 @@ package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestPlayfair{
|
||||
@Test
|
||||
public void testDecode() throws InvalidCharacterException, Exception{
|
||||
public void testDecode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -64,7 +65,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceDecode() throws InvalidCharacterException, Exception{
|
||||
public void testNoWhitespaceDecode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, false, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -114,7 +115,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws InvalidCharacterException, Exception{
|
||||
public void testNoCapitalDecode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(false, true, true);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -164,7 +165,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no capital mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolDecode() throws InvalidCharacterException, Exception{
|
||||
public void testNoSymbolDecode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -214,7 +215,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, Exception{
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(false, false, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
@@ -264,7 +265,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed secure mixed case, whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testEncode() throws InvalidCharacterException, Exception{
|
||||
public void testEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -314,7 +315,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, false, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -364,7 +365,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no whitespace mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(false, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -414,7 +415,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no capital mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(true, true, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
@@ -464,7 +465,7 @@ public class TestPlayfair{
|
||||
assertEquals("Playfair failed no symbol mixed case, whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
Playfair cipher = new Playfair(false, false, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestPolybiusSquare.java
|
||||
//Mattrixwv
|
||||
// Created: 01-04-22
|
||||
//Modified: 01-04-22
|
||||
//Modified: 01-09-22
|
||||
package com.mattrixwv.CipherStreamJava.polySubstitution;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.CipherStreamJava.exceptions.InvalidInputException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -166,7 +167,7 @@ public class TestPolybiusSquare{
|
||||
assertEquals("PolybiusSquare failed secure whitespace, symbol decoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testEncode() throws InvalidCharacterException, Exception{
|
||||
public void testEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
PolybiusSquare cipher = new PolybiusSquare(true, true);
|
||||
|
||||
//Test simple encoding
|
||||
@@ -204,7 +205,7 @@ public class TestPolybiusSquare{
|
||||
assertEquals("PolybiusSquare failed whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
PolybiusSquare cipher = new PolybiusSquare(false, true);
|
||||
|
||||
//Test simple encoding
|
||||
@@ -242,7 +243,7 @@ public class TestPolybiusSquare{
|
||||
assertEquals("PolybiusSquare failed no whitespace whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
PolybiusSquare cipher = new PolybiusSquare(true, false);
|
||||
|
||||
//Test simple encoding
|
||||
@@ -280,7 +281,7 @@ public class TestPolybiusSquare{
|
||||
assertEquals("PolybiusSquare failed no symbol whitespace, symbol encoding with mangled keyword.", correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceSymbolEncode() throws InvalidCharacterException, Exception{
|
||||
public void testNoWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidInputException{
|
||||
PolybiusSquare cipher = new PolybiusSquare(false, false);
|
||||
|
||||
//Test simple encoding
|
||||
|
||||
Reference in New Issue
Block a user