Update test coverage
This commit is contained in:
67
pom.xml
67
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.mattrixwv</groupId>
|
||||
<artifactId>cipher-stream-java</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0</version>
|
||||
|
||||
<name>CipherStreamJava</name>
|
||||
<url>http://www.mattrixwv.com</url>
|
||||
@@ -14,12 +14,13 @@
|
||||
<properties>
|
||||
<!--Compile-->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>19</maven.compiler.source>
|
||||
<maven.compiler.target>19</maven.compiler.target>
|
||||
<java.version>19</java.version>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<java.version>20</java.version>
|
||||
|
||||
<!--Sonarqube-->
|
||||
<sonar.java.source>19</sonar.java.source>
|
||||
<sonar.java.source>20</sonar.java.source>
|
||||
<sonar.dependencyCheck.jsonReportPath>target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
|
||||
<sonar.dependencyCheck.htmlReportPath>target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
|
||||
</properties>
|
||||
@@ -28,28 +29,47 @@
|
||||
<dependency>
|
||||
<groupId>mattrixwv</groupId>
|
||||
<artifactId>myClasses</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mattrixwv</groupId>
|
||||
<artifactId>matrix</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.6</version>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Test-->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.9.1</version>
|
||||
<version>5.9.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>5.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -58,7 +78,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-maven</id>
|
||||
@@ -83,46 +103,51 @@
|
||||
<!--Default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging-->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<version>3.11.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<version>3.3.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
<!--Site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle-->
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<version>3.12.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.4.2</version>
|
||||
</plugin>
|
||||
<!--Versions-->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<version>2.15.0</version>
|
||||
<configuration>
|
||||
<rulesUri>file://${session.executionRootDirectory}/version-rules.xml</rulesUri>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</plugin>
|
||||
<!--Sonarqube-->
|
||||
<plugin>
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
@@ -132,7 +157,7 @@
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.8</version>
|
||||
<version>0.8.9</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
@@ -153,7 +178,7 @@
|
||||
<plugin>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
<version>7.1.1</version>
|
||||
<version>8.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>none</phase>
|
||||
|
||||
@@ -16,23 +16,23 @@ import com.mattrixwv.cipherstream.polysubstitution.PolybiusSquare;
|
||||
|
||||
|
||||
public class ADFGX{
|
||||
private static final Logger logger = LoggerFactory.getLogger(ADFGX.class);
|
||||
protected static Logger logger = LoggerFactory.getLogger(ADFGX.class);
|
||||
|
||||
//Internal fields
|
||||
private String inputString; //The string that needs encoded/decoded
|
||||
private String outputString; //The string that is output after encoding/decoding
|
||||
private String squareKeyword; //The keyword used in the Polybius Square
|
||||
private String keyword; //The keyword used in the Columnar cipher
|
||||
private boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
private boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
private boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
protected String inputString; //The string that needs encoded/decoded
|
||||
protected String outputString; //The string that is output after encoding/decoding
|
||||
protected String squareKeyword; //The keyword used in the Polybius Square
|
||||
protected String keyword; //The keyword used in the Columnar cipher
|
||||
protected boolean preserveCapitals; //Whether to respect capitals in the output string
|
||||
protected boolean preserveWhitespace; //Whether to respect whitespace in the output string
|
||||
protected boolean preserveSymbols; //Whether to respect symbols in the output string
|
||||
//Internal ciphers
|
||||
private PolybiusSquare polybiusSquare; //The first step in encoding
|
||||
private Columnar columnar; //The second step in encoding
|
||||
protected PolybiusSquare polybiusSquare; //The first step in encoding
|
||||
protected Columnar columnar; //The second step in encoding
|
||||
|
||||
|
||||
//Ensures Polybius keyword constraints
|
||||
private void setSquareKeyword(String squareKeyword) throws InvalidKeywordException{
|
||||
protected void setSquareKeyword(String squareKeyword) throws InvalidKeywordException{
|
||||
if(squareKeyword == null){
|
||||
throw new InvalidKeywordException("Square keyword cannot be null");
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class ADFGX{
|
||||
this.squareKeyword = squareKeyword;
|
||||
}
|
||||
//Ensures Columnar keyword constraints
|
||||
private void setKeyword(String keyword) throws InvalidKeywordException{
|
||||
protected void setKeyword(String keyword) throws InvalidKeywordException{
|
||||
if(keyword == null){
|
||||
throw new InvalidKeywordException("Keyword cannot be null");
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ADFGX{
|
||||
this.keyword = keyword;
|
||||
}
|
||||
//Ensures inputString constraints
|
||||
private void setInputString(String inputString) throws InvalidInputException{
|
||||
protected void setInputString(String inputString) throws InvalidInputException{
|
||||
if(inputString == null){
|
||||
throw new InvalidInputException("Input cannot be null");
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class ADFGX{
|
||||
logger.debug("cleaned input string '{}'", inputString);
|
||||
}
|
||||
//Format the output string with capitals, symbols, and numbers that are in the input string
|
||||
private void formatOutputStringEncode(){
|
||||
protected void formatOutputStringEncode(){
|
||||
logger.debug("Formatting output string to match input string");
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
@@ -109,7 +109,7 @@ public class ADFGX{
|
||||
logger.debug("Saving output string '{}'", outputString);
|
||||
outputString = output.toString();
|
||||
}
|
||||
private void formatOutputStringDecode(){
|
||||
protected void formatOutputStringDecode(){
|
||||
logger.debug("Formatting output string to match input string");
|
||||
StringBuilder output = new StringBuilder();
|
||||
int outputLocation = 0;
|
||||
@@ -139,7 +139,7 @@ public class ADFGX{
|
||||
outputString = output.toString();
|
||||
}
|
||||
//Encodes the inputString and stores the result in outputString
|
||||
private void encode() throws InvalidCharacterException, InvalidInputException, InvalidKeywordException{
|
||||
protected void encode() throws InvalidCharacterException, InvalidInputException, InvalidKeywordException{
|
||||
//Encode the input with polybius
|
||||
logger.debug("Encoding using Polybius Square");
|
||||
String polybiusOutput = polybiusSquare.encode(squareKeyword, inputString);
|
||||
@@ -158,7 +158,7 @@ public class ADFGX{
|
||||
formatOutputStringEncode();
|
||||
}
|
||||
//Decodes the inputString and stores the result in outputString
|
||||
private void decode() throws InvalidKeywordException, InvalidCharacterException, InvalidInputException{
|
||||
protected void decode() throws InvalidKeywordException, InvalidCharacterException, InvalidInputException{
|
||||
//Decode the input with columnar
|
||||
logger.debug("Decoding using columnar");
|
||||
String columnarOutput = columnar.decode(keyword, inputString);
|
||||
|
||||
@@ -1,450 +1,199 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/CipherStreamjava/combination/TestADFGX.java
|
||||
//Mattrixwv
|
||||
// Created: 01-25-22
|
||||
//Modified: 07-09-22
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.combination;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidCharacterException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
|
||||
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
|
||||
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class TestADFGX{
|
||||
@Test
|
||||
public void testEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, true, true);
|
||||
private ADFGX cipher;
|
||||
private Logger logger;
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to+encode-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(false, true, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
String output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXD AXDX ADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to+encode-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXD*AXDX+ADAFAFXDDGDF-";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXD AXDX^ADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoWhitespaceEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, false, true);
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to+encode-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAgagadfagaxxdaxdx^adafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoSymbolEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, true, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to+encode-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAgagadfagaxxd axdxadafafxddgdf";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
}
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolEncode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(false, false, false);
|
||||
|
||||
//Test lowercase encoding
|
||||
String inputString = "messagetoencode";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
String output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase encoding
|
||||
inputString = "MESSAGETOENCODE";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace encoding
|
||||
inputString = "message to encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol encoding
|
||||
inputString = "message*to+encode-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol encoding
|
||||
inputString = "Message to^encode";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
output = cipher.encode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
cipher = new ADFGX();
|
||||
logger = mock(Logger.class);
|
||||
ADFGX.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, true, true);
|
||||
public void testSetSquareKeyword(){
|
||||
assertThrows(InvalidKeywordException.class, () -> {
|
||||
cipher.setSquareKeyword(null);
|
||||
});
|
||||
assertEquals("", cipher.squareKeyword);
|
||||
verify(logger, never()).debug(anyString(), anyString());
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message to encode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message*to+encode-";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol decoding
|
||||
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Message to^encode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
String squareKeyword = "squareKeyword";
|
||||
cipher.setSquareKeyword(squareKeyword);
|
||||
assertEquals(squareKeyword, cipher.squareKeyword);
|
||||
verify(logger, times(1)).debug("squareKeyword = {}", squareKeyword);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(false, true, true);
|
||||
public void testSetKeyword(){
|
||||
assertThrows(InvalidKeywordException.class, () -> {
|
||||
cipher.setKeyword(null);
|
||||
});
|
||||
assertEquals("", cipher.keyword);
|
||||
verify(logger, never()).debug(anyString(), anyString());
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "MESSAGETOENCODE";
|
||||
String output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE TO ENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE*TO+ENCODE-";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol decoding
|
||||
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGE TO^ENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
cipher.setKeyword(keyword);
|
||||
assertEquals(keyword, cipher.keyword);
|
||||
verify(logger, times(1)).debug("keyword = {}", keyword);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoWhitespaceDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, false, true);
|
||||
public void testSetInputString(){
|
||||
//Null input
|
||||
assertThrows(InvalidInputException.class, () -> {
|
||||
cipher.setInputString(null);
|
||||
});
|
||||
assertEquals("", cipher.inputString);
|
||||
verify(logger, never()).debug(anyString(), anyString());
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
String originalInputString = "original input string '{}'";
|
||||
String cleanedInputString = "cleaned input string '{}'";
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Blank input
|
||||
cipher.preserveCapitals = true;
|
||||
cipher.preserveSymbols = true;
|
||||
cipher.preserveWhitespace = true;
|
||||
assertThrows(InvalidInputException.class, () -> {
|
||||
cipher.setInputString("");
|
||||
});
|
||||
assertEquals("", cipher.inputString);
|
||||
verify(logger, times(1)).debug(originalInputString, "");
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message*to+encode-";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//No options
|
||||
String inputString = "input String*";
|
||||
cipher.setInputString(inputString);
|
||||
assertEquals(inputString, cipher.inputString);
|
||||
verify(logger, times(1)).debug(originalInputString, inputString);
|
||||
verify(logger, times(1)).debug(cleanedInputString, inputString);
|
||||
|
||||
//Test mixed case, whitespace, and symbol decoding
|
||||
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Messageto^encode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//capitals
|
||||
cipher.preserveCapitals = false;
|
||||
cipher.preserveWhitespace = true;
|
||||
cipher.preserveSymbols = true;
|
||||
inputString = "input String*";
|
||||
cipher.setInputString(inputString);
|
||||
assertEquals(inputString.toUpperCase(), cipher.inputString);
|
||||
verify(logger, times(2)).debug(originalInputString, inputString);
|
||||
verify(logger, times(1)).debug("Removing capitals");
|
||||
verify(logger, times(1)).debug(cleanedInputString, inputString.toUpperCase());
|
||||
|
||||
//whitespace
|
||||
cipher.preserveCapitals = true;
|
||||
cipher.preserveWhitespace = false;
|
||||
cipher.preserveSymbols = true;
|
||||
inputString = "input String*";
|
||||
cipher.setInputString(inputString);
|
||||
assertEquals(inputString.replaceAll("\\s", ""), cipher.inputString);
|
||||
verify(logger, times(3)).debug(originalInputString, inputString);
|
||||
verify(logger, times(1)).debug("Removing whitespace");
|
||||
verify(logger, times(1)).debug(cleanedInputString, inputString.replaceAll("\\s", ""));
|
||||
|
||||
//symbols
|
||||
cipher.preserveCapitals = true;
|
||||
cipher.preserveWhitespace = true;
|
||||
cipher.preserveSymbols = false;
|
||||
inputString = "input String*";
|
||||
cipher.setInputString(inputString);
|
||||
assertEquals(inputString.replaceAll("[^a-zA-Z\\s]", ""), cipher.inputString);
|
||||
verify(logger, times(4)).debug(originalInputString, inputString);
|
||||
verify(logger, times(1)).debug("Removing symbols");
|
||||
verify(logger, times(1)).debug(cleanedInputString, inputString.replaceAll("[^a-zA-Z\\s]", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSymbolDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(true, true, false);
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "messagetoencode";
|
||||
String output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "message to encode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "messagetoencode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
|
||||
//Test mixed case, whitespace, and symbol decoding
|
||||
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "Message toencode";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
public void testFormatOutputStringEncode(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCapitalWhitespaceSymbolDecode() throws InvalidCharacterException, InvalidKeywordException, InvalidInputException{
|
||||
ADFGX cipher = new ADFGX(false, false, false);
|
||||
public void formatOutputStringDecode(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
//Test lowercase decoding
|
||||
String inputString = "aagagadfagaxxdaxdxadafafxddgdf";
|
||||
String squareKeyword = "SquareKeyword";
|
||||
String keyword = "keyword";
|
||||
String correctOutput = "MESSAGETOENCODE";
|
||||
String output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
//Test uppercase decoding
|
||||
inputString = "AAGAGADFAGAXXDAXDXADAFAFXDDGDF";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
@Test
|
||||
public void testEncodePrivate(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
//Test whitespace decoding
|
||||
inputString = "aagagadfagaxxd axdx adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
@Test
|
||||
public void testDecodePrivate(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
//Test symbol decoding
|
||||
inputString = "aagagadfagaxxd*axdx+adafafxddgdf-";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
//Test mixed case, whitespace, and symbol decoding
|
||||
inputString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
squareKeyword = "SquareKeyword";
|
||||
keyword = "keyword";
|
||||
correctOutput = "MESSAGETOENCODE";
|
||||
output = cipher.decode(squareKeyword, keyword, inputString);
|
||||
assertEquals(correctOutput, output);
|
||||
@Test
|
||||
public void testGetters(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset(){
|
||||
//TODO:
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPracticalEncoding(){
|
||||
//Test as original
|
||||
cipher.preserveCapitals = true;
|
||||
cipher.preserveWhitespace = true;
|
||||
cipher.preserveSymbols = true;
|
||||
String output = cipher.encode("SquareKeyword", "keyword", "Message to^encode");
|
||||
assertEquals("AAgagadfagaxxd axdx^adafafxddgdf", output);
|
||||
|
||||
//Test fully cleaned
|
||||
cipher.preserveCapitals = false;
|
||||
cipher.preserveWhitespace = false;
|
||||
cipher.preserveSymbols = false;
|
||||
output = cipher.encode("SquareKeyword", "keyword", "Message to^encode");
|
||||
assertEquals("AAGAGADFAGAXXDAXDXADAFAFXDDGDF", output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPracticalDecoding(){
|
||||
//Test as original
|
||||
cipher.preserveCapitals = true;
|
||||
cipher.preserveWhitespace = true;
|
||||
cipher.preserveSymbols = true;
|
||||
String output = cipher.decode("SquareKeyword", "keyword", "AAgagadfagaxxd axdx^adafafxddgdf");
|
||||
assertEquals("Message to^encode", output);
|
||||
|
||||
//Test fully cleaned
|
||||
cipher.preserveCapitals = false;
|
||||
cipher.preserveWhitespace = false;
|
||||
cipher.preserveSymbols = false;
|
||||
output = cipher.decode("SquareKeyword", "keyword", "AAgagadfagaxxd axdx^adafafxddgdf");
|
||||
assertEquals("MESSAGETOENCODE", output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidBaseException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-14-23
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidBaseException{
|
||||
private String message = "message";
|
||||
private Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
InvalidBaseException exception = new InvalidBaseException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidBaseException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidBaseException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidBaseException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidcharacterException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-14-23
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidCharacterException{
|
||||
private String message = "message";
|
||||
private Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
InvalidCharacterException exception = new InvalidCharacterException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidCharacterException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidCharacterException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidCharacterException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exception/TestInvalidInputException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-14-23
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidInputException{
|
||||
private String message = "message";
|
||||
private Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
InvalidInputException exception = new InvalidInputException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidInputException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidInputException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidInputException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeyException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-14-23
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidKeyException{
|
||||
public String message = "message";
|
||||
public Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructors(){
|
||||
InvalidKeyException exception = new InvalidKeyException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidKeyException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidKeyException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidKeyException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//CipherStreamJava/src/test/java/com/mattrixwv/cipherstream/exceptions/TestInvalidKeywordException.java
|
||||
//Mattrixwv
|
||||
// Created: 04-14-23
|
||||
//Modified: 04-14-23
|
||||
package com.mattrixwv.cipherstream.exceptions;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
public class TestInvalidKeywordException{
|
||||
private String message = "message";
|
||||
private Throwable cause = new Exception();
|
||||
|
||||
|
||||
@Test
|
||||
public void testConstructor(){
|
||||
InvalidKeywordException exception = new InvalidKeywordException();
|
||||
assertNull(exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidKeywordException(message);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertNull(exception.getCause());
|
||||
|
||||
exception = new InvalidKeywordException(cause);
|
||||
assertEquals(cause.toString(), exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
|
||||
exception = new InvalidKeywordException(message, cause);
|
||||
assertEquals(message, exception.getMessage());
|
||||
assertEquals(cause, exception.getCause());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user