aboutsummaryrefslogtreecommitdiff
path: root/subsonic-main/src/test/java/net/sourceforge/subsonic/domain
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-07-02 21:24:02 -0700
committerScott Jackson <daneren2005@gmail.com>2012-07-02 21:24:02 -0700
commita1a18f77a50804e0127dfa4b0f5240c49c541184 (patch)
tree19a38880afe505beddb5590379a8134d7730a277 /subsonic-main/src/test/java/net/sourceforge/subsonic/domain
parentb61d787706979e7e20f4c3c4f93c1f129d92273f (diff)
downloaddsub-a1a18f77a50804e0127dfa4b0f5240c49c541184.tar.gz
dsub-a1a18f77a50804e0127dfa4b0f5240c49c541184.tar.bz2
dsub-a1a18f77a50804e0127dfa4b0f5240c49c541184.zip
Initial Commit
Diffstat (limited to 'subsonic-main/src/test/java/net/sourceforge/subsonic/domain')
-rw-r--r--subsonic-main/src/test/java/net/sourceforge/subsonic/domain/CacheElementTestCase.java44
-rw-r--r--subsonic-main/src/test/java/net/sourceforge/subsonic/domain/MediaFileComparatorTestCase.java124
-rw-r--r--subsonic-main/src/test/java/net/sourceforge/subsonic/domain/PlayQueueTestCase.java311
-rw-r--r--subsonic-main/src/test/java/net/sourceforge/subsonic/domain/TranscodeSchemeTestCase.java43
-rw-r--r--subsonic-main/src/test/java/net/sourceforge/subsonic/domain/VersionTestCase.java70
5 files changed, 592 insertions, 0 deletions
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/CacheElementTestCase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/CacheElementTestCase.java
new file mode 100644
index 00000000..6c6e871a
--- /dev/null
+++ b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/CacheElementTestCase.java
@@ -0,0 +1,44 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package net.sourceforge.subsonic.domain;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test of {@link net.sourceforge.subsonic.domain.CacheElement}.
+ *
+ * @author Sindre Mehus
+ */
+public class CacheElementTestCase extends TestCase {
+
+ public void testCreateId() {
+
+ assertTrue(CacheElement.createId(1, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home") ==
+ CacheElement.createId(1, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home"));
+
+ assertTrue(CacheElement.createId(1, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home") !=
+ CacheElement.createId(2, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home"));
+
+ assertTrue(CacheElement.createId(237462763, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home") !=
+ CacheElement.createId(28374922, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home"));
+
+ assertTrue(CacheElement.createId(1, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home bla bla") !=
+ CacheElement.createId(1, "/Volumes/WD Passport/music/'Til Tuesday/Welcome Home"));
+ }
+} \ No newline at end of file
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/MediaFileComparatorTestCase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/MediaFileComparatorTestCase.java
new file mode 100644
index 00000000..6e1047f4
--- /dev/null
+++ b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/MediaFileComparatorTestCase.java
@@ -0,0 +1,124 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package net.sourceforge.subsonic.domain;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Sindre Mehus
+ * @version $Id$
+ */
+public class MediaFileComparatorTestCase extends TestCase {
+
+ private final MediaFileComparator comparator = new MediaFileComparator(true);
+
+ public void testCompareAlbums() throws Exception {
+
+ MediaFile albumA2012 = new MediaFile();
+ albumA2012.setMediaType(MediaFile.MediaType.ALBUM);
+ albumA2012.setPath("a");
+ albumA2012.setYear(2012);
+
+ MediaFile albumB2012 = new MediaFile();
+ albumB2012.setMediaType(MediaFile.MediaType.ALBUM);
+ albumB2012.setPath("b");
+ albumB2012.setYear(2012);
+
+ MediaFile album2013 = new MediaFile();
+ album2013.setMediaType(MediaFile.MediaType.ALBUM);
+ album2013.setPath("c");
+ album2013.setYear(2013);
+
+ MediaFile albumWithoutYear = new MediaFile();
+ albumWithoutYear.setMediaType(MediaFile.MediaType.ALBUM);
+ albumWithoutYear.setPath("c");
+
+ assertEquals(0, comparator.compare(albumWithoutYear, albumWithoutYear));
+ assertEquals(0, comparator.compare(albumA2012, albumA2012));
+
+ assertEquals(-1, comparator.compare(albumA2012, albumWithoutYear));
+ assertEquals(-1, comparator.compare(album2013, albumWithoutYear));
+ assertEquals(1, comparator.compare(album2013, albumA2012));
+
+ assertEquals(1, comparator.compare(albumWithoutYear, albumA2012));
+ assertEquals(1, comparator.compare(albumWithoutYear, album2013));
+ assertEquals(-1, comparator.compare(albumA2012, album2013));
+
+ assertEquals(-1, comparator.compare(albumA2012, albumB2012));
+ assertEquals(1, comparator.compare(albumB2012, albumA2012));
+ }
+
+ public void testCompareDiscNumbers() throws Exception {
+
+ MediaFile discXtrack1 = new MediaFile();
+ discXtrack1.setMediaType(MediaFile.MediaType.MUSIC);
+ discXtrack1.setPath("a");
+ discXtrack1.setTrackNumber(1);
+
+ MediaFile discXtrack2 = new MediaFile();
+ discXtrack2.setMediaType(MediaFile.MediaType.MUSIC);
+ discXtrack2.setPath("a");
+ discXtrack2.setTrackNumber(2);
+
+ MediaFile disc5track1 = new MediaFile();
+ disc5track1.setMediaType(MediaFile.MediaType.MUSIC);
+ disc5track1.setPath("a");
+ disc5track1.setDiscNumber(5);
+ disc5track1.setTrackNumber(1);
+
+ MediaFile disc5track2 = new MediaFile();
+ disc5track2.setMediaType(MediaFile.MediaType.MUSIC);
+ disc5track2.setPath("a");
+ disc5track2.setDiscNumber(5);
+ disc5track2.setTrackNumber(2);
+
+ MediaFile disc6track1 = new MediaFile();
+ disc6track1.setMediaType(MediaFile.MediaType.MUSIC);
+ disc6track1.setPath("a");
+ disc6track1.setDiscNumber(6);
+ disc6track1.setTrackNumber(1);
+
+ MediaFile disc6track2 = new MediaFile();
+ disc6track2.setMediaType(MediaFile.MediaType.MUSIC);
+ disc6track2.setPath("a");
+ disc6track2.setDiscNumber(6);
+ disc6track2.setTrackNumber(2);
+
+ assertEquals(0, comparator.compare(discXtrack1, discXtrack1));
+ assertEquals(0, comparator.compare(disc5track1, disc5track1));
+
+ assertEquals(-1, comparator.compare(discXtrack1, discXtrack2));
+ assertEquals(1, comparator.compare(discXtrack2, discXtrack1));
+
+ assertEquals(-1, comparator.compare(disc5track1, disc5track2));
+ assertEquals(1, comparator.compare(disc6track2, disc5track1));
+
+ assertEquals(-1, comparator.compare(disc5track1, disc6track1));
+ assertEquals(1, comparator.compare(disc6track1, disc5track1));
+
+ assertEquals(-1, comparator.compare(disc5track2, disc6track1));
+ assertEquals(1, comparator.compare(disc6track1, disc5track2));
+
+ assertEquals(-1, comparator.compare(discXtrack1, disc5track1));
+ assertEquals(1, comparator.compare(disc5track1, discXtrack1));
+
+ assertEquals(-1, comparator.compare(discXtrack1, disc5track2));
+ assertEquals(1, comparator.compare(disc5track2, discXtrack1));
+ }
+}
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/PlayQueueTestCase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/PlayQueueTestCase.java
new file mode 100644
index 00000000..07b4be57
--- /dev/null
+++ b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/PlayQueueTestCase.java
@@ -0,0 +1,311 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package net.sourceforge.subsonic.domain;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+import net.sourceforge.subsonic.domain.PlayQueue.SortOrder;
+import net.sourceforge.subsonic.domain.PlayQueue.Status;
+
+/**
+ * Unit test of {@link PlayQueue}.
+ *
+ * @author Sindre Mehus
+ */
+public class PlayQueueTestCase extends TestCase {
+
+ public void testEmpty() {
+ PlayQueue playQueue = new PlayQueue();
+ assertEquals(0, playQueue.size());
+ assertTrue(playQueue.isEmpty());
+ assertEquals(0, playQueue.getFiles().size());
+ assertNull(playQueue.getCurrentFile());
+ }
+
+ public void testStatus() throws Exception {
+ PlayQueue playQueue = new PlayQueue();
+ assertEquals(Status.PLAYING, playQueue.getStatus());
+
+ playQueue.setStatus(Status.STOPPED);
+ assertEquals(Status.STOPPED, playQueue.getStatus());
+
+ playQueue.addFiles(true, new TestMediaFile());
+ assertEquals(Status.PLAYING, playQueue.getStatus());
+
+ playQueue.clear();
+ assertEquals(Status.PLAYING, playQueue.getStatus());
+ }
+
+ public void testMoveUp() throws Exception {
+ PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.moveUp(0);
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C", "D");
+
+ playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.moveUp(9999);
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C", "D");
+
+ playQueue = createPlaylist(1, "A", "B", "C", "D");
+ playQueue.moveUp(1);
+ assertPlaylistEquals(playQueue, 0, "B", "A", "C", "D");
+
+ playQueue = createPlaylist(3, "A", "B", "C", "D");
+ playQueue.moveUp(3);
+ assertPlaylistEquals(playQueue, 2, "A", "B", "D", "C");
+ }
+
+ public void testMoveDown() throws Exception {
+ PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.moveDown(0);
+ assertPlaylistEquals(playQueue, 1, "B", "A", "C", "D");
+
+ playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.moveDown(9999);
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C", "D");
+
+ playQueue = createPlaylist(1, "A", "B", "C", "D");
+ playQueue.moveDown(1);
+ assertPlaylistEquals(playQueue, 2, "A", "C", "B", "D");
+
+ playQueue = createPlaylist(3, "A", "B", "C", "D");
+ playQueue.moveDown(3);
+ assertPlaylistEquals(playQueue, 3, "A", "B", "C", "D");
+ }
+
+ public void testRemove() throws Exception {
+ PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.removeFileAt(0);
+ assertPlaylistEquals(playQueue, 0, "B", "C", "D");
+
+ playQueue = createPlaylist(1, "A", "B", "C", "D");
+ playQueue.removeFileAt(0);
+ assertPlaylistEquals(playQueue, 0, "B", "C", "D");
+
+ playQueue = createPlaylist(0, "A", "B", "C", "D");
+ playQueue.removeFileAt(3);
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue = createPlaylist(1, "A", "B", "C", "D");
+ playQueue.removeFileAt(1);
+ assertPlaylistEquals(playQueue, 1, "A", "C", "D");
+
+ playQueue = createPlaylist(3, "A", "B", "C", "D");
+ playQueue.removeFileAt(3);
+ assertPlaylistEquals(playQueue, 2, "A", "B", "C");
+
+ playQueue = createPlaylist(0, "A");
+ playQueue.removeFileAt(0);
+ assertPlaylistEquals(playQueue, -1);
+ }
+
+ public void testNext() throws Exception {
+ PlayQueue playQueue = createPlaylist(0, "A", "B", "C");
+ assertFalse(playQueue.isRepeatEnabled());
+ playQueue.next();
+ assertPlaylistEquals(playQueue, 1, "A", "B", "C");
+ playQueue.next();
+ assertPlaylistEquals(playQueue, 2, "A", "B", "C");
+ playQueue.next();
+ assertPlaylistEquals(playQueue, -1, "A", "B", "C");
+
+ playQueue = createPlaylist(0, "A", "B", "C");
+ playQueue.setRepeatEnabled(true);
+ assertTrue(playQueue.isRepeatEnabled());
+ playQueue.next();
+ assertPlaylistEquals(playQueue, 1, "A", "B", "C");
+ playQueue.next();
+ assertPlaylistEquals(playQueue, 2, "A", "B", "C");
+ playQueue.next();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+ }
+
+ public void testPlayAfterEndReached() throws Exception {
+ PlayQueue playQueue = createPlaylist(2, "A", "B", "C");
+ playQueue.setStatus(Status.PLAYING);
+ playQueue.next();
+ assertNull(playQueue.getCurrentFile());
+ assertEquals(Status.STOPPED, playQueue.getStatus());
+
+ playQueue.setStatus(Status.PLAYING);
+ assertEquals(Status.PLAYING, playQueue.getStatus());
+ assertEquals(0, playQueue.getIndex());
+ assertEquals("A", playQueue.getCurrentFile().getName());
+ }
+
+ public void testAppend() throws Exception {
+ PlayQueue playQueue = createPlaylist(1, "A", "B", "C");
+
+ playQueue.addFiles(true, new TestMediaFile("D"));
+ assertPlaylistEquals(playQueue, 1, "A", "B", "C", "D");
+
+ playQueue.addFiles(false, new TestMediaFile("E"));
+ assertPlaylistEquals(playQueue, 0, "E");
+ }
+
+ public void testUndo() throws Exception {
+ PlayQueue playQueue = createPlaylist(0, "A", "B", "C");
+ playQueue.setIndex(2);
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue.removeFileAt(2);
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue.clear();
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue.addFiles(true, new TestMediaFile());
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue.moveDown(1);
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+
+ playQueue.moveUp(1);
+ playQueue.undo();
+ assertPlaylistEquals(playQueue, 0, "A", "B", "C");
+ }
+
+ public void testOrder() throws IOException {
+ PlayQueue playQueue = new PlayQueue();
+ playQueue.addFiles(true, new TestMediaFile(2, "Artist A", "Album B"));
+ playQueue.addFiles(true, new TestMediaFile(1, "Artist C", "Album C"));
+ playQueue.addFiles(true, new TestMediaFile(3, "Artist B", "Album A"));
+ playQueue.addFiles(true, new TestMediaFile(null, "Artist D", "Album D"));
+ playQueue.setIndex(2);
+ assertEquals("Error in sort.", new Integer(3), playQueue.getCurrentFile().getTrackNumber());
+
+ // Order by track.
+ playQueue.sort(SortOrder.TRACK);
+ assertEquals("Error in sort().", null, playQueue.getFile(0).getTrackNumber());
+ assertEquals("Error in sort().", new Integer(1), playQueue.getFile(1).getTrackNumber());
+ assertEquals("Error in sort().", new Integer(2), playQueue.getFile(2).getTrackNumber());
+ assertEquals("Error in sort().", new Integer(3), playQueue.getFile(3).getTrackNumber());
+ assertEquals("Error in sort().", new Integer(3), playQueue.getCurrentFile().getTrackNumber());
+
+ // Order by artist.
+ playQueue.sort(SortOrder.ARTIST);
+ assertEquals("Error in sort().", "Artist A", playQueue.getFile(0).getArtist());
+ assertEquals("Error in sort().", "Artist B", playQueue.getFile(1).getArtist());
+ assertEquals("Error in sort().", "Artist C", playQueue.getFile(2).getArtist());
+ assertEquals("Error in sort().", "Artist D", playQueue.getFile(3).getArtist());
+ assertEquals("Error in sort().", new Integer(3), playQueue.getCurrentFile().getTrackNumber());
+
+ // Order by album.
+ playQueue.sort(SortOrder.ALBUM);
+ assertEquals("Error in sort().", "Album A", playQueue.getFile(0).getAlbumName());
+ assertEquals("Error in sort().", "Album B", playQueue.getFile(1).getAlbumName());
+ assertEquals("Error in sort().", "Album C", playQueue.getFile(2).getAlbumName());
+ assertEquals("Error in sort().", "Album D", playQueue.getFile(3).getAlbumName());
+ assertEquals("Error in sort().", new Integer(3), playQueue.getCurrentFile().getTrackNumber());
+ }
+
+ private void assertPlaylistEquals(PlayQueue playQueue, int index, String... songs) {
+ assertEquals(songs.length, playQueue.size());
+ for (int i = 0; i < songs.length; i++) {
+ assertEquals(songs[i], playQueue.getFiles().get(i).getName());
+ }
+
+ if (index == -1) {
+ assertNull(playQueue.getCurrentFile());
+ } else {
+ assertEquals(songs[index], playQueue.getCurrentFile().getName());
+ }
+ }
+
+ private PlayQueue createPlaylist(int index, String... songs) throws Exception {
+ PlayQueue playQueue = new PlayQueue();
+ for (String song : songs) {
+ playQueue.addFiles(true, new TestMediaFile(song));
+ }
+ playQueue.setIndex(index);
+ return playQueue;
+ }
+
+ private static class TestMediaFile extends MediaFile {
+
+ private String name;
+ private Integer track;
+ private String album;
+ private String artist;
+
+ TestMediaFile() {
+ }
+
+ TestMediaFile(String name) {
+ this.name = name;
+ }
+
+ TestMediaFile(Integer track, String artist, String album) {
+ this.track = track;
+ this.album = album;
+ this.artist = artist;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean isFile() {
+ return true;
+ }
+
+ @Override
+ public Integer getTrackNumber() {
+ return track;
+ }
+
+ @Override
+ public String getArtist() {
+ return artist;
+ }
+
+ @Override
+ public String getAlbumName() {
+ return album;
+ }
+
+ @Override
+ public File getFile() {
+ return new File(name);
+ }
+
+ @Override
+ public boolean exists() {
+ return true;
+ }
+
+ @Override
+ public boolean isDirectory() {
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return this == o;
+ }
+ }
+} \ No newline at end of file
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/TranscodeSchemeTestCase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/TranscodeSchemeTestCase.java
new file mode 100644
index 00000000..634ac41c
--- /dev/null
+++ b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/TranscodeSchemeTestCase.java
@@ -0,0 +1,43 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package net.sourceforge.subsonic.domain;
+
+import junit.framework.TestCase;
+import static net.sourceforge.subsonic.domain.TranscodeScheme.*;
+
+/**
+ * Unit test of {@link TranscodeScheme}.
+ *
+ * @author Sindre Mehus
+ */
+public class TranscodeSchemeTestCase extends TestCase {
+
+ /**
+ * Tests {@link TranscodeScheme#strictest}.
+ */
+ public void testStrictest() {
+ assertSame("Error in strictest().", OFF, OFF.strictest(null));
+ assertSame("Error in strictest().", OFF, OFF.strictest(OFF));
+ assertSame("Error in strictest().", MAX_32, OFF.strictest(MAX_32));
+ assertSame("Error in strictest().", MAX_32, MAX_32.strictest(null));
+ assertSame("Error in strictest().", MAX_32, MAX_32.strictest(OFF));
+ assertSame("Error in strictest().", MAX_32, MAX_32.strictest(MAX_64));
+ assertSame("Error in strictest().", MAX_32, MAX_64.strictest(MAX_32));
+ }
+}
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/VersionTestCase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/VersionTestCase.java
new file mode 100644
index 00000000..79a8bfdf
--- /dev/null
+++ b/subsonic-main/src/test/java/net/sourceforge/subsonic/domain/VersionTestCase.java
@@ -0,0 +1,70 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package net.sourceforge.subsonic.domain;
+
+/**
+ * Unit test of {@link Version}.
+ * @author Sindre Mehus
+ */
+
+import junit.framework.*;
+
+public class VersionTestCase extends TestCase {
+
+ /**
+ * Tests that equals(), hashCode(), toString() and compareTo() works.
+ */
+ public void testVersion() {
+ doTestVersion("0.0", "0.1");
+ doTestVersion("1.5", "2.3");
+ doTestVersion("2.3", "2.34");
+
+ doTestVersion("1.5", "1.5.1");
+ doTestVersion("1.5.1", "1.5.2");
+ doTestVersion("1.5.2", "1.5.11");
+
+ doTestVersion("1.4", "1.5.beta1");
+ doTestVersion("1.4.1", "1.5.beta1");
+ doTestVersion("1.5.beta1", "1.5");
+ doTestVersion("1.5.beta1", "1.5.1");
+ doTestVersion("1.5.beta1", "1.6");
+ doTestVersion("1.5.beta1", "1.5.beta2");
+ doTestVersion("1.5.beta2", "1.5.beta11");
+ }
+
+ /**
+ * Tests that equals(), hashCode(), toString() and compareTo() works.
+ * @param v1 A lower version.
+ * @param v2 A higher version.
+ */
+ private void doTestVersion(String v1, String v2) {
+ Version ver1 = new Version(v1);
+ Version ver2 = new Version(v2);
+
+ assertEquals("Error in toString().", v1, ver1.toString());
+ assertEquals("Error in toString().", v2, ver2.toString());
+
+ assertEquals("Error in equals().", ver1, ver1);
+
+ assertEquals("Error in compareTo().", 0, ver1.compareTo(ver1));
+ assertEquals("Error in compareTo().", 0, ver2.compareTo(ver2));
+ assertTrue("Error in compareTo().", ver1.compareTo(ver2) < 0);
+ assertTrue("Error in compareTo().", ver2.compareTo(ver1) > 0);
+ }
+} \ No newline at end of file