@Test public void testUserSpecifiedConfigName() throws Exception { System.setProperty("loader.config.name", "foo"); PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("my.Application", launcher.getMainClass()); assertEquals("[etc/]", ReflectionTestUtils.getField(launcher, "paths").toString()); }
@Test public void testUserSpecifiedConfigPathWins() throws Exception { System.setProperty("loader.config.name", "foo"); System.setProperty("loader.config.location", "classpath:bar.properties"); PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("my.BarApplication", launcher.getMainClass()); }
@Test public void testCustomClassLoaderCreation() throws Exception { System.setProperty("loader.classLoader", TestLoader.class.getName()); PropertiesLauncher launcher = new PropertiesLauncher(); ClassLoader loader = launcher.createClassLoader(Collections.<Archive>emptyList()); assertNotNull(loader); assertEquals(TestLoader.class.getName(), loader.getClass().getName()); }
@Test public void testUserSpecifiedJarPath() throws Exception { System.setProperty("loader.path", "jars/app.jar"); System.setProperty("loader.main", "demo.Application"); PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("[jars/app.jar]", ReflectionTestUtils.getField(launcher, "paths").toString()); launcher.launch(new String[0]); waitFor("Hello World"); }
@Test public void testUserSpecifiedMain() throws Exception { PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("demo.Application", launcher.getMainClass()); assertNull(System.getProperty("loader.main")); }
@Test public void testDefaultHome() { PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals(new File(System.getProperty("loader.home")), launcher.getHomeDirectory()); }
@Test public void testArgsEnhanced() throws Exception { System.setProperty("loader.args", "foo"); PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("[foo, bar]", Arrays.asList(launcher.getArgs("bar")).toString()); }
@Test public void testSystemPropertySpecifiedMain() throws Exception { System.setProperty("loader.main", "foo.Bar"); PropertiesLauncher launcher = new PropertiesLauncher(); assertEquals("foo.Bar", launcher.getMainClass()); }