summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/test/com/earth2me
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-10-12 03:14:07 +0200
committersnowleo <schneeleo@gmail.com>2011-10-12 03:14:26 +0200
commitea192ddd6d5b538e0bd0f6f1721890eb3c25de30 (patch)
tree344d5ad4eec389eedc6a72dbfb1bdfba1047a447 /EssentialsUpdate/test/com/earth2me
parent1b34ed40736b03f440352f8193f24b6b0525868a (diff)
downloadEssentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar
Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.gz
Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.lz
Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.tar.xz
Essentials-ea192ddd6d5b538e0bd0f6f1721890eb3c25de30.zip
EssentialsUpdate WIP
Diffstat (limited to 'EssentialsUpdate/test/com/earth2me')
-rw-r--r--EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java27
-rw-r--r--EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java87
2 files changed, 114 insertions, 0 deletions
diff --git a/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java b/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java
new file mode 100644
index 000000000..a51f03bd7
--- /dev/null
+++ b/EssentialsUpdate/test/com/earth2me/essentials/update/UploadTest.java
@@ -0,0 +1,27 @@
+package com.earth2me.essentials.update;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import org.junit.Test;
+
+
+public class UploadTest extends TestCase
+{
+ @Test
+ public void testPastieUpload()
+ {
+ try
+ {
+ final PastieUpload pastie = new PastieUpload();
+ assertNotNull(pastie);
+ //final String url = pastie.send("test");
+ //System.out.println(url);
+ }
+ catch (IOException ex)
+ {
+ Logger.getLogger(UploadTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+}
diff --git a/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java b/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
new file mode 100644
index 000000000..901a8f9dc
--- /dev/null
+++ b/EssentialsUpdate/test/com/earth2me/essentials/update/VersionTest.java
@@ -0,0 +1,87 @@
+package com.earth2me.essentials.update;
+
+import com.earth2me.essentials.update.Version.Type;
+import java.util.TreeSet;
+import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+
+public class VersionTest extends TestCase
+{
+ @Test
+ public void testStable()
+ {
+ final Version instance = new Version("1.2.3");
+ assertEquals("Testing Major", 1, instance.getMajor());
+ assertEquals("Testing Minor", 2, instance.getMinor());
+ assertEquals("Testing Build", 3, instance.getBuild());
+ assertEquals("Testing Type", Type.STABLE, instance.getType());
+ }
+
+ @Test
+ public void testDev()
+ {
+ final Version instance = new Version("Dev2.3.4");
+ assertEquals("Testing Major", 2, instance.getMajor());
+ assertEquals("Testing Minor", 3, instance.getMinor());
+ assertEquals("Testing Build", 4, instance.getBuild());
+ assertEquals("Testing Type", Type.DEVELOPER, instance.getType());
+ }
+
+ @Test
+ public void testTeamCity()
+ {
+ final Version instance = new Version("Teamcity");
+ assertEquals("Testing Type", Type.DEVELOPER, instance.getType());
+ }
+
+ @Test
+ public void testPre()
+ {
+ final Version instance = new Version("Pre5.7.400.2");
+ assertEquals("Testing Major", 5, instance.getMajor());
+ assertEquals("Testing Minor", 7, instance.getMinor());
+ assertEquals("Testing Build", 400, instance.getBuild());
+ assertEquals("Testing Type", Type.PREVIEW, instance.getType());
+ }
+
+ @Test
+ public void testCompareTo()
+ {
+ Version a = new Version("1.1.1");
+ Version b = new Version("Dev1.1.2");
+ Version c = new Version("1.1.2");
+ Version d = new Version("1.2.0");
+ Version e = new Version("2.0.0");
+ Version f = new Version("Pre1.1.1.1");
+ Version g = new Version("Dev1.2.2");
+ assertTrue("Testing dev", a.compareTo(b) < 0);
+ assertTrue("Testing dev", b.compareTo(a) > 0);
+ assertTrue("Testing build", a.compareTo(c) < 0);
+ assertTrue("Testing build", c.compareTo(a) > 0);
+ assertTrue("Testing minor", a.compareTo(d) < 0);
+ assertTrue("Testing minor", d.compareTo(a) > 0);
+ assertTrue("Testing major", a.compareTo(e) < 0);
+ assertTrue("Testing major", e.compareTo(a) > 0);
+ assertTrue("Testing pre", f.compareTo(a) < 0);
+ assertTrue("Testing pre", a.compareTo(f) > 0);
+ assertTrue("Testing dev vs dev", b.compareTo(g) < 0);
+ assertTrue("Testing dev vs dev", g.compareTo(b) > 0);
+ final TreeSet<Version> set = new TreeSet<Version>();
+ set.add(a);
+ set.add(b);
+ set.add(c);
+ set.add(d);
+ set.add(e);
+ set.add(f);
+ set.add(g);
+ assertEquals("Testing sorting", f, set.pollFirst());
+ assertEquals("Testing sorting", a, set.pollFirst());
+ assertEquals("Testing sorting", c, set.pollFirst());
+ assertEquals("Testing sorting", d, set.pollFirst());
+ assertEquals("Testing sorting", e, set.pollFirst());
+ assertEquals("Testing sorting", b, set.pollFirst());
+ assertEquals("Testing sorting", g, set.pollFirst());
+ }
+}