diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..84ed6ae --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..d3685f8 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..b061816 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..86993b2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ant/pom.xml b/ant/pom.xml index ea3dbf6..f03e2fe 100644 --- a/ant/pom.xml +++ b/ant/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.threerings.getdown + net.affliction getdown - 1.8.11-SNAPSHOT + 1.0.0 getdown-ant @@ -14,7 +14,7 @@ - com.threerings.getdown + net.affliction getdown-core ${project.version} diff --git a/core/pom.xml b/core/pom.xml index 37dd3d0..a65f62c 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.threerings.getdown + net.affliction getdown - 1.8.11-SNAPSHOT + 1.0.0 getdown-core diff --git a/core/src/it/java/com/threerings/getdown/tests/DigesterIT.java b/core/src/it/java/com/threerings/getdown/tests/DigesterIT.java deleted file mode 100644 index d2ddaf2..0000000 --- a/core/src/it/java/com/threerings/getdown/tests/DigesterIT.java +++ /dev/null @@ -1,54 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.tests; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; - -import com.threerings.getdown.tools.Digester; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -public class DigesterIT { - - @Test - public void testDigester () throws Exception { - Path appdir = Paths.get("src/it/resources/testapp"); - Digester.createDigests(appdir.toFile(), null, null, null); - - Path digest = appdir.resolve("digest.txt"); - List digestLines = Files.readAllLines(digest, StandardCharsets.UTF_8); - Files.delete(digest); - - Path digest2 = appdir.resolve("digest2.txt"); - List digest2Lines = Files.readAllLines(digest2, StandardCharsets.UTF_8); - Files.delete(digest2); - - assertEquals(Arrays.asList( - "getdown.txt = 9c9b2494929c99d44ae51034d59e1a1b", - "testapp.jar = 404dafa55e78b25ec0e3a936357b1883", - "funny%test dir/some=file.txt = d8e8fca2dc0f896fd7cb4cb0031ba249", - "crazyhashfile#txt = f29d23fd5ab1781bd8d0760b3a516f16", - "foo.jar = 46ca4cc9079d9d019bb30cd21ebbc1ec", - "script.sh = f66e8ea25598e67e99c47d9b0b2a2cdf", - "digest.txt = 11f9ba349cf9edacac4d72a3158447e5" - ), digestLines); - - assertEquals(Arrays.asList( - "getdown.txt = 1efecfae2a189002a6658f17d162b1922c7bde978944949276dc038a0df2461f", - "testapp.jar = c9cb1906afbf48f8654b416c3f831046bd3752a76137e5bf0a9af2f790bf48e0", - "funny%test dir/some=file.txt = f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2", - "crazyhashfile#txt = 6816889f922de38f145db215a28ad7c5e1badf7354b5cdab225a27486789fa3b", - "foo.jar = ea188b872e0496debcbe00aaadccccb12a8aa9b025bb62c130cd3d9b8540b062", - "script.sh = cca1c5c7628d9bf7533f655a9cfa6573d64afb8375f81960d1d832dc5135c988", - "digest2.txt = 41eacdabda8909bdbbf61e4f980867f4003c16a12f6770e6fc619b6af100e05b" - ), digest2Lines); - } -} diff --git a/core/src/it/resources/testapp/background.png b/core/src/it/resources/testapp/background.png deleted file mode 100644 index ff6a6ee..0000000 Binary files a/core/src/it/resources/testapp/background.png and /dev/null differ diff --git a/core/src/it/resources/testapp/crazyhashfile#txt b/core/src/it/resources/testapp/crazyhashfile#txt deleted file mode 100644 index 33bc373..0000000 --- a/core/src/it/resources/testapp/crazyhashfile#txt +++ /dev/null @@ -1 +0,0 @@ -Hello crazy world. diff --git a/core/src/it/resources/testapp/foo.jar b/core/src/it/resources/testapp/foo.jar deleted file mode 100644 index d040c01..0000000 Binary files a/core/src/it/resources/testapp/foo.jar and /dev/null differ diff --git a/core/src/it/resources/testapp/funny%test dir/some=file.txt b/core/src/it/resources/testapp/funny%test dir/some=file.txt deleted file mode 100644 index 9daeafb..0000000 --- a/core/src/it/resources/testapp/funny%test dir/some=file.txt +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/core/src/it/resources/testapp/getdown.txt b/core/src/it/resources/testapp/getdown.txt deleted file mode 100644 index ab0e473..0000000 --- a/core/src/it/resources/testapp/getdown.txt +++ /dev/null @@ -1,40 +0,0 @@ -# where our app is hosted on the internets -appbase = http://notused.com/testapp - -# the jar file that contains our code -code = testapp.jar - -# the main entry point of our app -class = com.threerings.testapp.TestApp - -# we pass the appdir to our app so that it can upgrade getdown -apparg = %APPDIR% - -# test the %env% mechanism -jvmarg = -Dusername=\%ENV.USER% - -# test various java_*** configs, they are not interesting for digester -java_local_dir = jre -java_max_version = 1089999 -java_min_version = [windows] 1080111 -java_min_version = [!windows] 1080192 -java_exact_version_required = [linux] true -java_location = [linux-amd64] /files/java/java_linux_64.zip -java_location = [linux-i386] /files/java/java_linux_32.zip -java_location = [mac] /files/java/java_mac_64.zip -java_location = [windows-amd64] /files/java/java_windows_64.zip -java_location = [windows-x86] /files/java/java_windows_32.zip - -strict_comments = true -resource = funny%test dir/some=file.txt -resource = crazyhashfile#txt -uresource = foo.jar -xresource = script.sh - -ui.name = Getdown Test App -ui.background_image = background.png -ui.progress = 17, 321, 458, 22 -ui.progress_bar = 336600 -ui.progress_text = FFFFFF -ui.status = 57, 245, 373, 68 -ui.status_text = 000000 diff --git a/core/src/it/resources/testapp/script.sh b/core/src/it/resources/testapp/script.sh deleted file mode 100644 index e3a1aba..0000000 --- a/core/src/it/resources/testapp/script.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -echo "Hello world!" diff --git a/core/src/it/resources/testapp/testapp.jar b/core/src/it/resources/testapp/testapp.jar deleted file mode 100644 index fe9de02..0000000 Binary files a/core/src/it/resources/testapp/testapp.jar and /dev/null differ diff --git a/core/src/main/java/com/threerings/getdown/data/Application.java b/core/src/main/java/com/threerings/getdown/data/Application.java index a0860c1..065bbe7 100644 --- a/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/core/src/main/java/com/threerings/getdown/data/Application.java @@ -1027,6 +1027,12 @@ public class Application // add the marker indicating the app is running in getdown args.add("-D" + Properties.GETDOWN + "=true"); + // forward the current JVM's language setting to the launched app + String userLanguage = System.getProperty("user.language"); + if (!StringUtil.isBlank(userLanguage)) { + args.add("-Duser.language=" + userLanguage); + } + // set the native library path if we have native resources // @TODO optional getdown.txt parameter to set addCurrentLibraryPath to true or false? ClassPath javaLibPath = PathBuilder.buildLibsPath(this, true); @@ -1715,7 +1721,15 @@ public class Application } for (String rsrc : rsrcs) { try { - list.add(createResource(rsrc, attrs)); + Resource res = createResource(rsrc, attrs); + // skip duplicate entries: a config publisher bug once stacked the code list 11x, + // and on Windows the duplicated -classpath blew past the 32,767-char + // CreateProcess limit (error=206); duplicates also multiply download/verify work + if (list.contains(res)) { + log.warning("Skipping duplicate resource '" + rsrc + "'."); + continue; + } + list.add(res); } catch (Exception e) { log.warning("Invalid resource '" + rsrc + "'. " + e); } diff --git a/core/src/test/java/com/threerings/getdown/cache/GarbageCollectorTest.java b/core/src/test/java/com/threerings/getdown/cache/GarbageCollectorTest.java deleted file mode 100644 index d34e584..0000000 --- a/core/src/test/java/com/threerings/getdown/cache/GarbageCollectorTest.java +++ /dev/null @@ -1,84 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.cache; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.TimeUnit; - -import org.junit.*; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.*; -import static org.junit.Assume.assumeTrue; - -/** - * Validates that cache garbage is collected and deleted correctly. - */ -@RunWith(Parameterized.class) -public class GarbageCollectorTest -{ - @Parameterized.Parameters(name = "{0}") - public static Collection data() { - return Arrays.asList(new Object[][] {{ ".jar" }, { ".zip" }}); - } - - @Parameterized.Parameter - public String extension; - - @Before public void setupFiles () throws IOException - { - _cachedFile = _folder.newFile("abc123" + extension); - _lastAccessedFile = _folder.newFile( - "abc123" + extension + ResourceCache.LAST_ACCESSED_FILE_SUFFIX); - } - - @Test public void shouldDeleteCacheEntryIfRetentionPeriodIsReached () - { - gcNow(); - assertFalse(_cachedFile.exists()); - assertFalse(_lastAccessedFile.exists()); - } - - @Test public void shouldDeleteCacheFolderIfFolderIsEmpty () - { - gcNow(); - assertFalse(_folder.getRoot().exists()); - } - - private void gcNow() { - GarbageCollector.collect(_folder.getRoot(), -1); - } - - @Test public void shouldKeepFilesInCacheIfRententionPeriodIsNotReached () - { - GarbageCollector.collect(_folder.getRoot(), TimeUnit.DAYS.toMillis(1)); - assertTrue(_cachedFile.exists()); - assertTrue(_lastAccessedFile.exists()); - } - - @Test public void shouldDeleteCachedFileIfLastAccessedFileIsMissing () - { - assumeTrue(_lastAccessedFile.delete()); - gcNow(); - assertFalse(_cachedFile.exists()); - } - - @Test public void shouldDeleteLastAccessedFileIfCachedFileIsMissing () - { - assumeTrue(_cachedFile.delete()); - gcNow(); - assertFalse(_lastAccessedFile.exists()); - } - - @Rule public final TemporaryFolder _folder = new TemporaryFolder(); - - private File _cachedFile; - private File _lastAccessedFile; -} diff --git a/core/src/test/java/com/threerings/getdown/cache/ResourceCacheTest.java b/core/src/test/java/com/threerings/getdown/cache/ResourceCacheTest.java deleted file mode 100644 index 54bde28..0000000 --- a/core/src/test/java/com/threerings/getdown/cache/ResourceCacheTest.java +++ /dev/null @@ -1,84 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.cache; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.concurrent.TimeUnit; - -import org.junit.*; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.*; - -/** - * Asserts the correct functionality of the {@link ResourceCache}. - */ -@RunWith(Parameterized.class) -public class ResourceCacheTest -{ - @Parameterized.Parameters(name = "{0}") - public static Collection data() { - return Arrays.asList(new Object[][] {{ ".jar" }, { ".zip" }}); - } - - @Parameterized.Parameter - public String extension; - - @Before public void setupCache () throws IOException { - _fileToCache = _folder.newFile("filetocache" + extension); - _cache = new ResourceCache(_folder.newFolder(".cache")); - } - - @Test public void shouldCacheFile () throws IOException - { - assertEquals("abc123" + extension, cacheFile().getName()); - } - - private File cacheFile() throws IOException - { - return _cache.cacheFile(_fileToCache, "abc123", "abc123"); - } - - @Test public void shouldTrackFileUsage () throws IOException - { - String name = "abc123" + extension + ResourceCache.LAST_ACCESSED_FILE_SUFFIX; - File lastAccessedFile = new File(cacheFile().getParentFile(), name); - assertTrue(lastAccessedFile.exists()); - } - - @Test public void shouldNotCacheTheSameFile () throws Exception - { - File cachedFile = cacheFile(); - cachedFile.setLastModified(YESTERDAY); - long expectedLastModified = cachedFile.lastModified(); - // caching it another time - File sameCachedFile = cacheFile(); - assertEquals(expectedLastModified, sameCachedFile.lastModified()); - } - - @Test public void shouldRememberWhenFileWasRequested () throws Exception - { - File cachedFile = cacheFile(); - String name = cachedFile.getName() + ResourceCache.LAST_ACCESSED_FILE_SUFFIX; - File lastAccessedFile = new File(cachedFile.getParentFile(), name); - lastAccessedFile.setLastModified(YESTERDAY); - long lastAccessed = lastAccessedFile.lastModified(); - // caching it another time - cacheFile(); - assertTrue(lastAccessedFile.lastModified() > lastAccessed); - } - - @Rule public final TemporaryFolder _folder = new TemporaryFolder(); - - private File _fileToCache; - private ResourceCache _cache; - - private static final long YESTERDAY = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1); -} diff --git a/core/src/test/java/com/threerings/getdown/data/ApplicationTest.java b/core/src/test/java/com/threerings/getdown/data/ApplicationTest.java deleted file mode 100644 index 65960b6..0000000 --- a/core/src/test/java/com/threerings/getdown/data/ApplicationTest.java +++ /dev/null @@ -1,75 +0,0 @@ -// -// 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.IOException; -import java.io.StringReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.junit.*; -import static org.junit.Assert.*; - -import com.threerings.getdown.util.Config; - -public class ApplicationTest { - - Application createApp () { - List notes = new ArrayList<>(); - EnvConfig env = EnvConfig.create(new String[0], notes); - EnvConfigTest.checkNoNotes(notes); - return new Application(env); - } - - @Test public void testBaseConfig () throws Exception { - Application app = createApp(); - URL appbase = new URL("https://test.com/foo/bar/"); - Config config = new Config(Config.parseData(toReader( - "appbase", appbase.toString() - ), Config.createOpts(true))); - app.initBase(config); - - assertEquals(appbase, app.getRemoteURL("")); - } - - @Test public void testVersionedBase () throws Exception { - Application app = createApp(); - String rootAppbase = "https://test.com/foo/bar/"; - Config config = new Config(Config.parseData(toReader( - "appbase", rootAppbase + "%VERSION%", - "version", "42" - ), Config.createOpts(true))); - app.initBase(config); - - assertEquals(new URL(rootAppbase + "42/"), app.getRemoteURL("")); - } - - @Test public void testEnvVarBase () throws Exception { - // fiddling to make test work on Windows or Unix - String evar = System.getenv("USER") == null ? "USERNAME" : "USER"; - Application app = createApp(); - String rootAppbase = "https://test.com/foo/%ENV." + evar + "%/"; - Config config = new Config(Config.parseData(toReader( - "appbase", rootAppbase + "%VERSION%", - "version", "42" - ), Config.createOpts(true))); - app.initBase(config); - - String expectAppbase = "https://test.com/foo/" + System.getenv(evar) + "/42/"; - assertEquals(new URL(expectAppbase), app.getRemoteURL("")); - } - - protected static StringReader toReader (String... pairs) - { - StringBuilder builder = new StringBuilder(); - for (int ii = 0; ii < pairs.length; ii += 2) { - builder.append(pairs[ii]).append("=").append(pairs[ii+1]).append("\n"); - } - return new StringReader(builder.toString()); - } - -} diff --git a/core/src/test/java/com/threerings/getdown/data/ClassPathTest.java b/core/src/test/java/com/threerings/getdown/data/ClassPathTest.java deleted file mode 100644 index f9b27ee..0000000 --- a/core/src/test/java/com/threerings/getdown/data/ClassPathTest.java +++ /dev/null @@ -1,54 +0,0 @@ -// -// 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 classPathEntries = new LinkedHashSet<>(); - classPathEntries.add(_firstJar); - classPathEntries.add(_secondJar); - _classPath = new ClassPath(classPathEntries); - } - - @Test public void shouldCreateValidArgumentString () - { - assertEquals( - "a.jar:b.jar", - _classPath.asArgumentString(_folder.getRoot())); - } - - @Test public void shouldProvideJarUrls () throws URISyntaxException - { - URL[] actualUrls = _classPath.asUrls(); - assertEquals(_firstJar, new File(actualUrls[0].toURI())); - assertEquals(_secondJar, new File(actualUrls[1].toURI())); - } - - @Rule public final TemporaryFolder _folder = new TemporaryFolder(); - - private File _firstJar, _secondJar; - private ClassPath _classPath; -} diff --git a/core/src/test/java/com/threerings/getdown/data/EnvConfigTest.java b/core/src/test/java/com/threerings/getdown/data/EnvConfigTest.java deleted file mode 100644 index 1900883..0000000 --- a/core/src/test/java/com/threerings/getdown/data/EnvConfigTest.java +++ /dev/null @@ -1,142 +0,0 @@ -// -// 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.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.io.File; - -import org.junit.*; -import static org.junit.Assert.*; - -public class EnvConfigTest { - - static final String CWD = System.getProperty("user.dir"); - static final String TESTID = "testid"; - static final String TESTBASE = "https://test.com/test"; - - private void debugNotes (List notes) { - for (EnvConfig.Note note : notes) { - System.out.println(note.message); - } - } - - static void checkNoNotes (List notes) { - StringBuilder msg = new StringBuilder(); - for (EnvConfig.Note note : notes) { - if (note.level != EnvConfig.Note.Level.INFO) { - msg.append("\n").append(note.message); - } - } - if (msg.length() > 0) { - fail("Unexpected notes:" + msg); - } - } - private void checkDir (EnvConfig cfg) { - assertTrue(cfg != null); - assertEquals(new File(CWD), cfg.appDir); - } - private void checkNoAppId (EnvConfig cfg) { - assertNull(cfg.appId); - } - private void checkAppId (EnvConfig cfg, String appId) { - assertEquals(appId, cfg.appId); - } - private void checkAppBase (EnvConfig cfg, String appBase) { - assertEquals(appBase, cfg.appBase); - } - private void checkNoAppBase (EnvConfig cfg) { - assertNull(cfg.appBase); - } - private void checkNoAppArgs (EnvConfig cfg) { - assertTrue(cfg.appArgs.isEmpty()); - } - private void checkAppArgs (EnvConfig cfg, String... args) { - assertEquals(Arrays.asList(args), cfg.appArgs); - } - - @Test public void testArgvDir () { - List notes = new ArrayList<>(); - String[] args = { CWD }; - EnvConfig cfg = EnvConfig.create(args, notes); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkNoAppId(cfg); - checkNoAppBase(cfg); - checkNoAppArgs(cfg); - } - - @Test public void testArgvDirId () { - List notes = new ArrayList<>(); - String[] args = { CWD, TESTID }; - EnvConfig cfg = EnvConfig.create(args, notes); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkAppId(cfg, TESTID); - checkNoAppBase(cfg); - checkNoAppArgs(cfg); - } - - @Test public void testArgvDirArgs () { - List notes = new ArrayList<>(); - String[] args = { CWD, "", "one", "two" }; - EnvConfig cfg = EnvConfig.create(args, notes); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkNoAppId(cfg); - checkNoAppBase(cfg); - checkAppArgs(cfg, "one", "two"); - } - - @Test public void testArgvDirIdArgs () { - List notes = new ArrayList<>(); - String[] args = { CWD, TESTID, "one", "two" }; - EnvConfig cfg = EnvConfig.create(args, notes); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkAppId(cfg, TESTID); - checkNoAppBase(cfg); - checkAppArgs(cfg, "one", "two"); - } - - private EnvConfig sysPropsConfig (List notes, String... keyVals) { - for (int ii = 0; ii < keyVals.length; ii += 2) { - System.setProperty(keyVals[ii], keyVals[ii+1]); - } - EnvConfig cfg = EnvConfig.create(new String[0], notes); - for (int ii = 0; ii < keyVals.length; ii += 2) { - System.clearProperty(keyVals[ii]); - } - return cfg; - } - - @Test public void testSysPropsDir () { - List notes = new ArrayList<>(); - EnvConfig cfg = sysPropsConfig(notes, "appdir", CWD); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkNoAppId(cfg); - checkNoAppBase(cfg); - checkNoAppArgs(cfg); - } - - @Test public void testSysPropsDirIdBase () { - List notes = new ArrayList<>(); - EnvConfig cfg = sysPropsConfig(notes, "appdir", CWD, "appid", TESTID, "appbase", TESTBASE); - // debugNotes(notes); - checkNoNotes(notes); - checkDir(cfg); - checkAppId(cfg, TESTID); - checkAppBase(cfg, TESTBASE); - checkNoAppArgs(cfg); - } -} diff --git a/core/src/test/java/com/threerings/getdown/data/PathBuilderTest.java b/core/src/test/java/com/threerings/getdown/data/PathBuilderTest.java deleted file mode 100644 index 5df18eb..0000000 --- a/core/src/test/java/com/threerings/getdown/data/PathBuilderTest.java +++ /dev/null @@ -1,58 +0,0 @@ -// -// 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.util.Arrays; - -import org.junit.*; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; - -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class PathBuilderTest -{ - @Before public void setupFilesAndResources () throws IOException - { - _firstJarFile = _appdir.newFile("a.jar"); - _secondJarFile = _appdir.newFile("b.jar"); - - when(_firstJar.getFinalTarget()).thenReturn(_firstJarFile); - when(_secondJar.getFinalTarget()).thenReturn(_secondJarFile); - when(_application.getActiveCodeResources()).thenReturn(Arrays.asList(_firstJar, _secondJar)); - when(_application.getAppDir()).thenReturn(_appdir.getRoot()); - } - - @Test public void shouldBuildDefaultClassPath () throws IOException - { - ClassPath classPath = PathBuilder.buildDefaultClassPath(_application); - assertEquals("a.jar:b.jar", classPath.asArgumentString(_appdir.getRoot())); - } - - @Test public void shouldBuildCachedClassPath () throws IOException - { - when(_application.getDigest(_firstJar)).thenReturn("first"); - when(_application.getDigest(_secondJar)).thenReturn("second"); - when(_application.getCodeCacheRetentionDays()).thenReturn(1); - - ClassPath classPath = PathBuilder.buildCachedClassPath(_application); - assertEquals(".cache/fi/first.jar:.cache/se/second.jar", classPath.asArgumentString(_appdir.getRoot())); - } - - @Mock protected Application _application; - @Mock protected Resource _firstJar; - @Mock protected Resource _secondJar; - - protected File _firstJarFile, _secondJarFile; - - @Rule public final TemporaryFolder _appdir = new TemporaryFolder(); -} diff --git a/core/src/test/java/com/threerings/getdown/data/SysPropsTest.java b/core/src/test/java/com/threerings/getdown/data/SysPropsTest.java deleted file mode 100644 index 042a13f..0000000 --- a/core/src/test/java/com/threerings/getdown/data/SysPropsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -// -// 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 org.junit.*; -import static org.junit.Assert.*; - -public class SysPropsTest { - - @After public void clearProps () { - System.clearProperty("delay"); - System.clearProperty("appbase_domain"); - System.clearProperty("appbase_override"); - } - - private static final String[] APPBASES = { - "http://foobar.com/myapp", - "https://foobar.com/myapp", - "http://foobar.com:8080/myapp", - "https://foobar.com:8080/myapp" - }; - - @Test public void testStartDelay () { - - assertEquals(0, SysProps.startDelay()); - - System.setProperty("delay", "x"); - assertEquals(0, SysProps.startDelay()); - - System.setProperty("delay", "-7"); - assertEquals(0, SysProps.startDelay()); - - System.setProperty("delay", "7"); - assertEquals(7, SysProps.startDelay()); - - System.setProperty("delay", "1440"); - assertEquals(1440, SysProps.startDelay()); - - System.setProperty("delay", "1441"); - assertEquals(1440, SysProps.startDelay()); - } - - @Test public void testAppbaseDomain () { - System.setProperty("appbase_domain", "https://barbaz.com"); - for (String appbase : APPBASES) { - assertEquals("https://barbaz.com/myapp", SysProps.overrideAppbase(appbase)); - } - System.setProperty("appbase_domain", "http://barbaz.com"); - for (String appbase : APPBASES) { - assertEquals("http://barbaz.com/myapp", SysProps.overrideAppbase(appbase)); - } - } - - @Test public void testAppbaseOverride () { - System.setProperty("appbase_override", "https://barbaz.com/newapp"); - for (String appbase : APPBASES) { - assertEquals("https://barbaz.com/newapp", SysProps.overrideAppbase(appbase)); - } - } -} diff --git a/core/src/test/java/com/threerings/getdown/util/ColorTest.java b/core/src/test/java/com/threerings/getdown/util/ColorTest.java deleted file mode 100644 index 7aa48ee..0000000 --- a/core/src/test/java/com/threerings/getdown/util/ColorTest.java +++ /dev/null @@ -1,23 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -/** - * Tests {@link Color}. - */ -public class ColorTest -{ - @Test - public void testBrightness() { - assertEquals(0, Color.brightness(0xFF000000), 0.0000001); - assertEquals(1, Color.brightness(0xFFFFFFFF), 0.0000001); - assertEquals(0.0117647, Color.brightness(0xFF010203), 0.0000001); - assertEquals(1, Color.brightness(0xFF00FFC8), 0.0000001); - } -} diff --git a/core/src/test/java/com/threerings/getdown/util/ConfigTest.java b/core/src/test/java/com/threerings/getdown/util/ConfigTest.java deleted file mode 100644 index 911191f..0000000 --- a/core/src/test/java/com/threerings/getdown/util/ConfigTest.java +++ /dev/null @@ -1,171 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import java.io.IOException; -import java.io.StringReader; -import java.util.List; -import java.util.Random; - -import org.junit.*; -import static org.junit.Assert.*; - -/** - * Tests {@link Config}. - */ -public class ConfigTest -{ - public static class Pair { - public final String key; - public final String value; - public Pair (String key, String value) { - this.key = key; - this.value = value; - } - } - - public static final Pair[] SIMPLE_PAIRS = { - new Pair("one", "two"), - new Pair("three", "four"), - new Pair("five", "six"), - new Pair("seven", "eight"), - new Pair("nine", "ten"), - }; - - @Test public void testSimplePairs () throws IOException - { - List pairs = Config.parsePairs( - toReader(SIMPLE_PAIRS), Config.createOpts(true)); - for (int ii = 0; ii < SIMPLE_PAIRS.length; ii++) { - assertEquals(SIMPLE_PAIRS[ii].key, pairs.get(ii)[0]); - assertEquals(SIMPLE_PAIRS[ii].value, pairs.get(ii)[1]); - } - } - - @Test public void testQualifiedPairs () throws IOException - { - Pair linux = new Pair("one", "[linux] two"); - Pair mac = new Pair("three", "[mac os x] four"); - Pair linuxAndMac = new Pair("five", "[linux, mac os x] six"); - Pair linux64 = new Pair("seven", "[linux-x86_64] eight"); - Pair linux64s = new Pair("nine", "[linux-x86_64, linux-amd64] ten"); - Pair mac64 = new Pair("eleven", "[mac os x-x86_64] twelve"); - Pair win64 = new Pair("thirteen", "[windows-x86_64] fourteen"); - Pair notWin = new Pair("fifteen", "[!windows] sixteen"); - Pair[] pairs = { linux, mac, linuxAndMac, linux64, linux64s, mac64, win64, notWin }; - - Config.ParseOpts opts = Config.createOpts(false); - opts.osname = "linux"; - opts.osarch = "i386"; - List parsed = Config.parsePairs(toReader(pairs), opts); - assertTrue(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertTrue(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertFalse(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertTrue(exists(parsed, notWin.key)); - - opts.osarch = "x86_64"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertTrue(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertTrue(exists(parsed, linuxAndMac.key)); - assertTrue(exists(parsed, linux64.key)); - assertTrue(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertTrue(exists(parsed, notWin.key)); - - opts.osarch = "amd64"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertTrue(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertTrue(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertTrue(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertTrue(exists(parsed, notWin.key)); - - opts.osname = "mac os x"; - opts.osarch = "x86_64"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertFalse(exists(parsed, linux.key)); - assertTrue(exists(parsed, mac.key)); - assertTrue(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertFalse(exists(parsed, linux64s.key)); - assertTrue(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertTrue(exists(parsed, notWin.key)); - - opts.osname = "windows"; - opts.osarch = "i386"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertFalse(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertFalse(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertFalse(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertFalse(exists(parsed, notWin.key)); - - opts.osarch = "x86_64"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertFalse(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertFalse(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertFalse(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertTrue(exists(parsed, win64.key)); - assertFalse(exists(parsed, notWin.key)); - - opts.osarch = "amd64"; - parsed = Config.parsePairs(toReader(pairs), opts); - assertFalse(exists(parsed, linux.key)); - assertFalse(exists(parsed, mac.key)); - assertFalse(exists(parsed, linuxAndMac.key)); - assertFalse(exists(parsed, linux64.key)); - assertFalse(exists(parsed, linux64s.key)); - assertFalse(exists(parsed, mac64.key)); - assertFalse(exists(parsed, win64.key)); - assertFalse(exists(parsed, notWin.key)); - } - - protected static boolean exists (List pairs, String key) - { - for (String[] pair : pairs) { - if (pair[0].equals(key)) { - return true; - } - } - return false; - } - - protected static StringReader toReader (Pair[] pairs) - { - StringBuilder builder = new StringBuilder(); - for (Pair pair : pairs) { - // throw some whitespace in to ensure it's trimmed - builder.append(whitespace()).append(pair.key). - append(whitespace()).append("="). - append(whitespace()).append(pair.value). - append(whitespace()).append("\n"); - } - return new StringReader(builder.toString()); - } - - protected static String whitespace () - { - return _rando.nextBoolean() ? " " : ""; - } - - protected static final Random _rando = new Random(); -} diff --git a/core/src/test/java/com/threerings/getdown/util/FileUtilTest.java b/core/src/test/java/com/threerings/getdown/util/FileUtilTest.java deleted file mode 100644 index 41de5ac..0000000 --- a/core/src/test/java/com/threerings/getdown/util/FileUtilTest.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import java.io.File; -import java.io.IOException; -import java.io.StringReader; -import java.util.List; - -import org.junit.*; -import org.junit.rules.TemporaryFolder; - -import static org.junit.Assert.*; - -/** - * Tests {@link FileUtil}. - */ -public class FileUtilTest -{ - @Test public void testReadLines () throws IOException - { - String data = "This is a test\nof a file with\na few lines\n"; - List lines = FileUtil.readLines(new StringReader(data)); - String[] linesBySplit = data.split("\n"); - assertEquals(linesBySplit.length, lines.size()); - for (int ii = 0; ii < lines.size(); ii++) { - assertEquals(linesBySplit[ii], lines.get(ii)); - } - } - - @Test public void shouldCopyFile () throws IOException - { - File source = _folder.newFile("source.txt"); - File target = new File(_folder.getRoot(), "target.txt"); - assertFalse(target.exists()); - FileUtil.copy(source, target); - assertTrue(target.exists()); - } - - @Test public void shouldRecursivelyWalkOverFilesAndFolders () throws IOException - { - _folder.newFile("a.txt"); - new File(_folder.newFolder("b"), "b.txt").createNewFile(); - - class CountingVisitor implements FileUtil.Visitor { - int fileCount = 0; - @Override public void visit(File file) { - fileCount++; - } - } - CountingVisitor visitor = new CountingVisitor(); - FileUtil.walkTree(_folder.getRoot(), visitor); - assertEquals(3, visitor.fileCount); - } - - @Rule public final TemporaryFolder _folder = new TemporaryFolder(); -} diff --git a/core/src/test/java/com/threerings/getdown/util/HostWhitelistTest.java b/core/src/test/java/com/threerings/getdown/util/HostWhitelistTest.java deleted file mode 100644 index 703afef..0000000 --- a/core/src/test/java/com/threerings/getdown/util/HostWhitelistTest.java +++ /dev/null @@ -1,159 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import static org.junit.Assert.assertEquals; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; - -/** - * Tests {@link HostWhitelist}. - */ -public class HostWhitelistTest -{ - @Test - public void testVerify () throws MalformedURLException - { - checkCanVerify("foo.com", "http://foo.com", true); - checkCanVerify("foo.com", "http://foo.com/", true); - checkCanVerify("foo.com", "http://foo.com/x/y/z", true); - checkCanVerify("foo.com", "http://www.foo.com", false); - checkCanVerify("foo.com", "http://www.foo.com/", false); - checkCanVerify("foo.com", "http://www.foo.com/x/y/z", false); - checkCanVerify("foo.com", "http://a.b.foo.com", false); - checkCanVerify("foo.com", "http://a.b.foo.com/", false); - checkCanVerify("foo.com", "http://a.b.foo.com/x/y/z", false); - checkCanVerify("foo.com", "http://oo.com", false); - checkCanVerify("foo.com", "http://f.oo.com", false); - checkCanVerify("foo.com", "http://a.f.oo.com", false); - - checkCanVerify("*.foo.com", "http://foo.com", false); - checkCanVerify("*.foo.com", "http://foo.com/", false); - checkCanVerify("*.foo.com", "http://foo.com/x/y/z", false); - checkCanVerify("*.foo.com", "http://www.foo.com", true); - checkCanVerify("*.foo.com", "http://www.foo.com/", true); - checkCanVerify("*.foo.com", "http://www.foo.com/x/y/z", true); - checkCanVerify("*.foo.com", "http://a.b.foo.com", true); - checkCanVerify("*.foo.com", "http://a.b.foo.com/", true); - checkCanVerify("*.foo.com", "http://a.b.foo.com/x/y/z", true); - checkCanVerify("*.foo.com", "http://oo.com", false); - checkCanVerify("*.foo.com", "http://f.oo.com", false); - checkCanVerify("*.foo.com", "http://a.f.oo.com", false); - - checkCanVerify("*.com", "http://foo.com", true); - checkCanVerify("*.com", "http://foo.com/", true); - checkCanVerify("*.com", "http://foo.com/x/y/z", true); - checkCanVerify("*.com", "http://www.foo.com", true); - checkCanVerify("*.com", "http://www.foo.com/", true); - checkCanVerify("*.com", "http://www.foo.com/x/y/z", true); - checkCanVerify("*.com", "http://a.b.foo.com", true); - checkCanVerify("*.com", "http://a.b.foo.com/", true); - checkCanVerify("*.com", "http://a.b.foo.com/x/y/z", true); - checkCanVerify("*.com", "http://oo.com", true); - checkCanVerify("*.com", "http://f.oo.com", true); - checkCanVerify("*.com", "http://a.f.oo.com", true); - - checkCanVerify("*.net", "http://foo.com", false); - checkCanVerify("*.net", "http://foo.com/", false); - checkCanVerify("*.net", "http://foo.com/x/y/z", false); - checkCanVerify("*.net", "http://www.foo.com", false); - checkCanVerify("*.net", "http://www.foo.com/", false); - checkCanVerify("*.net", "http://www.foo.com/x/y/z", false); - checkCanVerify("*.net", "http://a.b.foo.com", false); - checkCanVerify("*.net", "http://a.b.foo.com/", false); - checkCanVerify("*.net", "http://a.b.foo.com/x/y/z", false); - checkCanVerify("*.net", "http://oo.com", false); - checkCanVerify("*.net", "http://f.oo.com", false); - checkCanVerify("*.net", "http://a.f.oo.com", false); - - checkCanVerify("www.*.com", "http://foo.com", false); - checkCanVerify("www.*.com", "http://foo.com/", false); - checkCanVerify("www.*.com", "http://foo.com/x/y/z", false); - checkCanVerify("www.*.com", "http://www.foo.com", true); - checkCanVerify("www.*.com", "http://www.foo.com/", true); - checkCanVerify("www.*.com", "http://www.foo.com/x/y/z", true); - checkCanVerify("www.*.com", "http://a.b.foo.com", false); - checkCanVerify("www.*.com", "http://a.b.foo.com/", false); - checkCanVerify("www.*.com", "http://a.b.foo.com/x/y/z", false); - checkCanVerify("www.*.com", "http://oo.com", false); - checkCanVerify("www.*.com", "http://f.oo.com", false); - checkCanVerify("www.*.com", "http://a.f.oo.com", false); - checkCanVerify("www.*.com", "http://www.a.f.oo.com", true); - - checkCanVerify("foo.*", "http://foo.com", true); - checkCanVerify("foo.*", "http://foo.com/", true); - checkCanVerify("foo.*", "http://foo.com/x/y/z", true); - checkCanVerify("foo.*", "http://www.foo.com", false); - checkCanVerify("foo.*", "http://www.foo.com/", false); - checkCanVerify("foo.*", "http://www.foo.com/x/y/z", false); - checkCanVerify("foo.*", "http://a.b.foo.com", false); - checkCanVerify("foo.*", "http://a.b.foo.com/", false); - checkCanVerify("foo.*", "http://a.b.foo.com/x/y/z", false); - checkCanVerify("foo.*", "http://oo.com", false); - checkCanVerify("foo.*", "http://f.oo.com", false); - checkCanVerify("foo.*", "http://a.f.oo.com", false); - - checkCanVerify("*.foo.*", "http://foo.com", false); - checkCanVerify("*.foo.*", "http://foo.com/", false); - checkCanVerify("*.foo.*", "http://foo.com/x/y/z", false); - checkCanVerify("*.foo.*", "http://www.foo.com", true); - checkCanVerify("*.foo.*", "http://www.foo.com/", true); - checkCanVerify("*.foo.*", "http://www.foo.com/x/y/z", true); - checkCanVerify("*.foo.*", "http://a.b.foo.com", true); - checkCanVerify("*.foo.*", "http://a.b.foo.com/", true); - checkCanVerify("*.foo.*", "http://a.b.foo.com/x/y/z", true); - checkCanVerify("*.foo.*", "http://oo.com", false); - checkCanVerify("*.foo.*", "http://f.oo.com", false); - checkCanVerify("*.foo.*", "http://a.f.oo.com", false); - - checkCanVerify("127.0.0.1", "http://127.0.0.1", true); - checkCanVerify("127.0.0.1", "http://127.0.0.1/", true); - checkCanVerify("127.0.0.1", "http://127.0.0.1/x/y/z", true); - checkCanVerify("*.0.0.1", "http://127.0.0.1/abc", true); - checkCanVerify("127.*.0.1", "http://127.0.0.1/abc", true); - checkCanVerify("127.0.*.1", "http://127.0.0.1/abc", true); - checkCanVerify("127.0.0.*", "http://127.0.0.1/abc", true); - checkCanVerify("127.*.1", "http://127.0.0.1/abc", true); - checkCanVerify("*.0.1", "http://127.0.0.1/abc", true); - checkCanVerify("127.0.*", "http://127.0.0.1/abc", true); - checkCanVerify("*", "http://127.0.0.1/abc", true); - checkCanVerify("127.0.0.2", "http://127.0.0.1", false); - checkCanVerify("127.0.2.1", "http://127.0.0.1", false); - checkCanVerify("127.2.0.1", "http://127.0.0.1", false); - checkCanVerify("222.0.0.1", "http://127.0.0.1", false); - - checkCanVerify("", "http://foo.com", true); - checkCanVerify("", "http://aaa.bbb.net/xyz", true); - checkCanVerify("", "https://127.0.0.1/abc", true); - - checkCanVerify("aaa.bbb.com,xxx.yyy.com, *.jjj.net", "http://aaa.bbb.com/m", true); - checkCanVerify("aaa.bbb.com, xxx.yyy.com,*.jjj.net", "http://xxx.yyy.com/n", true); - checkCanVerify("aaa.bbb.com,xxx.yyy.com, *.jjj.net", "http://www.jjj.net/o", true); - } - - private static void checkCanVerify (String whitelist, String url, boolean expectedToPass) - throws MalformedURLException - { - List w = Arrays.asList(StringUtil.parseStringArray(whitelist)); - URL u = new URL(url); - boolean passed; - - try { - HostWhitelist.verify(w, u); - passed = true; - } catch (MalformedURLException e) { - passed = false; - } - - assertEquals("with whitelist '" + whitelist + "' and URL '" + url + "'", - expectedToPass, passed); - } -} diff --git a/core/src/test/java/com/threerings/getdown/util/StringUtilTest.java b/core/src/test/java/com/threerings/getdown/util/StringUtilTest.java deleted file mode 100644 index f70bab9..0000000 --- a/core/src/test/java/com/threerings/getdown/util/StringUtilTest.java +++ /dev/null @@ -1,28 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import org.junit.Test; - -import static com.threerings.getdown.util.StringUtil.couldBeValidUrl; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Tests {@link StringUtil}. - */ -public class StringUtilTest -{ - @Test public void testCouldBeValidUrl () - { - assertTrue(couldBeValidUrl("http://www.foo.com/")); - assertTrue(couldBeValidUrl("http://www.foo.com/A-B-C/1_2_3/~bar/q.jsp?x=u+i&y=2;3;4#baz%20baz")); - assertTrue(couldBeValidUrl("https://user:secret@www.foo.com/")); - - assertFalse(couldBeValidUrl("http://www.foo.com & echo hello")); - assertFalse(couldBeValidUrl("http://www.foo.com\"")); - } -} diff --git a/core/src/test/java/com/threerings/getdown/util/VersionUtilTest.java b/core/src/test/java/com/threerings/getdown/util/VersionUtilTest.java deleted file mode 100644 index 165fbe3..0000000 --- a/core/src/test/java/com/threerings/getdown/util/VersionUtilTest.java +++ /dev/null @@ -1,53 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.util; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class VersionUtilTest { - - @Test - public void shouldParseJavaVersion () - { - long version = VersionUtil.parseJavaVersion( - "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "1.8.0_152"); - assertEquals(1_080_152, version); - } - - @Test - public void shouldParseJavaVersion8 () - { - long version = VersionUtil.parseJavaVersion( - "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "1.8"); - assertEquals(1_080_000, version); - } - - @Test - public void shouldParseJavaVersion9 () - { - long version = VersionUtil.parseJavaVersion( - "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "9"); - assertEquals(9_000_000, version); - } - - @Test - public void shouldParseJavaVersion10 () - { - long version = VersionUtil.parseJavaVersion( - "(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(_\\d+)?)?)?", "10"); - assertEquals(10_000_000, version); - } - - @Test - public void shouldParseJavaRuntimeVersion () - { - long version = VersionUtil.parseJavaVersion( - "(\\d+)\\.(\\d+)\\.(\\d+)(_\\d+)?(-b\\d+)?", "1.8.0_131-b11"); - assertEquals(108_013_111, version); - } -} diff --git a/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker deleted file mode 100644 index 1f0955d..0000000 --- a/core/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +++ /dev/null @@ -1 +0,0 @@ -mock-maker-inline diff --git a/launcher/pom.xml b/launcher/pom.xml index 7c26e51..bf5dfd5 100644 --- a/launcher/pom.xml +++ b/launcher/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - com.threerings.getdown + net.affliction getdown - 1.8.11-SNAPSHOT + 1.0.0 getdown-launcher @@ -21,7 +21,7 @@ - com.threerings.getdown + net.affliction getdown-core ${project.version} true @@ -29,7 +29,7 @@ com.samskivert samskivert - 1.12-SNAPSHOT + 1.13 true @@ -82,79 +82,6 @@ - - com.github.wvengen - proguard-maven-plugin - 2.7.0 - - - package - proguard - - - - - com.guardsquare - proguard-base - ${proguard.version} - runtime - - - com.guardsquare - proguard-core - ${proguard-core.version} - runtime - - - - ${proguard.version} - ${project.build.directory} - ${project.build.finalName}.jar - ${project.build.finalName}.jar - - - - com.threerings.getdown - getdown-core - - - com.samskivert - samskivert - - !**/*.java, - !**/swing/RuntimeAdjust*, - !**/swing/util/ButtonUtil*, - !**/util/CalendarUtil*, - !**/util/Calendars*, - !**/util/Log4JLogger*, - !**/util/PrefsConfig*, - !**/util/SignalUtil*, - com/samskivert/Log.class, - **/samskivert/io/**, - **/samskivert/swing/**, - **/samskivert/text/**, - **/samskivert/util/** - - - - jregistrykey - jregistrykey - - - - true - - - - - - - ${rt.jar.path} - - false - - - org.apache.maven.plugins maven-jar-plugin @@ -175,6 +102,32 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.1 + + + package + + shade + + + false + + + com.threerings.getdown.launcher.GetdownApp + + + + + ${project.artifactId}-all + + + + @@ -203,23 +156,6 @@ ${java.home}/jmods/java.base.jmod - - - - com.github.wvengen - proguard-maven-plugin - - - ${java.home}/jmods/java.base.jmod - ${java.home}/jmods/java.desktop.jmod - ${java.home}/jmods/java.logging.jmod - ${java.home}/jmods/java.scripting.jmod - ${java.home}/jmods/jdk.jsobject.jmod - - - - - diff --git a/launcher/src/test/java/com/threerings/getdown/launcher/ProxyUtilTest.java b/launcher/src/test/java/com/threerings/getdown/launcher/ProxyUtilTest.java deleted file mode 100644 index e21377b..0000000 --- a/launcher/src/test/java/com/threerings/getdown/launcher/ProxyUtilTest.java +++ /dev/null @@ -1,149 +0,0 @@ -// -// Getdown - application installer, patcher and launcher -// Copyright (C) 2004-2018 Getdown authors -// https://github.com/threerings/getdown/blob/master/LICENSE - -package com.threerings.getdown.launcher; - -import java.io.StringReader; -import java.net.InetAddress; -import java.net.URL; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class ProxyUtilTest { - - static String[] strs (String... strs) { return strs; } - - static String[] findPAC (String code, String url) throws Exception { - return ProxyUtil.findPACProxiesForURL(new StringReader(code), new URL(url)); - } - - static void testPAC (String code, String url, String... expectedProxies) throws Exception { - assertArrayEquals(expectedProxies, findPAC(code, url)); - } - - @Test public void testPACProxy () throws Exception { - // we use the Graal JavaScrip VM for testing, because JDK15 no longer bundles Nashorn, but - // it does not support calling back into Java unless we set this compatibility property - System.setProperty("polyglot.js.nashorn-compat", "true"); - - String EXAMPLE0 = - "function FindProxyForURL(url, host) {\n" + - " if (shExpMatch(host, '*.example.com')) { return 'DIRECT'; }\n" + - " if (isInNet(host, '10.0.0.0', '255.255.248.0')) {\n" + - " return 'PROXY fastproxy.example.com:8080';\n" + - " }\n" + - " return 'PROXY proxy.example.com:8080; DIRECT';\n" + - "}\n"; - - testPAC(EXAMPLE0, "http://test.example.com/", "DIRECT"); - testPAC(EXAMPLE0, "http://10.0.1.1/", "PROXY fastproxy.example.com:8080"); - testPAC(EXAMPLE0, "http://chicken.gov/", "PROXY proxy.example.com:8080", "DIRECT"); - - String EXAMPLE1 = - "function FindProxyForURL(url, host) {" + - " if (isPlainHostName(host) || dnsDomainIs(host, '.mozilla.org')) {" + - " return 'DIRECT';" + - " } else {" + - " return 'PROXY w3proxy.mozilla.org:8080; DIRECT';" + - " }" + - "}"; - testPAC(EXAMPLE1, "http://test.example.com/", "PROXY w3proxy.mozilla.org:8080", "DIRECT"); - testPAC(EXAMPLE1, "http://www.mozilla.org/", "DIRECT"); - testPAC(EXAMPLE1, "http://foo.mozilla.org/", "DIRECT"); - testPAC(EXAMPLE1, "http://localhost/", "DIRECT"); - - String EXAMPLE2 = - " function FindProxyForURL(url, host) {\n" + - " if ((isPlainHostName(host) || dnsDomainIs(host, '.mozilla.org')) &&\n" + - " !localHostOrDomainIs(host, 'www.mozilla.org') &&\n" + - " !localHostOrDomainIs(host, 'merchant.mozilla.org')) {\n" + - " return 'DIRECT';\n" + - " } else {\n" + - " return 'PROXY w3proxy.mozilla.org:8080; DIRECT';\n" + - " }\n" + - " }"; - testPAC(EXAMPLE2, "http://test.example.com/", "PROXY w3proxy.mozilla.org:8080", "DIRECT"); - testPAC(EXAMPLE2, "http://www.mozilla.org/", "PROXY w3proxy.mozilla.org:8080", "DIRECT"); - testPAC(EXAMPLE2, "http://www/", "PROXY w3proxy.mozilla.org:8080", "DIRECT"); - testPAC(EXAMPLE2, "http://foo.mozilla.org/", "DIRECT"); - testPAC(EXAMPLE2, "http://localhost/", "DIRECT"); - - String EXAMPLE3A = - "function FindProxyForURL(url, host) {\n" + - " if (isResolvable(host)) return 'DIRECT';\n" + - " else return 'PROXY proxy.mydomain.com:8080';\n" + - "}"; - testPAC(EXAMPLE3A, "http://www.mozilla.org/", "DIRECT"); - testPAC(EXAMPLE3A, "http://doesnotexist.mozilla.org/", "PROXY proxy.mydomain.com:8080"); - - String EXAMPLE3B = - "function FindProxyForURL(url, host) {\n" + - " if (isPlainHostName(host) ||\n" + - " dnsDomainIs(host, '.mydomain.com') ||\n" + - " isResolvable(host)) {\n" + - " return 'DIRECT';\n" + - " } else {\n" + - " return 'PROXY proxy.mydomain.com:8080';\n" + - " }\n" + - "}"; - testPAC(EXAMPLE3B, "http://plain/", "DIRECT"); - testPAC(EXAMPLE3B, "http://foo.mydomain.com/", "DIRECT"); - testPAC(EXAMPLE3B, "http://www.mozilla.org/", "DIRECT"); - testPAC(EXAMPLE3B, "http://doesnotexist.mozilla.org/", "PROXY proxy.mydomain.com:8080"); - - // example 4 - // function FindProxyForURL(url, host) { - // if (isInNet(host, '198.95.0.0', '255.255.0.0')) return 'DIRECT'; - // else return 'PROXY proxy.mydomain.com:8080'; - // } - // function FindProxyForURL(url, host) { - // if (isPlainHostName(host) || - // dnsDomainIs(host, '.mydomain.com') || - // isInNet(host, '198.95.0.0', '255.255.0.0')) { - // return 'DIRECT'; - // } else { - // return 'PROXY proxy.mydomain.com:8080'; - // } - // } - - // example 5 - // function FindProxyForURL(url, host) { - // if (isPlainHostName(host) || dnsDomainIs(host, '.mydomain.com')) return 'DIRECT'; - // else if (shExpMatch(host, '*.com')) return 'PROXY proxy1.mydomain.com:8080; ' + - // 'PROXY proxy4.mydomain.com:8080'; - // else if (shExpMatch(host, '*.edu')) return 'PROXY proxy2.mydomain.com:8080; ' + - // 'PROXY proxy4.mydomain.com:8080'; - // else return 'PROXY proxy3.mydomain.com:8080; ' + - // 'PROXY proxy4.mydomain.com:8080'; - // } - - // example 6 - // function FindProxyForURL(url, host) { - // if (url.substring(0, 5) == 'http:') { - // return 'PROXY http-proxy.mydomain.com:8080'; - // } - // else if (url.substring(0, 4) == 'ftp:') { - // return 'PROXY ftp-proxy.mydomain.com:8080'; - // } - // else if (url.substring(0, 7) == 'gopher:') { - // return 'PROXY gopher-proxy.mydomain.com:8080'; - // } - // else if (url.substring(0, 6) == 'https:' || - // url.substring(0, 6) == 'snews:') { - // return 'PROXY security-proxy.mydomain.com:8080'; - // } else { - // return 'DIRECT'; - // } - // } - - String MYIP = - "function FindProxyForURL(url, host) {\n" + - " return 'PROXY ' + myIpAddress() + ':8080';\n" + - "}"; - String myIp = InetAddress.getLocalHost().getHostAddress(); - testPAC(MYIP, "http://testurl.com/", "PROXY " + myIp + ":8080"); - } -} diff --git a/pom.xml b/pom.xml index 6ee5152..621e39d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,10 +2,10 @@ 4.0.0 - com.threerings.getdown + net.affliction getdown pom - 1.8.11-SNAPSHOT + 1.0.0 getdown An application installer and updater.