final File getWindowsKillFile(String windowsKillCommand) { File parent = new File(installDir, "c-mxj-utils"); File kill = new File(parent, windowsKillCommand); if (!kill.exists()) { utils.streams().createFileFromResource(windowsKillCommand, kill); } return kill; }
private void expandResourceJarInner(File outputDir, String jarResourceName) throws IOException { InputStream is = getResourceAsStream(jarResourceName); try { JarInputStream jis = new JarInputStream(is); try { expandEachEntry(outputDir, jis); } finally { jis.close(); } } finally { is.close(); } }
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); } }
public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
public Files() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
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")); } }
/** * Reads the data from the Input stream and writes to the output stream * Buffers each stream. Terminates when a read from the Input stream results * in EOF */ public void copy(InputStream from, OutputStream to) throws IOException { copy(from, to, true, false); }
/** * Uses ClassLoader which loaded Streams.class to obtain resource * * @return an InputStream * @throws MissingResourceException */ public InputStream getResourceAsStream(String name) { return getResourceAsStream(getClass(), name); }
void ensureEssentialFilesExist(File dataDir) { streams.expandResourceJar(dataDir, getVersionDir() + Streams.RESOURCE_SEPARATOR + "data_dir.jar"); streams.expandResourceJar(baseDir, getVersionDir() + Streams.RESOURCE_SEPARATOR + shareJar()); }
public String inner() throws IOException { FileInputStream fis = new FileInputStream(file); try { return streams.readString(fis); } finally { fis.close(); } } }.exec();
@Override public void ensureEssentialFilesExist() { try { if(bNewMySqldWasCopiedToWorkArea) { utils.files().deleteTree(new File(baseDir + File.separator + "share")); } String sSourceDir = binDir(); JarInputStream dataIn = new JarInputStream(new FileInputStream(sSourceDir + File.separator + "data_dir.jar")); utils.streams().expandEachEntry(dataDir, dataIn); JarInputStream shareIn = new JarInputStream(new FileInputStream(sSourceDir + File.separator + "share_dir.jar")); utils.streams().expandEachEntry(baseDir, shareIn); } catch (IOException e) { e.printStackTrace(); } }
public void testJarName() { Properties props = utils.streams().loadProperties( "connector-mxj.properties", System.err); String expected = props.getProperty("windows-share-dir-jar", "win_share_dir.jar"); setSystemPropertiesToWinNT(); assertEquals(expected, mysqldResource.shareJar()); setSytemPropertiesToLinux(); assertEquals("share_dir.jar", mysqldResource.shareJar()); }
protected synchronized void setVersion(boolean checkRunning, String mysqlVersionString) { if (checkRunning && isRunning()) { throw new IllegalStateException("Already running"); } if (mysqlVersionString == null || mysqlVersionString.equals("")) { versionString = utils.streams() .getSystemPropertyWithDefaultFromResource(MYSQLD_VERSION, "connector-mxj.properties", err); } else { versionString = mysqlVersionString; } versionString.trim(); }
public FileUtil() { this(new Shell.Factory(), File.separatorChar, new 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 void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
/** * Reads the data from the Input stream and writes to the output stream * Buffers each stream. Terminates when a read from the Input stream results * in EOF */ public void copy(InputStream from, OutputStream to) throws IOException { copy(from, to, true, false); }
/** * Uses ClassLoader which loaded Streams.class to obtain resource * * @return an InputStream * @throws MissingResourceException */ public InputStream getResourceAsStream(String name) { ClassLoader classLoader = getClass().getClassLoader(); return getResourceAsStream(classLoader, name); }
public void ensureEssentialFilesExist() { utils.streams().expandResourceJar(dataDir, getVersionDir() + Streams.RESOURCE_SEPARATOR + "data_dir.jar"); utils.streams().expandResourceJar(baseDir, getVersionDir() + Streams.RESOURCE_SEPARATOR + shareJar()); }