public int waitFor() { new Threads().pause(sleep); return returnCode; }
public int waitFor() { new Threads().pause(sleep); return returnCode; }
public void testStreamConnector() throws Exception { String expected = "sendMe"; ByteArrayInputStream send = new ByteArrayInputStream(expected .getBytes()); ByteArrayOutputStream receive = new ByteArrayOutputStream(); new StreamConnector(send, receive, "test").start(); new Threads().pause(20); assertEquals(expected, new String(receive.toByteArray())); } }
public void testStreamConnector() throws Exception { String expected = "sendMe"; ByteArrayInputStream send = new ByteArrayInputStream(expected .getBytes()); ByteArrayOutputStream receive = new ByteArrayOutputStream(); new StreamConnector(send, receive, "test").start(); new Threads().pause(20); assertEquals(expected, new String(receive.toByteArray())); } }
public void testStreamConnector() throws Exception { String expected = "sendMe"; ByteArrayInputStream send = new ByteArrayInputStream(expected .getBytes()); ByteArrayOutputStream receive = new ByteArrayOutputStream(); new StreamConnector(send, receive, "test").start(); new Threads().pause(20); assertEquals(expected, new String(receive.toByteArray())); } }
public void testTrimOptionsErrorMsg() { ByteArrayOutputStream out = new ByteArrayOutputStream(); HelpOptionsParser parser = new HelpOptionsParser(new PrintStream(out), new Threads(), new ClassUtil(), new Str()); Exception expected = null; try { parser.trimToOptions("bogus"); } catch (Exception e) { expected = e; } assertNotNull(expected); String errMsg = new String(out.toByteArray()); assertTrue(errMsg.indexOf("bogus") >= 0); } }
public void testOptionParser() throws Exception { String resourceVersionDir = MysqldResourceI.DEFAULT_VERSION.replaceAll( "\\.", "-"); assertEquals("4-1-13", resourceVersionDir); String sampleHelp = resourceVersionDir + "/com/mysql/management/MySQL_Help.txt"; ClassLoader cl = getClass().getClassLoader(); InputStream is = cl.getResourceAsStream(sampleHelp); String help = new Streams().readString(is); is.close(); HelpOptionsParser parser = new HelpOptionsParser(System.err, new Threads(), new ClassUtil(), new Str()); Map parsed = parser.parseHelp(help); assertEquals("/usr/local/mysql/", parsed.get(MysqldResourceI.BASEDIR)); assertEquals("TRUE", parsed.get("bdb")); // assertEquals("(No default value)", parsed.get("time-format")); assertEquals("", parsed.get("time-format")); }
public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }
public void testDoubleRun() { processSleep = 2000; shell.start(); new Threads().pause(20); Exception expected = null; try { shell.run(); } catch (IllegalStateException e) { expected = e; } assertNotNull(expected); }
public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }
public ProcessUtil(String pid, PrintStream out, PrintStream err) { this(new FileUtil(), pid, out, err, new Str(), new Shell.Factory(), new Streams(), new Threads()); }
public void testDoubleRun() { processSleep = 2000; shell.start(); new Threads().pause(20); Exception expected = null; try { shell.run(); } catch (IllegalStateException e) { expected = e; } assertNotNull(expected); }
public void testDestroy() throws Exception { processSleep = 2000; assertNull(testProcess); shell.start(); new Threads().pause(20); shell.destroyProcess(); assertEquals(1, testProcess.destroyCalled); }
public void testDestroy() throws Exception { processSleep = 2000; assertNull(testProcess); shell.start(); new Threads().pause(20); shell.destroyProcess(); assertEquals(1, testProcess.destroyCalled); }
public MysqldResource(File baseDir, PrintStream out, PrintStream err) { this(baseDir, out, err, new FileUtil(), new Shell.Factory(), new Streams(), new Threads(), new Str(), new ClassUtil()); }
protected void setUp() { super.setUp(); testUtil = new TestUtil(); fileUtil = new TestFileUtil(); utils = new Utils(fileUtil, new Shell.Factory(), new Streams(), new Threads(), new Str()); baseDir = new File(fileUtil.testDir(), "MRTest"); dataDir = new File(baseDir, "data"); fileUtil.deleteTree(baseDir); if (baseDir.exists()) { warn("residual files"); } mysqldResource = new MysqldResource(baseDir, dataDir, null, System.out, System.err, utils); mysqldResource.setKillDelay(testUtil.testKillDelay()); }
public void testCompletionListener() { Exception expected = null; try { shell.addCompletionListener(null); } catch (IllegalArgumentException e) { expected = e; } assertNotNull(expected); class TestListener implements Runnable { int timesRun = 0; public void run() { timesRun++; } } TestListener listener = new TestListener(); shell.addCompletionListener(listener); shell.run(); for (int c = 0; c < 5 && (listener.timesRun == 0); c++) { new Threads().pause(10); } assertEquals(1, listener.timesRun); }
public void testCompletionListener() { Exception expected = null; try { shell.addCompletionListener(null); } catch (IllegalArgumentException e) { expected = e; } assertNotNull(expected); class TestListener implements Runnable { int timesRun = 0; public void run() { timesRun++; } } TestListener listener = new TestListener(); shell.addCompletionListener(listener); shell.run(); for (int c = 0; c < 5 && (listener.timesRun == 0); c++) { new Threads().pause(10); } assertEquals(1, listener.timesRun); }
public static void main(String[] args) { CommandLineOptionsParser clop = new CommandLineOptionsParser(args); MysqldResource mysqld = new MysqldResource(clop.getBaseDir()); if (args.length == 0) { mysqld.printUsage(); } else if (clop.isShutdown()) { mysqld.shutdown(); } else { mysqld.start(new Threads().newName(), clop.asMap()); } } }
protected void setUp() { super.setUp(); testUtil = new TestUtil(); threads = new Threads(); fileUtil = new TestFileUtil(); shellFactory = new Shell.Factory(); streams = new Streams(); str = new Str(); classUtil = new ClassUtil(); mysqldResource = new MysqldResource(fileUtil.nullFile(), System.out, System.err, fileUtil, shellFactory, streams, threads, str, classUtil); mysqldResource.setKillDelay(10000); File baseDir = mysqldResource.getBaseDir(); fileUtil.deleteTree(baseDir); if (baseDir.exists()) { warn("residual files"); } }