public String getSystemPropertyWithDefaultFromResource(String property, String resourceName, PrintStream err) { Properties props = new Streams().loadProperties(resourceName, err); String fileVal = props.getProperty(property); return System.getProperty(property, fileVal); } }
@Override public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
public void inner() throws Exception { new Streams().copy(from, to, false, true); } }.exec();
public Files() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
public FileUtil() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
public Files() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
public void testStreamsCopyErrorSilent() throws Exception { ThrowingInputStream from = new ThrowingInputStream(); ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = true; // close quitely if "terminateOnFalure = true" new Streams().copy(from, to, isBuffered, terminateOnFalure); assertEquals(from.data(), new String(to.toByteArray())); }
public void testOptionParserSupportIssue8601() throws Exception { String text = "support-issue-8601-help-output.txt"; ClassLoader cl = getClass().getClassLoader(); InputStream is = cl.getResourceAsStream(text); String help = new Streams().readString(is); is.close(); HelpOptionsParser parser = new HelpOptionsParser(System.err, new Utils()); Map parsed = parser.getOptionsFromHelp(help); // System.err.println(new ListToString().toString(parsed)); assertEquals("FALSE", parsed.get("allow-suspicious-udfs")); } }
public void testKillCommandLineWindows() { FileUtil fu = new FileUtil() { public boolean isWindows() { return true; } }; String pid = "2342"; ProcessUtil kp = new ProcessUtil(fu, pid, null, null, new Str(), null, new Streams(), null); String[] args = kp.killArgs(false); assertTrue(args[0], args[0].endsWith("kill.exe")); assertEquals(pid, args[args.length - 1]); }
private void checkCopyError(boolean isIOException) throws Exception { ThrowingInputStream from = new ThrowingInputStream(); from.ioexception = isIOException; ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = false; // throw exception if "terminateOnFalure = false" Exception expected = null; try { new Streams().copy(from, to, isBuffered, terminateOnFalure); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(EXCEPTION_MSG, expected.getMessage()); assertEquals(from.data(), new String(to.toByteArray())); }
private void checkCopyError(boolean isIOException) throws Exception { ThrowingInputStream from = new ThrowingInputStream(); from.ioexception = isIOException; ByteArrayOutputStream to = new ByteArrayOutputStream(); boolean isBuffered = false; boolean terminateOnFalure = false; // throw exception if "terminateOnFalure = false" Exception expected = null; try { new Streams().copy(from, to, isBuffered, terminateOnFalure); } catch (Exception e) { expected = e; } assertNotNull(expected); assertEquals(EXCEPTION_MSG, expected.getMessage()); assertEquals(from.data(), new String(to.toByteArray())); }
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 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 ProcessUtil(String pid, PrintStream out, PrintStream err) { this(new FileUtil(), pid, out, err, new Str(), new Shell.Factory(), new Streams(), new Threads()); }
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()); }