public static void main(String args[]) { // TODO: Use args if (false) { Parser p = new Parser(); run(p.parse(ConfigFile)); } // TODO: Use args if (true) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.showSaveDialog(null); String filepath = fileChooser.getSelectedFile().toString().replace("\\", "\\\\"); // String filepath = "X:\\#inbox"; List<Extension> text = new ArrayList<>(); text.add(new ExtensionCaseInsensitive("doc")); text.add(new ExtensionCaseInsensitive("docx")); text.add(new ExtensionCaseInsensitive("pdf")); text.add(new ExtensionCaseInsensitive("txt")); run(new Folder(filepath, text)); } }
public static void main(String[] args) { if (args.length == 0) { gui = new Gui(); gui.setVisible(true); } else if (args.length == 3 || args.length == 4) { Main.setBlogName(args[0]); Main.load(); if (args.length == 3) { int start, limit; try { start = Integer.parseInt(args[1]); limit = Integer.parseInt(args[2]); } catch (Exception e) { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); Main.status("start_page and end_page must be integers >= 1"); return; } Main.run(start, limit); Main.save(); } else if (args.length == 4 && args[3].equals("-hires")) { Main.downloadHiRes(); Main.save(); } else { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); } } else { Main.status("usage: Main <blogname> <start_page> <end_page> -hires"); } }
@Test public void testCommand() throws Exception { Command command = mock(Command.class); when(command.getName()).thenReturn("mock-command"); Main main = new Main(command); main.run(null, null, null, Lists.newArrayList("mock-command", "arg1", "arg2")); verify(command).run(null, null, null, Lists.newArrayList("arg1", "arg2")); }
@Test public void testUnrecognizedCommand() throws Exception { Main main = new Main(new TestCommand()); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); PrintStream err = new PrintStream(bytes); int rc = main.run(null, null, err, Lists.newArrayList("bogus-command")); assertThat(rc, is(-1)); assertThat(bytes.toString(), containsString("Unrecognized command 'bogus-command'")); }
/* * Start up. */ public static void main(String[] args) { Main main = new Main(); main.run(); /* run through the heap to see if we trashed something */ System.gc(); System.out.println("Done!"); }
private void run(String commandLine) throws Exception { String[] argv = convertToMainArgs(commandLine); try { super.run(argv); } catch (TerminatedByHelpException e) { // this is not a failure, super called exit() on help } finally { writer.flush(); } }
public static void main(String... args) throws IOException { Main m = new Main(); PrintWriter out = new PrintWriter(System.out); try { if (args.length == 0) m.usage(out); else m.run(out, args); } finally { out.flush(); } }
@Test public void testNoArgs() throws Exception { Main main = new Main(new TestCommand()); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bytes); int rc = main.run(null, out, null, Collections.<String>emptyList()); assertThat(rc, is(-1)); assertThat(bytes.toString(), containsString("Usage: whirr COMMAND")); assertThat(bytes.toString(), containsString("test-command test description")); }
public static void main(String[] args) { Main main = new Main(); initDisplay(false); initGL(); // main.init(); main.run(); AL.destroy(); }
public void boot() throws Exception { // create a Main instance main = new Main(); // enable hangup support so you can press ctrl + c to terminate the JVM main.enableHangupSupport(); // add routes main.addRouteBuilder(new MyRouteBuilder()); // run until you terminate the JVM System.out.println("Starting Camel. Use ctrl + c to terminate the JVM.\n"); main.run(); }
@Test public <RC extends RepositoryConnection> void testFind() throws ClientException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { final List<RepositoryResource> getAllList = new ArrayList<>(); getAllList.add(getTestEsa("1", "A name", "A short description", "productVersion=8.5.5.4;")); getAllList.add(getTestEsa("2", "A name", null, null)); getAllList.add( getTestEsa( "3", "A quoted version", "A shortish description", "productVersion=\"8.5.5.7\";")); new MockUp<RC>() { @Mock public Collection<? extends RepositoryResource> getAllResources() throws RepositoryBackendException { return getAllList; } }; tested.run(new String[] {"--find", "--url=http://foobar.baz"}); String output = baos.toString(); Pattern pat = Pattern.compile( "1\\s\\+|\\s+Feature\\s+\\|\\s+8\\.5\\.5\\.4\\s+\\|\\s+A name\\s+\\(A short description\\)"); Matcher match = pat.matcher(output); assertTrue( "The output didn't contain the expected asset description:\n" + output, match.find()); Pattern pat2 = Pattern.compile("2\\s+\\|\\s+Feature\\s+\\|\\s+\\|\\s+A name"); Matcher match2 = pat2.matcher(output); assertTrue( "The output didn't contain the expected asset description:\n" + output, match2.find()); Pattern pat3 = Pattern.compile( "1\\s\\+|\\s+Feature\\s+\\|\\s+8\\.5\\.5\\.7\\s+\\|\\s+A quoted version\\s+\\(A shortish description\\)"); Matcher match3 = pat3.matcher(output); assertTrue( "The output didn't contain the expected asset description:\n" + output, match3.find()); assertEquals("The error output wasn't empty", "", ebaos.toString()); }
@Test public void testFooUrl() { // Should throw an exception but no help message try { tested.run(new String[] {"--find", "--url=foobar"}); } catch (ClientException e) { assertEquals("Unexpected exception message", Main.INVALID_URL + "foobar", e.getMessage()); String outputString = baos.toString(); assertTrue( "The expected output wasn't produced, was:\n" + outputString, outputString.contains(Main.INVALID_URL)); String errorOutput = ebaos.toString(); assertEquals("No output was expected to stderr", "", errorOutput); return; } fail("The expected client exception was not thrown"); }
@Test public void testNoUrl() { // Should throw an exception and print out a help message try { tested.run(new String[] {"--find"}); } catch (ClientException e) { assertEquals("Unexpected exception message", Main.MISSING_URL, e.getMessage()); String outputString = baos.toString(); assertTrue( "The expected help output wasn't produced, was:\n" + outputString, TestUtils.checkForHelpMessage(outputString)); String errorOutput = ebaos.toString(); assertEquals("No output was expected to stderr", "", errorOutput); return; } fail("The expected client exception was not thrown"); }
@Test public <RC extends RepositoryConnection> void testEmptyRepository() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClientException { new MockUp<RC>() { @Mock public Collection<? extends RepositoryResource> findResources( String searchTerm, Collection<ProductDefinition> productDefinitions, Collection<ResourceType> types, Visibility visibility) throws RepositoryBackendException { return Collections.emptySet(); } }; tested.run(new String[] {"--find", "*", "--url=http://foobar.baz"}); String output = baos.toString(); assertTrue( "The test output didn't contain the expected string, was: " + output, output.contains("No assets found in repository")); assertEquals("The error output wasn't empty", "", ebaos.toString()); }
public GUI() throws MessagingException, IOException { main = new Main(); main.run(); initialize(); }
public static void run(Iterable<Folder> folders) { for (Folder f : folders) { run(f); } }
public static void main(String args[]) // entry point from OS { Main myWork = new Main(); // Construct the bootloader myWork.run(); // execute }
public void start() { /* Dump a message */ System.err.println("ServiceDaemon: starting"); existMain.run(args); }
public static void main(String args[]) { Main server = new Main(); while (true) { server.run(); } }
/** @param args */ public static void main(String[] args) { Main main = new Main(); main.run(); }