public void testTestReporting() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream captured = new PrintStream(baos); mysqldResource = new MysqldResource(fileUtil.nullFile(), captured, captured, fileUtil, shellFactory, streams, threads, str, classUtil); mysqldResource.reportIfNoPidfile(true); captured.flush(); assertEquals("", new String(baos.toByteArray())); mysqldResource.reportIfNoPidfile(false); captured.flush(); String output = new String(baos.toByteArray()); testUtil.assertContainsIgnoreCase(output, "pid-file not found"); testUtil.assertContainsIgnoreCase(output, fileUtil.tmp().toString()); }
public void testTestFinalize() throws Throwable { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream captured = new PrintStream(baos); mysqldResource = new MysqldResource(fileUtil.nullFile(), captured, captured, fileUtil, shellFactory, streams, threads, str, classUtil); mysqldResource.finalize(); captured.flush(); String output = new String(baos.toByteArray()); assertEquals("", output); PrintStream devNull = new NullPrintStream(); String[] none = new String[0]; mysqldResource.setShell(new Shell.Default(none, "bogus", devNull, devNull)); mysqldResource.finalize(); captured.flush(); output = new String(baos.toByteArray()); testUtil.assertContainsIgnoreCase(output, "<init>"); }
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"); } }
public void testDestroyShell() { /** TODO: improve this test */ startMysql("DestroyMe"); assertTrue(mysqldResource.isRunning()); mysqldResource.destroyShell(); if (mysqldResource.isRunning()) { new MysqldResource(fileUtil.nullFile()).shutdown(); } }
public void testDestroyShell() { /** TODO: improve this test */ startMysql("DestroyMe"); assertTrue(mysqldResource.isRunning()); mysqldResource.destroyShell(); if (mysqldResource.isRunning()) { new MysqldResource(fileUtil.nullFile()).shutdown(); } }