@BeforeClass public static void init() { CliFrontendTestUtils.pipeSystemOutToNull(); }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
protected Configuration getConfiguration() { final Configuration configuration = GlobalConfiguration .loadConfiguration(CliFrontendTestUtils.getConfigDir()); return configuration; }
@Test public void testGetPreviewPlan() { try { PackagedProgram prog = new PackagedProgram(new File(CliFrontendTestUtils.getTestJarPath())); final PrintStream out = System.out; final PrintStream err = System.err; try { System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); Assert.assertNotNull(prog.getPreviewPlan()); } finally { System.setOut(out); System.setErr(err); } } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); Assert.fail("Test is erroneous: " + e.getMessage()); } }
@Test public void testFileNotJarFile() throws Exception { ProgramOptions options = mock(ProgramOptions.class); when(options.getJarFilePath()).thenReturn(getNonJarFilePath()); try { frontend.buildProgram(options); fail("should throw an exception"); } catch (ProgramInvocationException e) { // that's what we want } }
@Test(expected = CliArgsException.class) public void testInvalidParallelismOption() throws Exception { // test configure parallelism with non integer value String[] parameters = {"-v", "-p", "text", getTestJarPath()}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.run(parameters); }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
@BeforeClass public static void init() { CliFrontendTestUtils.pipeSystemOutToNull(); }
@Test(expected = CliArgsException.class) public void testParallelismWithOverflow() throws Exception { // test configure parallelism with overflow integer value String[] parameters = {"-v", "-p", "475871387138", getTestJarPath()}; Configuration configuration = new Configuration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.run(parameters); }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
@BeforeClass public static void init() { CliFrontendTestUtils.pipeSystemOutToNull(); }
@Test public void testShowExecutionPlanWithParallelism() { replaceStdOut(); try { String[] parameters = {"-p", "17", CliFrontendTestUtils.getTestJarPath()}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.info(parameters); assertTrue(buffer.toString().contains("\"parallelism\": \"17\"")); } catch (Exception e) { e.printStackTrace(); fail("Program caused an exception: " + e.getMessage()); } finally { restoreStdOut(); } }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
@BeforeClass public static void init() { CliFrontendTestUtils.pipeSystemOutToNull(); }
@Test public void testShowExecutionPlan() throws Exception { replaceStdOut(); try { String[] parameters = new String[]{CliFrontendTestUtils.getTestJarPath(), "-f", "true"}; Configuration configuration = getConfiguration(); CliFrontend testFrontend = new CliFrontend( configuration, Collections.singletonList(getCli(configuration))); testFrontend.info(parameters); assertTrue(buffer.toString().contains("\"parallelism\": \"1\"")); } finally { restoreStdOut(); } }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
@BeforeClass public static void setup() { CliFrontendTestUtils.pipeSystemOutToNull(); }
@Test public void testValidVariantWithNoJarAndNoArgumentsOption() throws Exception { String[] arguments = { "--classpath", "file:///tmp/foo", "--classpath", "file:///tmp/bar", getTestJarPath(), "--debug", "true", "arg1", "arg2" }; URL[] classpath = new URL[] { new URL("file:///tmp/foo"), new URL("file:///tmp/bar") }; String[] reducedArguments = {"--debug", "true", "arg1", "arg2"}; RunOptions options = CliFrontendParser.parseRunCommand(arguments); assertEquals(getTestJarPath(), options.getJarFilePath()); assertArrayEquals(classpath, options.getClasspaths().toArray()); assertArrayEquals(reducedArguments, options.getProgramArgs()); PackagedProgram prog = frontend.buildProgram(options); Assert.assertArrayEquals(reducedArguments, prog.getArguments()); Assert.assertEquals(TEST_JAR_MAIN_CLASS, prog.getMainClassName()); }
@AfterClass public static void shutdown() { CliFrontendTestUtils.restoreSystemOut(); }
@BeforeClass public static void init() { CliFrontendTestUtils.pipeSystemOutToNull(); }