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