Update error messages and test names

This commit is contained in:
2024-04-19 22:36:52 -04:00
parent 434260969c
commit 0b1d5a3d91
46 changed files with 395 additions and 520 deletions

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGVX.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/combination/ADFGVX.java
//Mattrixwv //Mattrixwv
// Created: 01-26-22 // Created: 01-26-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/combination/ADFGX.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/combination/ADFGX.java
//Mattrixwv //Mattrixwv
// Created: 01-25-22 // Created: 01-25-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Affine.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Affine.java
//Mattrixwv //Mattrixwv
// Created: 01-26-22 // Created: 01-26-22
//Modified: 05-04-23 //Modified: 05-04-23
@@ -8,11 +8,10 @@ package com.mattrixwv.cipherstream.monosubstitution;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.mattrixwv.NumberAlgorithms;
import com.mattrixwv.cipherstream.exceptions.InvalidInputException; import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException; import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
import com.mattrixwv.NumberAlgorithms;
public class Affine{ public class Affine{
private static final Logger logger = LoggerFactory.getLogger(Affine.class); private static final Logger logger = LoggerFactory.getLogger(Affine.class);

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Atbash.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Atbash.java
//Mattrixwv //Mattrixwv
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/Baconian.java //CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/Baconian.java
//Mattrixwv //Mattrixwv
// Created: 01-12-22 // Created: 01-12-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
@@ -76,14 +76,14 @@ public class Baconian{
//Make sure each letter contains 5 characters //Make sure each letter contains 5 characters
if(str.length() != 5){ if(str.length() != 5){
throw new InvalidCharacterException("All Baconian letters contain exactly 5 characters: " + str); throw new InvalidCharacterException("All Baconian 'letters' contain exactly 5 characters. Invalid 'letter': " + str);
} }
//Make sure the letter contains only a's and b's //Make sure the letter contains only a's and b's
logger.debug("Replacing all non-abAB characters"); logger.debug("Replacing all non-abAB characters");
String temp = str.replaceAll("[^abAB]", ""); String temp = str.replaceAll("[^abAB]", "");
if(!temp.equals(str)){ if(!temp.equals(str)){
throw new InvalidCharacterException("Baconian letters contain only a's and b's: " + str); throw new InvalidCharacterException("Baconian 'letters' contain only a's and b's. Invalid 'letter': " + str);
} }
} }

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/BaseX.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/BaseX.java
//Mattrixwv //Mattrixwv
// Created: 01-08-22 // Created: 01-08-22
//Modified: 05-04-23 //Modified: 05-04-23
@@ -10,9 +10,9 @@ import java.util.StringJoiner;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException; import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
import com.mattrixwv.cipherstream.exceptions.InvalidInputException; import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
public class BaseX{ public class BaseX{

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Beaufort.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Beaufort.java
//Mattrixwv //Mattrixwv
// Created: 02-23-22 // Created: 02-23-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Caesar.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Caesar.java
//Matthew Ellison //Matthew Ellison
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/OneTimePad.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/OneTimePad.java
//Mattrixwv //Mattrixwv
// Created: 02-23-22 // Created: 02-23-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Porta.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Porta.java
//Mattrixwv //Mattrixwv
// Created: 02-28-22 // Created: 02-28-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Substitution.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Substitution.java
//Mattrixwv //Mattrixwv
// Created: 02-22-22 // Created: 02-22-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/Vigenere.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/monosubstitution/Vigenere.java
//Matthew Ellison //Matthew Ellison
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 05-04-23
@@ -98,7 +98,7 @@ public class Vigenere{
setOffset(); setOffset();
//If after all the eliminating of unusable characters the keyword is empty throw an exception //If after all the eliminating of unusable characters the keyword is empty throw an exception
if(this.keyword.isBlank()){ if(this.keyword.length() < 2){
throw new InvalidKeywordException("Keyword must contain at least 2 letters"); throw new InvalidKeywordException("Keyword must contain at least 2 letters");
} }
} }

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Bifid.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Bifid.java
//Mattrixwv //Mattrixwv
// Created: 03-03-22 // Created: 03-03-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//MattrixwvWebsite/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Columnar.java //MattrixwvWebsite/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Columnar.java
//Mattrixwv //Mattrixwv
// Created: 01-16-22 // Created: 01-16-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Hill.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Hill.java
//Mattrixwv //Mattrixwv
// Created: 01-31-22 // Created: 01-31-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Playfair.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Playfair.java
//Matthew Ellison //Matthew Ellison
// Created: 07-30-21 // Created: 07-30-21
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/PolybiusSquare.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/PolybiusSquare.java
//Mattrixwv //Mattrixwv
// Created: 01-04-22 // Created: 01-04-22
//Modified: 05-04-23 //Modified: 05-04-23

View File

@@ -1,4 +1,4 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/RailFence.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/RailFence.java
//Mattrixwv //Mattrixwv
// Created: 03-21-22 // Created: 03-21-22
//Modified: 05-04-23 //Modified: 05-04-23
@@ -10,8 +10,8 @@ import java.math.BigDecimal;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException; import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
public class RailFence{ public class RailFence{

View File

@@ -1,7 +1,7 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/polySubstitution/Trifid.java //CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/Trifid.java
//Mattrixwv //Mattrixwv
// Created: 03-03-22 // Created: 03-03-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
@@ -11,10 +11,10 @@ import java.util.StringJoiner;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException; import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
import com.mattrixwv.cipherstream.exceptions.InvalidInputException; import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException; import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
public class Trifid{ public class Trifid{
@@ -60,11 +60,11 @@ public class Trifid{
protected void setFillIn(char fillIn) throws InvalidCharacterException{ protected void setFillIn(char fillIn) throws InvalidCharacterException{
//Make sure the character is a printing character //Make sure the character is a printing character
if((fillIn < ' ') || (fillIn > '~')){ if((fillIn < ' ') || (fillIn > '~')){
throw new InvalidCharacterException("Fill in character must be a printing character"); throw new InvalidCharacterException("Fill in character must be a printable character");
} }
//Make sure the character is not a letter //Make sure the character is not a letter
if(Character.isAlphabetic(fillIn)){ if(Character.isAlphabetic(fillIn)){
throw new InvalidCharacterException("Fill in must not be a letter"); throw new InvalidCharacterException("Fill in must not be a non-letter character");
} }
logger.debug("Setting fill in {}", fillIn); logger.debug("Setting fill in {}", fillIn);

View File

@@ -1,22 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/combination/TestADFGVX.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGVX.java
//Mattrixwv //Mattrixwv
// Created: 01-26-22 // Created: 01-26-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.combination; package com.mattrixwv.cipherstream.combination;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -32,18 +23,18 @@ import com.mattrixwv.cipherstream.polysubstitution.LargePolybiusSquare;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestADFGVX{ public class ADFGVXTest{
@InjectMocks @InjectMocks
private ADFGVX cipher; private ADFGVX cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "AXgvdavfxgagfa afag^aaxdxfgdagda"; private static final String encodedString = "AXgvdavfxgagfa afag^aaxdxfgdagda";
private String encodedStringClean = "AXGVDAVFXGAGFAAFAGAAXDXFGDAGDA"; private static final String encodedStringClean = "AXGVDAVFXGAGFAAFAGAAXDXFGDAGDA";
private String keyword = "keyword"; private static final String keyword = "keyword";
private String squareKeyword = "SquareKeyword"; private static final String squareKeyword = "SquareKeyword";
@Test @Test

View File

@@ -1,22 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamjava/combination/TestADFGX.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/combination/TestADFGX.java
//Mattrixwv //Mattrixwv
// Created: 01-25-22 // Created: 01-25-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.combination; package com.mattrixwv.cipherstream.combination;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -32,18 +23,18 @@ import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestADFGX{ public class ADFGXTest{
@InjectMocks @InjectMocks
private ADFGX cipher; private ADFGX cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "AAgagadfagaxxd axdx^adafafxddgdf"; private static final String encodedString = "AAgagadfagaxxd axdx^adafafxddgdf";
private String encodedStringClean = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF"; private static final String encodedStringClean = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
private String keyword = "keyword"; private static final String keyword = "keyword";
private String squareKeyword = "SquareKeyword"; private static final String squareKeyword = "SquareKeyword";
@Test @Test

View File

@@ -1,36 +1,44 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidBaseException.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidBaseException.java
//Mattrixwv //Mattrixwv
// Created: 04-14-23 // Created: 04-14-23
//Modified: 04-14-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.exceptions; package com.mattrixwv.cipherstream.exceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class TestInvalidBaseException{ public class InvalidBaseExceptionTest{
private String message = "message"; private static final String message = "message";
private Throwable cause = new Exception(); private static final Throwable cause = new Exception();
@Test @Test
public void testConstructors(){ public void testConstructor_default(){
InvalidBaseException exception = new InvalidBaseException(); InvalidBaseException exception = new InvalidBaseException();
assertNull(exception.getMessage()); assertNull(exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidBaseException(message); @Test
public void testConstructor_message(){
InvalidBaseException exception = new InvalidBaseException(message);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidBaseException(cause); @Test
public void testConstructor_cause(){
InvalidBaseException exception = new InvalidBaseException(cause);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(cause.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
}
exception = new InvalidBaseException(message, cause); @Test
public void testConstructor_messageAndCause(){
InvalidBaseException exception = new InvalidBaseException(message, cause);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
} }

View File

@@ -1,36 +1,44 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidcharacterException.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidcharacterException.java
//Mattrixwv //Mattrixwv
// Created: 04-14-23 // Created: 04-14-23
//Modified: 04-14-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.exceptions; package com.mattrixwv.cipherstream.exceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class TestInvalidCharacterException{ public class InvalidCharacterExceptionTest{
private String message = "message"; private String message = "message";
private Throwable cause = new Exception(); private Throwable cause = new Exception();
@Test @Test
public void testConstructors(){ public void testConstructor_default(){
InvalidCharacterException exception = new InvalidCharacterException(); InvalidCharacterException exception = new InvalidCharacterException();
assertNull(exception.getMessage()); assertNull(exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidCharacterException(message); @Test
public void testConstructor_message(){
InvalidCharacterException exception = new InvalidCharacterException(message);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidCharacterException(cause); @Test
public void testConstructor_cause(){
InvalidCharacterException exception = new InvalidCharacterException(cause);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(cause.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
}
exception = new InvalidCharacterException(message, cause); @Test
public void testConstructor_messageAndCause(){
InvalidCharacterException exception = new InvalidCharacterException(message, cause);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
} }

View File

@@ -1,36 +1,44 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exception/TestInvalidInputException.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exception/TestInvalidInputException.java
//Mattrixwv //Mattrixwv
// Created: 04-14-23 // Created: 04-14-23
//Modified: 04-14-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.exceptions; package com.mattrixwv.cipherstream.exceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class TestInvalidInputException{ public class InvalidInputExceptionTest{
private String message = "message"; private String message = "message";
private Throwable cause = new Exception(); private Throwable cause = new Exception();
@Test @Test
public void testConstructors(){ public void testConstructor_default(){
InvalidInputException exception = new InvalidInputException(); InvalidInputException exception = new InvalidInputException();
assertNull(exception.getMessage()); assertNull(exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidInputException(message); @Test
public void testConstructor_message(){
InvalidInputException exception = new InvalidInputException(message);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidInputException(cause); @Test
public void testConstructor_cause(){
InvalidInputException exception = new InvalidInputException(cause);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(cause.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
}
exception = new InvalidInputException(message, cause); @Test
public void testConstructor_messageAndCause(){
InvalidInputException exception = new InvalidInputException(message, cause);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
} }

View File

@@ -1,36 +1,44 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeyException.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeyException.java
//Mattrixwv //Mattrixwv
// Created: 04-14-23 // Created: 04-14-23
//Modified: 04-14-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.exceptions; package com.mattrixwv.cipherstream.exceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class TestInvalidKeyException{ public class InvalidKeyExceptionTest{
public String message = "message"; public String message = "message";
public Throwable cause = new Exception(); public Throwable cause = new Exception();
@Test @Test
public void testConstructors(){ public void testConstructor_default(){
InvalidKeyException exception = new InvalidKeyException(); InvalidKeyException exception = new InvalidKeyException();
assertNull(exception.getMessage()); assertNull(exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidKeyException(message); @Test
public void testConstructor_message(){
InvalidKeyException exception = new InvalidKeyException(message);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidKeyException(cause); @Test
public void testConstructor_cause(){
InvalidKeyException exception = new InvalidKeyException(cause);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(cause.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
}
exception = new InvalidKeyException(message, cause); @Test
public void testConstructor_messageAndCause(){
InvalidKeyException exception = new InvalidKeyException(message, cause);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
} }

View File

@@ -1,36 +1,44 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeywordException.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeywordException.java
//Mattrixwv //Mattrixwv
// Created: 04-14-23 // Created: 04-14-23
//Modified: 04-14-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.exceptions; package com.mattrixwv.cipherstream.exceptions;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class TestInvalidKeywordException{ public class InvalidKeywordExceptionTest{
private String message = "message"; private String message = "message";
private Throwable cause = new Exception(); private Throwable cause = new Exception();
@Test @Test
public void testConstructor(){ public void testConstructor_default(){
InvalidKeywordException exception = new InvalidKeywordException(); InvalidKeywordException exception = new InvalidKeywordException();
assertNull(exception.getMessage()); assertNull(exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidKeywordException(message); @Test
public void testConstructor_message(){
InvalidKeywordException exception = new InvalidKeywordException(message);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertNull(exception.getCause()); assertNull(exception.getCause());
}
exception = new InvalidKeywordException(cause); @Test
public void testConstructor_cause(){
InvalidKeywordException exception = new InvalidKeywordException(cause);
assertEquals(cause.toString(), exception.getMessage()); assertEquals(cause.toString(), exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
}
exception = new InvalidKeywordException(message, cause); @Test
public void testConstructor_messageAndCause(){
InvalidKeywordException exception = new InvalidKeywordException(message, cause);
assertEquals(message, exception.getMessage()); assertEquals(message, exception.getMessage());
assertEquals(cause, exception.getCause()); assertEquals(cause, exception.getCause());
} }

View File

@@ -1,20 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestAffine.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/AffineTest.java
//Mattrixwv //Mattrixwv
// Created: 01-26-22 // Created: 01-26-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -28,18 +21,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestAffine{ public class AffineTest{
@InjectMocks @InjectMocks
private Affine cipher; private Affine cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "MEssage to^encode"; private static final String decodedString = "MEssage to^encode";
private String decodedStringClean = "messagetoencode"; private static final String decodedStringClean = "messagetoencode";
private String encodedString = "PBtthlb yz^burzwb"; private static final String encodedString = "PBtthlb yz^burzwb";
private String encodedStringClean = "pbtthlbyzburzwb"; private static final String encodedStringClean = "pbtthlbyzburzwb";
private int key1 = 5; private static final int key1 = 5;
private int key2 = 7; private static final int key2 = 7;
@Test @Test

View File

@@ -1,20 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAtbash.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/AtbashTest.java
//Mattrixwv //Mattrixwv
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -27,16 +20,16 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestAtbash{ public class AtbashTest{
@InjectMocks @InjectMocks
private Atbash cipher; private Atbash cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "Nvhhztv gl^vmxlwv"; private static final String encodedString = "Nvhhztv gl^vmxlwv";
private String encodedStringClean = "NVHHZTVGLVMXLWV"; private static final String encodedStringClean = "NVHHZTVGLVMXLWV";
@Test @Test

View File

@@ -1,17 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestAutokey.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/AutokeyTest.java
//Mattrixwv //Mattrixwv
// Created: 07-26-21 // Created: 07-26-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.*;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -25,18 +21,18 @@ import org.slf4j.Logger;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestAutokey{ public class AutokeyTest{
@InjectMocks @InjectMocks
private Autokey cipher; private Autokey cipher;
@Mock(name = "com.mattrixwv.cipherstream.monosubstitution.Autokey") @Mock(name = "com.mattrixwv.cipherstream.monosubstitution.Autokey")
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "MeSsage to^encode"; private static final String decodedString = "MeSsage to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "WiQooxh fs^wfcuhx"; private static final String encodedString = "WiQooxh fs^wfcuhx";
private String encodedStringClean = "WIQOOXHFSWFCUHX"; private static final String encodedStringClean = "WIQOOXHFSWFCUHX";
private String keyword = "keyword"; private static final String keyword = "keyword";
private ArrayList<Integer> offset = new ArrayList<>(List.of(10, 4, 24, 22, 14, 17, 3, 12, 4, 18, 18, 0, 6, 4, 19)); private static final ArrayList<Integer> offset = new ArrayList<>(List.of(10, 4, 24, 22, 14, 17, 3, 12, 4, 18, 18, 0, 6, 4, 19));
@Test @Test

View File

@@ -1,21 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestBaconian.java //CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/BaconianTest.java
//Mattrixwv //Mattrixwv
// Created: 01-12-22 // Created: 01-12-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,16 +21,16 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestBaconian{ public class BaconianTest{
@InjectMocks @InjectMocks
private Baconian cipher; private Baconian cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to-encode"; private static final String decodedString = "Message to-encode";
private String decodedStringClean = "Messagetoencode"; private static final String decodedStringClean = "Messagetoencode";
private String decodedStringCleanLower = "messagetoencode"; private static final String decodedStringCleanLower = "messagetoencode";
private String encodedString = "ABABB aabaa baaab baaab aaaaa aabba aabaa baaba abbab aabaa abbaa aaaba abbab aaabb aabaa"; private static final String encodedString = "ABABB aabaa baaab baaab aaaaa aabba aabaa baaba abbab aabaa abbaa aaaba abbab aaabb aabaa";
@Test @Test

View File

@@ -1,19 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBaseX.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/BaseXTest.java
//Mattrixwv //Mattrixwv
// Created: 01-08-22 // Created: 01-08-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.ArgumentMatchers.anyChar; import static org.mockito.Mockito.*;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -28,17 +22,17 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestBaseX{ public class BaseXTest{
@InjectMocks @InjectMocks
private BaseX cipher; private BaseX cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "A+B@C d\te\nf"; private static final String decodedString = "A+B@C d\te\nf";
private String encodedString_2 = "1000001 101011 1000010 1000000 1000011 100000 1100100 1001 1100101 1010 1100110"; private static final String encodedString_2 = "1000001 101011 1000010 1000000 1000011 100000 1100100 1001 1100101 1010 1100110";
private String encodedString_8 = "101 53 102 100 103 40 144 11 145 12 146"; private static final String encodedString_8 = "101 53 102 100 103 40 144 11 145 12 146";
private String encodedString_10 = "65 43 66 64 67 32 100 9 101 10 102"; private static final String encodedString_10 = "65 43 66 64 67 32 100 9 101 10 102";
private String encodedString_16 = "41 2B 42 40 43 20 64 9 65 A 66"; private static final String encodedString_16 = "41 2B 42 40 43 20 64 9 65 A 66";
@Test @Test

View File

@@ -1,19 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestBeaufort.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/BeaufortTest.java
//Mattrixwv //Mattrixwv
// Created: 02-23-22 // Created: 02-23-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -27,18 +21,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestBeaufort{ public class BeaufortTest{
@InjectMocks @InjectMocks
private Beaufort cipher; private Beaufort cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "Yageolz rq^ujmdag"; private static final String encodedString = "Yageolz rq^ujmdag";
private String encodedStringClean = "YAGEOLZRQUJMDAG"; private static final String encodedStringClean = "YAGEOLZRQUJMDAG";
private String keyword = "Ke*y word"; private static final String keyword = "Ke*y word";
private String keywordClean = "KEYWORD"; private static final String keywordClean = "KEYWORD";
@Test @Test

View File

@@ -1,19 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestCaesar.java //CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/CaesarTest.java
//Matthew Ellison //Matthew Ellison
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -26,17 +20,17 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestCaesar{ public class CaesarTest{
@InjectMocks @InjectMocks
private Caesar cipher; private Caesar cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "The quick brown fox jumps over - the lAzy dog"; private static final String decodedString = "The quick brown fox jumps over - the lAzy dog";
private String decodedStringClean = "thequickbrownfoxjumpsoverthelazydog"; private static final String decodedStringClean = "thequickbrownfoxjumpsoverthelazydog";
private String encodedString = "Qeb nrfzh yoltk clu grjmp lsbo - qeb iXwv ald"; private static final String encodedString = "Qeb nrfzh yoltk clu grjmp lsbo - qeb iXwv ald";
private String encodedStringClean = "qebnrfzhyoltkclugrjmplsboqebixwvald"; private static final String encodedStringClean = "qebnrfzhyoltkclugrjmplsboqebixwvald";
private int shift = 23; private static final int shift = 23;
@Test @Test

View File

@@ -1,18 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestOneTimePad.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/OneTimePadTest.java
//Mattrixwv //Mattrixwv
// Created: 02-23-22 // Created: 02-23-22
//Modified: 05-04-23 //Modified: 05-04-23
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -28,18 +23,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestOneTimePad{ public class OneTimePadTest{
@InjectMocks @InjectMocks
private OneTimePad cipher; private OneTimePad cipher;
@Mock(name = "com.mattrixwv.cipherstream.monosubstitution.OneTimePad") @Mock(name = "com.mattrixwv.cipherstream.monosubstitution.OneTimePad")
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "Wiqooxh mv^egkgws"; private static final String encodedString = "Wiqooxh mv^egkgws";
private String encodedStringClean = "WIQOOXHMVEGKGWS"; private static final String encodedStringClean = "WIQOOXHMVEGKGWS";
private String keyword = "keywordThatIsTotallyRandom"; private static final String keyword = "keywordThatIsTotallyRandom";
private ArrayList<Integer> offset = new ArrayList<>(Arrays.asList(10, 4, 24, 22, 14, 17, 3, 19, 7, 0, 19, 8, 18, 19, 14, 19, 0, 11, 11, 24, 17, 0, 13, 3, 14, 12)); private static final ArrayList<Integer> offset = new ArrayList<>(Arrays.asList(10, 4, 24, 22, 14, 17, 3, 19, 7, 0, 19, 8, 18, 19, 14, 19, 0, 11, 11, 24, 17, 0, 13, 3, 14, 12));
@Test @Test

View File

@@ -1,20 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestPorta.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/PortaTest.java
//Mattrixwv //Mattrixwv
// Created: 02-28-22 // Created: 02-28-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -28,18 +21,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestPorta{ public class PortaTest{
@InjectMocks @InjectMocks
private Porta cipher; private Porta cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "Rtghuos bm^qcwgrw"; private static final String encodedString = "Rtghuos bm^qcwgrw";
private String encodedStringClean = "RTGHUOSBMQCWGRW"; private static final String encodedStringClean = "RTGHUOSBMQCWGRW";
private String keyword = "keyword"; private static final String keyword = "keyword";
private String keywordDirty = "Ke yw*ord"; private static final String keywordDirty = "Ke yw*ord";
@Test @Test

View File

@@ -1,20 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestSubstitution.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/SubstitutionTest.java
//Mattrixwv //Mattrixwv
// Created: 02-22-22 // Created: 02-22-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -28,24 +21,24 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestSubstitution{ public class SubstitutionTest{
@InjectMocks @InjectMocks
private Substitution cipher; private Substitution cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String decodedStringAlNum = "Message to^encode 123"; private static final String decodedStringAlNum = "Message to^encode 123";
private String decodedStringAlNumClean = "MESSAGETOENCODE"; private static final String decodedStringAlNumClean = "MESSAGETOENCODE";
private String encodedString = "Oguucig vq^gpeqfg"; private static final String encodedString = "Oguucig vq^gpeqfg";
private String encodedStringClean = "OGUUCIGVQGPEQFG"; private static final String encodedStringClean = "OGUUCIGVQGPEQFG";
private String encodedStringAlNum = "Oguucig vq^gpeqfg 876"; private static final String encodedStringAlNum = "Oguucig vq^gpeqfg 876";
private String encodedStringAlNumClean = "OGUUCIGVQGPEQFG"; private static final String encodedStringAlNumClean = "OGUUCIGVQGPEQFG";
private String keyword = "cdefghijklmnopqrstuvwxyzab"; private static final String keyword = "cdefghijklmnopqrstuvwxyzab";
private String keywordClean = "CDEFGHIJKLMNOPQRSTUVWXYZAB"; private static final String keywordClean = "CDEFGHIJKLMNOPQRSTUVWXYZAB";
private String keywordAlNum = "cdefghijklmnopqrstuvwxyzab9876543210"; private static final String keywordAlNum = "cdefghijklmnopqrstuvwxyzab9876543210";
private String keywordAlNumClean = "CDEFGHIJKLMNOPQRSTUVWXYZAB9876543210"; private static final String keywordAlNumClean = "CDEFGHIJKLMNOPQRSTUVWXYZAB9876543210";
@Test @Test

View File

@@ -1,20 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/monoSubstitution/TestVigenere.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/monosubstitution/VigenereTest.java
//Mattrixwv //Mattrixwv
// Created: 07-25-21 // Created: 07-25-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.monosubstitution; package com.mattrixwv.cipherstream.monosubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -31,18 +24,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestVigenere{ public class VigenereTest{
@InjectMocks @InjectMocks
private Vigenere cipher; private Vigenere cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String inputString = "MeSsage to^encode"; private static final String inputString = "MeSsage to^encode";
private String inputStringClean = "MESSAGETOENCODE"; private static final String inputStringClean = "MESSAGETOENCODE";
private String outputString = "WiQooxh ds^cjqfgo"; private static final String outputString = "WiQooxh ds^cjqfgo";
private String outputStringClean = "WIQOOXHDSCJQFGO"; private static final String outputStringClean = "WIQOOXHDSCJQFGO";
private String keyword = "ke yw*ord"; private static final String keyword = "ke yw*ord";
private String keywordClean = "KEYWORD"; private static final String keywordClean = "KEYWORD";
private ArrayList<Integer> offset = new ArrayList<>(List.of(10, 4, 24, 22, 14, 17, 3)); private ArrayList<Integer> offset = new ArrayList<>(List.of(10, 4, 24, 22, 14, 17, 3));

View File

@@ -1,21 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestBifid.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/BifidTest.java
//Mattrixwv //Mattrixwv
// Created: 03-03-22 // Created: 03-03-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,18 +21,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestBifid{ public class BifidTest{
@InjectMocks @InjectMocks
private Bifid cipher; private Bifid cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Test //Test
private String inputString = "Message to^encode"; private static final String inputString = "Message to^encode";
private String inputStringClean = "MESSAGETOENCODE"; private static final String inputStringClean = "MESSAGETOENCODE";
private String outputString = "Mqaokne kc^vdodzd"; private static final String outputString = "Mqaokne kc^vdodzd";
private String outputStringClean = "MQAOKNEKCVDODZD"; private static final String outputStringClean = "MQAOKNEKCVDODZD";
private String keyword = "keyword"; private static final String keyword = "keyword";
private String keywordClean = "KEYWORDABCFGHILMNPQSTUVXZ"; private static final String keywordClean = "KEYWORDABCFGHILMNPQSTUVXZ";
@Test @Test

View File

@@ -1,21 +1,13 @@
//Mattrixwv/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestColumnar.java //Mattrixwv/src/test/java/com/mattrixwv/cipherstream/polysubstitution/ColumnarTest.java
//Mattrixwv //Mattrixwv
// Created: 01-16-22 // Created: 01-16-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -33,23 +25,23 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestColumnar{ public class ColumnarTest{
@InjectMocks @InjectMocks
private Columnar cipher; private Columnar cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to*encode"; private static final String decodedString = "Message to*encode";
private String decodedStringPadded = "Message to*encodexxxxxx"; private static final String decodedStringPadded = "Message to*encodexxxxxx";
private String decodedStringClean = "MESSAGETOENCODEXXXXXX"; private static final String decodedStringClean = "MESSAGETOENCODEXXXXXX";
private String encodedString = "Edeomte ac*gosnse"; private static final String encodedString = "Edeomte ac*gosnse";
//TODO: This is a bug that needs fixed //TODO: This is a bug that needs fixed
private String encodedStringPadingAdded = "Edxeoxmte ac*xgoxsnxsex"; //When padding is added to outputString for decoding private static final String encodedStringPadingAdded = "Edxeoxmte ac*xgoxsnxsex"; //When padding is added to outputString for decoding
private String encodedStringPadded = "Edxeoxm te*acxgoxsnxsex"; //When padding is left in outputString private static final String encodedStringPadded = "Edxeoxm te*acxgoxsnxsex"; //When padding is left in outputString
private String encodedStringClean = "EDXEOXMTEACXGOXSNXSEX"; private static final String encodedStringClean = "EDXEOXMTEACXGOXSNXSEX";
private String keyword = "ke yw*ord"; private static final String keyword = "ke yw*ord";
private String keywordClean = "KEYWORD"; private static final String keywordClean = "KEYWORD";
private ArrayList<ArrayList<Character>> encodeGrid = new ArrayList<>( private static final ArrayList<ArrayList<Character>> encodeGrid = new ArrayList<>(
List.of( List.of(
new ArrayList<>( new ArrayList<>(
List.of('K', 'E', 'Y', 'W', 'O', 'R', 'D') List.of('K', 'E', 'Y', 'W', 'O', 'R', 'D')
@@ -65,7 +57,7 @@ public class TestColumnar{
) )
) )
); );
private ArrayList<ArrayList<Character>> decodeGrid = new ArrayList<>( private static final ArrayList<ArrayList<Character>> decodeGrid = new ArrayList<>(
List.of( List.of(
new ArrayList<>( new ArrayList<>(
List.of('D', 'E', 'K', 'O', 'R', 'W', 'Y') List.of('D', 'E', 'K', 'O', 'R', 'W', 'Y')

View File

@@ -1,22 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamjava/polySubstitution/TestHill.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/HillTest.java
//Mattrixwv //Mattrixwv
// Created: 01-31-22 // Created: 01-31-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.ArrayList; import java.util.ArrayList;
@@ -34,19 +25,19 @@ import com.mattrixwv.matrix.ModMatrix;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestHill{ public class HillTest{
@InjectMocks @InjectMocks
private Hill cipher; private Hill cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String decodedString = "Message to^encoded"; private static final String decodedString = "Message to^encoded";
private String decodedStringPadded = "Message to^encodedxx"; private static final String decodedStringPadded = "Message to^encodedxx";
private String decodedStringClean = "MESSAGETOENCODEDXX"; private static final String decodedStringClean = "MESSAGETOENCODEDXX";
private String encodedString = "Mgkeqge ul^ikhisplrd"; private static final String encodedString = "Mgkeqge ul^ikhisplrd";
private String encodedStringClean = "MGKEQGEULIKHISPLRD"; private static final String encodedStringClean = "MGKEQGEULIKHISPLRD";
private int[][] keyArray = new int[][]{{1, 4, 2}, {2, 4, 1}, {4, 1, 2}}; private static final int[][] keyArray = new int[][]{{1, 4, 2}, {2, 4, 1}, {4, 1, 2}};
private ModMatrix key = new ModMatrix(keyArray, 26); private static final ModMatrix key = new ModMatrix(keyArray, 26);
@Test @Test

View File

@@ -1,21 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TestLargePolybiusSquare.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/LargePolybiusSquareTest.java
//Mattrixwv //Mattrixwv
// Created: 04-21-23 // Created: 04-21-23
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,20 +21,20 @@ import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestLargePolybiusSquare{ public class LargePolybiusSquareTest{
@InjectMocks @InjectMocks
private LargePolybiusSquare cipher; private LargePolybiusSquare cipher;
@Mock(name = "com.mattrixwv.cipherstream.polysubstitution.LargePolybiusSquare") @Mock(name = "com.mattrixwv.cipherstream.polysubstitution.LargePolybiusSquare")
private Logger logger; private Logger logger;
//Variables //Variables
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString = "35124343222612 4415^123624152112"; private static final String encodedString = "35124343222612 4415^123624152112";
private String encodedStringClean = "31 15 41 41 11 21 15 42 33 15 32 13 33 14 15"; private static final String encodedStringClean = "31 15 41 41 11 21 15 42 33 15 32 13 33 14 15";
private String keyword = "ke yw*ord"; private static final String keyword = "ke yw*ord";
private String keywordClean = "KEYWORDABCFGHIJLMNPQSTUVXZ0123456789"; private static final String keywordClean = "KEYWORDABCFGHIJLMNPQSTUVXZ0123456789";
private String keywordBlank = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; private static final String keywordBlank = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private char[][] grid = { private static final char[][] grid = {
{'K', 'E', 'Y', 'W', 'O', 'R'}, {'K', 'E', 'Y', 'W', 'O', 'R'},
{'D', 'A', 'B', 'C', 'F', 'G'}, {'D', 'A', 'B', 'C', 'F', 'G'},
{'H', 'I', 'J', 'L', 'M', 'N'}, {'H', 'I', 'J', 'L', 'M', 'N'},
@@ -50,7 +42,7 @@ public class TestLargePolybiusSquare{
{'X', 'Z', '0', '1', '2', '3'}, {'X', 'Z', '0', '1', '2', '3'},
{'4', '5', '6', '7', '8', '9'} {'4', '5', '6', '7', '8', '9'}
}; };
private char[][] gridClean = { private static final char[][] gridClean = {
{'A', 'B', 'C', 'D', 'E', 'F'}, {'A', 'B', 'C', 'D', 'E', 'F'},
{'G', 'H', 'I', 'J', 'K', 'L'}, {'G', 'H', 'I', 'J', 'K', 'L'},
{'M', 'N', 'O', 'P', 'Q', 'R'}, {'M', 'N', 'O', 'P', 'Q', 'R'},

View File

@@ -1,18 +1,13 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestMorse.java //CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/MoresTest.java
//Matthew Ellison //Matthew Ellison
// Created: 07-28-21 // Created: 07-28-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.ArgumentMatchers.anyChar; import static org.mockito.Mockito.*;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -25,15 +20,15 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestMorse{ public class MorseTest{
@InjectMocks @InjectMocks
private Morse cipher; private Morse cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String inputString = "Message to^encode123"; private static final String inputString = "Message to^encode123";
private String inputStringClean = "MESSAGETOENCODE123"; private static final String inputStringClean = "MESSAGETOENCODE123";
private String outputString = "-- . ... ... .- --. . - --- . -. -.-. --- -.. . .---- ..--- ...--"; private static final String outputString = "-- . ... ... .- --. . - --- . -. -.-. --- -.. . .---- ..--- ...--";
@Test @Test

View File

@@ -1,23 +1,13 @@
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/TestPlayfair.java //CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/PlayfairTest.java
//Matthew Ellison //Matthew Ellison
// Created: 07-30-21 // Created: 07-30-21
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -33,20 +23,20 @@ import com.mattrixwv.cipherstream.polysubstitution.Playfair.CharLocation;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestPlayfair{ public class PlayfairTest{
@InjectMocks @InjectMocks
private Playfair cipher; private Playfair cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String decodedString = "Hide the gold in - the@tree+stump"; private static final String decodedString = "Hide the gold in - the@tree+stump";
private String decodedStringPadded = "Hide the gold in - the@trexe+stump"; private static final String decodedStringPadded = "Hide the gold in - the@trexe+stump";
private String decodedStringClean = "HIDETHEGOLDINTHETREXESTUMP"; private static final String decodedStringClean = "HIDETHEGOLDINTHETREXESTUMP";
private String encodedString = "Bmod zbx dnab ek - udm@uixmm+ouvif"; private static final String encodedString = "Bmod zbx dnab ek - udm@uixmm+ouvif";
private String encodedStringClean = "BMODZBXDNABEKUDMUIXMMOUVIF"; private static final String encodedStringClean = "BMODZBXDNABEKUDMUIXMMOUVIF";
private String keyword = "Play-fair@Exam ple"; private static final String keyword = "Play-fair@Exam ple";
private String keywordClean = "PLAYFIREXMBCDGHKNOQSTUVWZ"; private static final String keywordClean = "PLAYFIREXMBCDGHKNOQSTUVWZ";
private char[][] grid = new char[][]{ private static final char[][] grid = new char[][]{
{'P', 'L', 'A', 'Y', 'F'}, {'P', 'L', 'A', 'Y', 'F'},
{'I', 'R', 'E', 'X', 'M'}, {'I', 'R', 'E', 'X', 'M'},
{'B', 'C', 'D', 'G', 'H'}, {'B', 'C', 'D', 'G', 'H'},

View File

@@ -1,22 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/TestPolybiusSquare.java //CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/PolybiusSquareTest.java
//Mattrixwv //Mattrixwv
// Created: 01-04-22 // Created: 01-04-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -32,26 +23,26 @@ import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare.CharLocation;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestPolybiusSquare{ public class PolybiusSquareTest{
@InjectMocks @InjectMocks
private PolybiusSquare cipher; private PolybiusSquare cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "M E S S A G E T O E N C O D E"; private static final String decodedStringClean = "M E S S A G E T O E N C O D E";
private String encodedString = "41124545233212 5115^124225152212"; private static final String encodedString = "41124545233212 5115^124225152212";
private String encodedStringClean = "41 12 45 45 23 32 12 51 15 12 42 25 15 22 12"; private static final String encodedStringClean = "41 12 45 45 23 32 12 51 15 12 42 25 15 22 12";
private String keyword = "ke yw*ord"; private static final String keyword = "ke yw*ord";
private String keywordClean = "KEYWORDABCFGHILMNPQSTUVXZ"; private static final String keywordClean = "KEYWORDABCFGHILMNPQSTUVXZ";
private char[][] grid = new char[][]{ private static final char[][] grid = new char[][]{
{'K', 'E', 'Y', 'W', 'O'}, {'K', 'E', 'Y', 'W', 'O'},
{'R', 'D', 'A', 'B', 'C'}, {'R', 'D', 'A', 'B', 'C'},
{'F', 'G', 'H', 'I', 'L'}, {'F', 'G', 'H', 'I', 'L'},
{'M', 'N', 'P', 'Q', 'S'}, {'M', 'N', 'P', 'Q', 'S'},
{'T', 'U', 'V', 'X', 'Z'} {'T', 'U', 'V', 'X', 'Z'}
}; };
private String gridString = "[K E Y W O]\n[R D A B C]\n[F G H I L]\n[M N P Q S]\n[T U V X Z]"; private static final String gridString = "[K E Y W O]\n[R D A B C]\n[F G H I L]\n[M N P Q S]\n[T U V X Z]";
@Test @Test

View File

@@ -1,23 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestRailFence.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/RailFenceTest.java
//Mattrixwv //Mattrixwv
// Created: 03-21-22 // Created: 03-21-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -31,24 +21,24 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestRailFence{ public class RailFenceTest{
@InjectMocks @InjectMocks
private RailFence cipher; private RailFence cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String decodedString = "Message to^encode"; private static final String decodedString = "Message to^encode";
private String decodedStringClean = "MESSAGETOENCODE"; private static final String decodedStringClean = "MESSAGETOENCODE";
private String encodedString3 = "Maooesg te^cdsene"; private static final String encodedString3 = "Maooesg te^cdsene";
private String encodedString3Clean = "MAOOESGTECDSENE"; private static final String encodedString3Clean = "MAOOESGTECDSENE";
private String encodedString5 = "Moetese ne^sgcdao"; private static final String encodedString5 = "Moetese ne^sgcdao";
private String encodedString5Clean = "MOETESENESGCDAO"; private static final String encodedString5Clean = "MOETESENESGCDAO";
private StringBuilder[] fence3 = new StringBuilder[]{ private static final StringBuilder[] fence3 = new StringBuilder[]{
new StringBuilder("Maoo"), new StringBuilder("Maoo"),
new StringBuilder("esgtecd"), new StringBuilder("esgtecd"),
new StringBuilder("sene") new StringBuilder("sene")
}; };
private StringBuilder[] fence5 = new StringBuilder[]{ private static final StringBuilder[] fence5 = new StringBuilder[]{
new StringBuilder("Mo"), new StringBuilder("Mo"),
new StringBuilder("ete"), new StringBuilder("ete"),
new StringBuilder("sene"), new StringBuilder("sene"),

View File

@@ -1,22 +1,13 @@
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamJava/polySubstitution/TestTrifid.java //CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/polysubstitution/TrifidTest.java
//Mattrixwv //Mattrixwv
// Created: 03-03-22 // Created: 03-03-22
//Modified: 05-04-23 //Modified: 04-19-24
package com.mattrixwv.cipherstream.polysubstitution; package com.mattrixwv.cipherstream.polysubstitution;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyChar;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@@ -35,25 +26,25 @@ import com.mattrixwv.cipherstream.polysubstitution.Trifid.CharLocation;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class TestTrifid{ public class TrifidTest{
@InjectMocks @InjectMocks
private Trifid cipher; private Trifid cipher;
@Mock @Mock
private Logger logger; private Logger logger;
//Fields //Fields
private String decodedString = "Message to^encode+"; private static final String decodedString = "Message to^encode+";
private String decodedStringClean = "MESSAGETOENCODE+"; private static final String decodedStringClean = "MESSAGETOENCODE+";
private String decodedStringCleanAlt = "MESSAGETOENCODE"; private static final String decodedStringCleanAlt = "MESSAGETOENCODE";
private String encodedString = "Gqdokxy eg^ranmoqr"; private static final String encodedString = "Gqdokxy eg^ranmoqr";
private String encodedStringAlt = "Gqdokpd od^ljvflf+"; private static final String encodedStringAlt = "Gqdokpd od^ljvflf+";
private String encodedString3 = "Gpjqdvd of^odlklf+"; private static final String encodedString3 = "Gpjqdvd of^odlklf+";
private String encodedStringClean = "GQDOKXYEGRANMOQR"; private static final String encodedStringClean = "GQDOKXYEGRANMOQR";
private String encodedStringCleanAlt = "GQDOKPDODLJVFLF"; private static final String encodedStringCleanAlt = "GQDOKPDODLJVFLF";
private String encodedStringClean3 = "GPJQDVDOFODLKLF+"; private static final String encodedStringClean3 = "GPJQDVDOFODLKLF+";
private String keyword = "ke yw*ord"; private static final String keyword = "ke yw*ord";
private String keywordClean = "KEYWORDABCFGHIJLMNPQSTUVXZ+"; private static final String keywordClean = "KEYWORDABCFGHIJLMNPQSTUVXZ+";
private String keywordCleanAlt = "KEYWORDABCFGHIJLMNPQSTUVXZ="; private static final String keywordCleanAlt = "KEYWORDABCFGHIJLMNPQSTUVXZ=";
private char[][][] grid = new char[][][]{ private static final char[][][] grid = new char[][][]{
{ {
{'K', 'E', 'Y'}, {'K', 'E', 'Y'},
{'W', 'O', 'R'}, {'W', 'O', 'R'},
@@ -70,8 +61,8 @@ public class TestTrifid{
{'X', 'Z', '+'} {'X', 'Z', '+'}
} }
}; };
private String gridString = "[K E Y]\n[W O R]\n[D A B]\n\n[C F G]\n[H I J]\n[L M N]\n\n[P Q S]\n[T U V]\n[X Z +]"; private static final String gridString = "[K E Y]\n[W O R]\n[D A B]\n\n[C F G]\n[H I J]\n[L M N]\n\n[P Q S]\n[T U V]\n[X Z +]";
private char[][][] gridAlt = new char[][][]{ private static final char[][][] gridAlt = new char[][][]{
{ {
{'K', 'E', 'Y'}, {'K', 'E', 'Y'},
{'W', 'O', 'R'}, {'W', 'O', 'R'},