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
1 //
2 // Getdown - application installer, patcher and launcher
3 // Copyright (C) 2004-2018 Getdown authors
4 // https://github.com/threerings/getdown/blob/master/LICENSE
5
6 package com.threerings.getdown.data;
7
8 import java.io.File;
9 import java.io.IOException;
10 import java.net.MalformedURLException;
11 import java.net.URISyntaxException;
12 import java.net.URL;
13 import java.util.LinkedHashSet;
14
15 import org.junit.*;
16 import org.junit.rules.TemporaryFolder;
17
18 import static org.junit.Assert.assertEquals;
19
20 /**
21  * Tests for {@link ClassPath}.
22  */
23 public class ClassPathTest
24 {
25     @Before public void createJarsAndSetupClassPath () throws IOException
26     {
27         _firstJar = _folder.newFile("a.jar");
28         _secondJar = _folder.newFile("b.jar");
29
30         LinkedHashSet<File> classPathEntries = new LinkedHashSet<File>();
31         classPathEntries.add(_firstJar);
32         classPathEntries.add(_secondJar);
33         _classPath = new ClassPath(classPathEntries);
34     }
35
36     @Test public void shouldCreateValidArgumentString ()
37     {
38         assertEquals(
39             _firstJar.getAbsolutePath() + File.pathSeparator + _secondJar.getAbsolutePath(),
40             _classPath.asArgumentString());
41     }
42
43     @Test public void shouldProvideJarUrls () throws MalformedURLException, URISyntaxException
44     {
45         URL[] actualUrls = _classPath.asUrls();
46         assertEquals(_firstJar, new File(actualUrls[0].toURI()));
47         assertEquals(_secondJar, new File(actualUrls[1].toURI()));
48     }
49
50     @Rule public TemporaryFolder _folder = new TemporaryFolder();
51
52     private File _firstJar, _secondJar;
53     private ClassPath _classPath;
54 }