Browse Source

Remove checker framework and fix tests.

Tankernn 8 years ago
parent
commit
ab0eeeeb91

+ 6 - 13
pom.xml

@@ -33,7 +33,7 @@
 			<scope>test</scope>
 		</dependency>
 		<!-- annotations from the Checker Framework: nullness, interning, locking, 
-			... -->
+			... 
 		<dependency>
 			<groupId>org.checkerframework</groupId>
 			<artifactId>checker-qual</artifactId>
@@ -43,7 +43,8 @@
 			<groupId>org.checkerframework</groupId>
 			<artifactId>checker</artifactId>
 			<version>2.1.8</version>
-		</dependency>
+		</dependency> 
+		-->
 		<!-- The type annotations compiler - uncomment if desired -->
 		<!-- <dependency> <groupId>org.checkerframework</groupId> <artifactId>compiler</artifactId> 
 			<version>2.1.8</version> </dependency> -->
@@ -66,16 +67,14 @@
 					<source>1.8</source>
 					<target>1.8</target>
 					<fork>true</fork>
+					<!-- 
 					<annotationProcessors>
-						<!-- Add all the checkers you want to enable here -->
 						<annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>
 					</annotationProcessors>
 					<compilerArgs>
-						<!-- location of the annotated JDK, which comes from a Maven dependency -->
 						<arg>-Xbootclasspath/p:${annotatedJdk}</arg>
-						<!-- Uncomment the following line to use the type annotations compiler. -->
-						<!-- <arg>-J-Xbootclasspath/p:${typeAnnotationsJavac}</arg> -->
 					</compilerArgs>
+					 -->
 				</configuration>
 			</plugin>
 			<plugin>
@@ -129,13 +128,7 @@
 	</build>
 
 	<properties>
-		<!-- These properties will be set by the Maven Dependency plugin -->
-		<!-- Change to jdk7 if using Java 7 -->
-		<annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk>
-		<!-- Uncomment to use the type annotations compiler. -->
-		<!-- <typeAnnotationsJavac>${org.checkerframework:compiler:jar}</typeAnnotationsJavac> -->
-		<maven.compiler.source>1.8</maven.compiler.source>
-		<maven.compiler.target>1.8</maven.compiler.target>
+		<!-- <annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk> -->
 		<build.number>SNAPSHOT</build.number>
 	</properties>
 </project>

+ 2 - 4
src/main/java/eu/tankernn/accounts/FileManager.java

@@ -12,8 +12,6 @@ import java.io.ObjectStreamException;
 
 import javax.swing.JOptionPane;
 
-import org.checkerframework.checker.nullness.qual.NonNull;
-
 import eu.tankernn.accounts.util.encryption.EncryptedComplex;
 import eu.tankernn.accounts.util.encryption.Encryption;
 import eu.tankernn.accounts.util.encryption.InvalidPasswordException;
@@ -74,7 +72,7 @@ public class FileManager {
 		writeBytesToFile(file, contents.getBytes());
 	}
 
-	private static void writeBytesToFile(@NonNull File file, byte[] data) {
+	private static void writeBytesToFile(File file, byte[] data) {
 		try {
 			FileOutputStream writer = new FileOutputStream(file);
 			writer.write(data, 0, data.length);
@@ -88,7 +86,7 @@ public class FileManager {
 
 	}
 
-	public static <T> T readObjectFromFile(@NonNull File file, Class<T> class1)
+	public static <T> T readObjectFromFile(File file, Class<T> class1)
 			throws ClassNotFoundException, FileNotFoundException, IOException {
 		ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
 		T obj = class1.cast(in.readObject());

+ 18 - 6
src/test/java/eu/tankernn/accounts/test/FileManagerTest.java

@@ -10,19 +10,31 @@ import eu.tankernn.accounts.FileManager;
 import eu.tankernn.accounts.util.encryption.InvalidPasswordException;
 
 public class FileManagerTest {
+	String testData = "[VeryNice2123..----__...'+<<><";
+	File testFile = new File("test.txt");
+	
 	@Test
-	public void readingStringShouldReturnEqualString() {
-		String testData = "VeryNice2123..----__...'¨´+<<><";
-		
-		File testFile = new File("test.txt");
-		
+	public void testPlainReadWrite() {
 		try {
 			FileManager.saveFile(testFile, testData);
 			String read = FileManager.openFile(testFile, null);
 			Assert.assertEquals(testData, read);
 		} catch (IOException | InvalidPasswordException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
+			Assert.fail(e.getMessage());
+		}
+	}
+	
+	@Test
+	public void testEncryptedReadWrite() {
+		char[] pass = "VerySafeANDSoundPassWord123<><<--..,,".toCharArray();
+		try {
+			FileManager.saveFile(testFile, testData, pass);
+			String read = FileManager.openFile(testFile, pass);
+			Assert.assertEquals(testData, read);
+		} catch (IOException | InvalidPasswordException e) {
+			e.printStackTrace();
+			Assert.fail(e.getMessage());
 		}
 	}
 }