summaryrefslogtreecommitdiffstats
path: root/MobiReader
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-06 15:46:52 +0200
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-06 15:46:52 +0200
commit1bdd410a39e7abec4c1691d721af864f2838c796 (patch)
treedb3e95c7ebc195da7d6cbf0d15e39092fef7a807 /MobiReader
parentc3df7b0c9778533c6fcbf98e28f215d0f3910ede (diff)
downloadmobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.gz
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.bz2
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.tar.xz
mobi_reader-1bdd410a39e7abec4c1691d721af864f2838c796.zip
Wrum, wrum, wrum. Some silly tests.
Diffstat (limited to 'MobiReader')
-rw-r--r--MobiReader/nbproject/project.properties44
-rw-r--r--MobiReader/test/tests/HeaderJUnitTest.java64
-rw-r--r--MobiReader/test/tests/UnzippingJUnitTest.java42
3 files changed, 144 insertions, 6 deletions
diff --git a/MobiReader/nbproject/project.properties b/MobiReader/nbproject/project.properties
index 0b86f59..0cfd8f9 100644
--- a/MobiReader/nbproject/project.properties
+++ b/MobiReader/nbproject/project.properties
@@ -30,6 +30,27 @@ dist.jar=${dist.dir}/MobiReader.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
+file.reference.antlr-2.7.7.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/antlr-2.7.7.jar
+file.reference.antlr-3.0.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/antlr-3.0.jar
+file.reference.asm-1.5.3.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/asm-1.5.3.jar
+file.reference.avalon-framework-4.1.3.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/avalon-framework-4.1.3.jar
+file.reference.backport-util-concurrent-3.0.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/backport-util-concurrent-3.0.jar
+file.reference.cglib-2.1_3.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/cglib-2.1_3.jar
+file.reference.commons-io-1.2.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/commons-io-1.2.jar
+file.reference.commons-io-1.3.1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/commons-io-1.3.1.jar
+file.reference.commons-logging-1.1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/commons-logging-1.1.jar
+file.reference.guava-14.0.1.jar=/home/att/studia/semestr4/Java/compression/guava-14.0.1.jar
+file.reference.limbo-1.1-20081112.085229-2.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/limbo-1.1-20081112.085229-2.jar
+file.reference.log4j-1.2.12.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/log4j-1.2.12.jar
+file.reference.logkit-1.0.1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/logkit-1.0.1.jar
+file.reference.pecia-1.0-20081112.075516-1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/pecia-1.0-20081112.075516-1.jar
+file.reference.preon-binding-1.0-SNAPSHOT.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/preon-binding-1.0-SNAPSHOT.jar
+file.reference.preon-bitbuffer-1.0-SNAPSHOT.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/preon-bitbuffer-1.0-SNAPSHOT.jar
+file.reference.preon-bitbuffer-1.0-SNAPSHOT.jar-1=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/preon-bitbuffer-1.0-SNAPSHOT.jar
+file.reference.servlet-api-2.3.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/servlet-api-2.3.jar
+file.reference.stax-api-1.0.1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/stax-api-1.0.1.jar
+file.reference.stringtemplate-3.0.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/stringtemplate-3.0.jar
+file.reference.wstx-asl-3.2.1.jar=/home/att/studia/semestr4/Java/resources/preon-1.0-SNAPSHOT/lib/ext/wstx-asl-3.2.1.jar
includes=**
# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects
jar.archive.disabled=true
@@ -38,7 +59,28 @@ javac.classpath=\
${javafx.runtime}/lib/jfxrt.jar:\
${javafx.runtime}/lib/deploy.jar:\
${javafx.runtime}/lib/javaws.jar:\
- ${javafx.runtime}/lib/plugin.jar
+ ${javafx.runtime}/lib/plugin.jar:\
+ ${file.reference.guava-14.0.1.jar}:\
+ ${file.reference.preon-binding-1.0-SNAPSHOT.jar}:\
+ ${file.reference.preon-bitbuffer-1.0-SNAPSHOT.jar}:\
+ ${file.reference.antlr-2.7.7.jar}:\
+ ${file.reference.antlr-3.0.jar}:\
+ ${file.reference.asm-1.5.3.jar}:\
+ ${file.reference.avalon-framework-4.1.3.jar}:\
+ ${file.reference.backport-util-concurrent-3.0.jar}:\
+ ${file.reference.cglib-2.1_3.jar}:\
+ ${file.reference.commons-io-1.2.jar}:\
+ ${file.reference.commons-io-1.3.1.jar}:\
+ ${file.reference.commons-logging-1.1.jar}:\
+ ${file.reference.limbo-1.1-20081112.085229-2.jar}:\
+ ${file.reference.log4j-1.2.12.jar}:\
+ ${file.reference.logkit-1.0.1.jar}:\
+ ${file.reference.pecia-1.0-20081112.075516-1.jar}:\
+ ${file.reference.preon-bitbuffer-1.0-SNAPSHOT.jar-1}:\
+ ${file.reference.servlet-api-2.3.jar}:\
+ ${file.reference.stax-api-1.0.1.jar}:\
+ ${file.reference.stringtemplate-3.0.jar}:\
+ ${file.reference.wstx-asl-3.2.1.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/MobiReader/test/tests/HeaderJUnitTest.java b/MobiReader/test/tests/HeaderJUnitTest.java
new file mode 100644
index 0000000..0ac36a7
--- /dev/null
+++ b/MobiReader/test/tests/HeaderJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tests;
+
+import java.io.File;
+import mobireader.Header;
+import mobireader.Mobi;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author att
+ */
+public class HeaderJUnitTest {
+
+ public HeaderJUnitTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+ // TODO add test methods here.
+ // The methods must be annotated with annotation @Test. For example:
+ //
+ @Test
+ public void testCaluculationOfHeaderSize() {
+ Mobi mobi = new Mobi("test");
+ String header_format = "32shhIIIIII4s4sIIH";
+ int correct_size = 78;
+ int calculated_size = mobi.calcsize(header_format);
+ assertEquals("Calculated size is incorrect", correct_size,
+ calculated_size);
+ }
+
+ @Test
+ public void testCreatingHeaderByPreon() {
+ Mobi mobi = new Mobi("test");
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+ File file = new File(path);
+ Header header = mobi.createHeaderBasedOn(file) ;
+ System.out.println(header.name);
+ assertTrue(header.name.length() != 0);
+
+ }
+} \ No newline at end of file
diff --git a/MobiReader/test/tests/UnzippingJUnitTest.java b/MobiReader/test/tests/UnzippingJUnitTest.java
index f9c18cd..ca817d2 100644
--- a/MobiReader/test/tests/UnzippingJUnitTest.java
+++ b/MobiReader/test/tests/UnzippingJUnitTest.java
@@ -1,12 +1,17 @@
package tests;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Scanner;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
-
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
public class UnzippingJUnitTest {
@@ -30,13 +35,40 @@ public class UnzippingJUnitTest {
}
@Test
- public void testBullshit() {
- assertEquals("10 equals 11", 10, 11);
+ public void testIfCompressionIsShorter() {
+ String text = "aaabbbaaacaccbbaaabbbaaacaccbbaaabbbaaacaccbb";
+ String compressed = unzipping.LZ77.compressStr(text);
+ assertTrue("compressed file is longer than before compression",
+ compressed.length() <= text.length());
+ }
+
+ @Test
+ public void testHowDecompressedMobiLooksLike() throws FileNotFoundException, IOException {
+
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+ byte compressed [] = Files.toByteArray(new File(path));
+ String compressedText = "";
+ for(int i = 0; i < 40000; i++)
+ {
+ compressedText += (char)compressed[i];
+ }
+ }
+
+
+ @Test
+ public void testHowCompressedMobiLooksLike() throws FileNotFoundException, IOException {
+ String path = "/home/att/studia/semestr4/Java/resources/test.mobi";
+
+
}
@Test
- public void testTruth() {
- assertEquals("10 does not equal 10", 10, 10);
+ public void testIfDecompressionInvertCompression() {
+ String text = "aaabbbaaacaccbbaaabbbaaacaccbbaaabbbaaacaccbb";
+ String compressed = unzipping.LZ77.compressStr(text);
+ String decompressed = unzipping.LZ77.decompressStr(compressed);
+ assertEquals("Decompression does not invert compression",
+ text, decompressed);
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example: