JAL-3130 adapted getdown src. attempt 2. first attempt failed due to cp'ed .git files
[jalview.git] / getdown / src / getdown / core / src / test / java / com / threerings / getdown / data / ClassPathTest.java
diff --git a/getdown/src/getdown/core/src/test/java/com/threerings/getdown/data/ClassPathTest.java b/getdown/src/getdown/core/src/test/java/com/threerings/getdown/data/ClassPathTest.java
new file mode 100644 (file)
index 0000000..5344f3b
--- /dev/null
@@ -0,0 +1,54 @@
+//
+// Getdown - application installer, patcher and launcher
+// Copyright (C) 2004-2018 Getdown authors
+// https://github.com/threerings/getdown/blob/master/LICENSE
+
+package com.threerings.getdown.data;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.LinkedHashSet;
+
+import org.junit.*;
+import org.junit.rules.TemporaryFolder;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link ClassPath}.
+ */
+public class ClassPathTest
+{
+    @Before public void createJarsAndSetupClassPath () throws IOException
+    {
+        _firstJar = _folder.newFile("a.jar");
+        _secondJar = _folder.newFile("b.jar");
+
+        LinkedHashSet<File> classPathEntries = new LinkedHashSet<File>();
+        classPathEntries.add(_firstJar);
+        classPathEntries.add(_secondJar);
+        _classPath = new ClassPath(classPathEntries);
+    }
+
+    @Test public void shouldCreateValidArgumentString ()
+    {
+        assertEquals(
+            _firstJar.getAbsolutePath() + File.pathSeparator + _secondJar.getAbsolutePath(),
+            _classPath.asArgumentString());
+    }
+
+    @Test public void shouldProvideJarUrls () throws MalformedURLException, URISyntaxException
+    {
+        URL[] actualUrls = _classPath.asUrls();
+        assertEquals(_firstJar, new File(actualUrls[0].toURI()));
+        assertEquals(_secondJar, new File(actualUrls[1].toURI()));
+    }
+
+    @Rule public TemporaryFolder _folder = new TemporaryFolder();
+
+    private File _firstJar, _secondJar;
+    private ClassPath _classPath;
+}