public DataInputOutput() { database = Database.getInstance(); Files files = new Files(); }
protected void setUp() { fileUtil = new Files(); testUtil = new TestUtil(); }
public MysqldResourceTestImpl(File baseDir, File dataDir, Map options, Map runningFakeMysqlds) { this.baseDir = (baseDir == null) ? new Files().nullFile() : baseDir; this.dataDir = dataDir; this.running = null; this.currentOptions = options; this.completionListensers = new ArrayList(); this.runningFakeMysqlds = runningFakeMysqlds; this.version = "5.2.23"; }
public MysqldResourceTestImpl(File baseDir, File dataDir, Map options, Map runningFakeMysqlds) { this.baseDir = (baseDir == null) ? new Files().nullFile() : baseDir; this.dataDir = dataDir; this.running = null; this.currentOptions = options; this.completionListensers = new ArrayList(); this.runningFakeMysqlds = runningFakeMysqlds; this.version = "5.2.23"; }
public CommandLineOptionsParser(List args) { this.params = new HashMap(); this.fileUtil = new Files(); for (int i = 0; i < args.size(); i++) { String arg = (String) args.get(i); if (arg.startsWith("--")) { arg = arg.substring(2); } int equalsPos = arg.indexOf("="); if (equalsPos == -1) { equalsPos = arg.length(); } String key = arg.substring(0, equalsPos).trim(); String value = null; if (arg.length() > equalsPos) { value = arg.substring(equalsPos + 1, arg.length()).trim(); } params.put(key, value); } }
public CommandLineOptionsParser(List args) { this.params = new HashMap(); this.fileUtil = new Files(); for (int i = 0; i < args.size(); i++) { String arg = (String) args.get(i); if (arg.startsWith("--")) { arg = arg.substring(2); } int equalsPos = arg.indexOf("="); if (equalsPos == -1) { equalsPos = arg.length(); } String key = arg.substring(0, equalsPos).trim(); String value = null; if (arg.length() > equalsPos) { value = arg.substring(equalsPos + 1, arg.length()).trim(); } params.put(key, value); } }
protected void setUp() { super.setUp(); orig = System.getProperty(Files.USE_TEST_DIR, ""); System.setProperty(Files.USE_TEST_DIR, Boolean.TRUE.toString()); dataDir = new Files().tmp("MxjAccTest_" + System.currentTimeMillis()); testUtil = new TestUtil(); }
protected void setUp() { dir = new File(new Files().testDir(), "ProcUtiTest"); devNull = new NullPrintStream(); testUtil = new TestUtil(); wk = testUtil.getSystemPropertyWithDefaultFromResource( MysqldResourceI.WINDOWS_KILL_COMMAND, MysqldResourceI.CONNECTOR_MXJ_PROPERTIES, System.err); }
public void testServerDriverLauncherFactory() throws Exception { dataDir = new File(new Files().tmp("TestApp"), "data"); String safePath = URLEncoder.encode(dataDir.getPath(), "UTF-8"); port = testUtil.testPort(); String url = "jdbc:mysql:mxj://localhost:" + port + "/alice_db" // + "?server.datadir=" + safePath // + "&server.initialize-user=true"// + "&createDatabaseIfNotExist=true"// ; testUtil.assertConnectViaJDBC(url, "alice", "opt4g01396"); testUtil.assertConnectViaJDBC(url, "alice", "opt4g01396"); testUtil.assertConnectViaJDBC(url, "alice", "opt4g01396"); } }
public void testCreateDbFiles() { new Files().deleteTree(dataDir); File dbDataDir = new File(dataDir, "mysql"); File host_frm = new File(dbDataDir, "host.frm"); assertEquals(false, host_frm.exists()); assertEquals(false, dataDir.exists()); mysqldResource.ensureEssentialFilesExist(); assertTrue(host_frm.exists()); }
protected void tearDown() { super.tearDown(); // un-quiet so we can see errors. try { File baseDir = new Files().tmp(MysqldResource.MYSQL_C_MXJ); ServerLauncherSocketFactory.shutdown(baseDir, dataDir, testUtil .testKillDelay()); } catch (MysqldResourceNotFoundException e) { warn(e); } finally { if (orig != null) { System.setProperty(Files.USE_TEST_DIR, orig); } else { // System.clearProperty(Files.USE_TEST_DIR); System.setProperty(Files.USE_TEST_DIR, ""); } new Files().cleanTestDir(); if (dataDir != null) { new Files().deleteTree(dataDir); } } }
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 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); }
protected void tearDown() { try { if (bean != null) { try { bean.invoke(SimpleMysqldDynamicMBean.STOP_METHOD, null, null); } catch (Exception e) { e.printStackTrace(); } threads.pause(50); } if (agent != null) { agent.shutdown(); } new Files().deleteTree(dataDir); } finally { System.setProperty(Files.USE_TEST_DIR, orig); super.tearDown(); } }
public void testKillCommandLineWindows() { Utils utils = new Utils(); utils.setFiles(new Files() { public boolean isWindows() { return true; } }); String pid = "2342"; ProcessUtil kp = new ProcessUtil(pid, devNull, devNull, dir, utils, wk); String[] args = kp.killArgs(false); assertTrue(args[0], args[0].endsWith("kill.exe")); assertEquals(pid, args[args.length - 1]); }
public void testDefaultAnd3306() throws Exception { ServerLauncherSocketFactory sf = new ServerLauncherSocketFactory(); FakeMysqldFactory factory = new FakeMysqldFactory(); FakeSocketFactory fakeSf = new FakeSocketFactory(); sf.setResourceFactory(factory); sf.setSocketFactory(fakeSf); sf.throwOnBadPassword(false); Properties props = new Properties(); int port = 3306; assertEquals(0, factory.fakeRunningMysqlds.size()); sf.connect("localhost", port, props); assertEquals(1, factory.fakeRunningMysqlds.size()); sf.connect("127.0.0.1", port, props); assertEquals(1, factory.fakeRunningMysqlds.size()); File baseDir = new Files().tmp("MysqlDir3307"); props.setProperty(ServerLauncherSocketFactory.SERVER_DOT + MysqldResourceI.BASEDIR, baseDir.toString() + "1"); sf.connect("localhost", port + 1, props); assertEquals(2, factory.fakeRunningMysqlds.size()); } }
public void testKillCommandLineUnix() { Utils utils = new Utils(); utils.setFiles(new Files() { public boolean isWindows() { return false; } }); String pid = "2342"; ProcessUtil kp = new ProcessUtil(pid, devNull, devNull, dir, utils, wk); String[] args = kp.killArgs(false); assertEquals(args[0], "kill"); assertEquals(pid, args[args.length - 1]); }
public static Test suite() { new Files().cleanTestDir(); TestSuite suite = new TestSuite(); suite.addTest(com.mysql.management.util.AllTestsSuite.suite()); suite .addTest(com.mysql.management.driverlaunched.AllTestsSuite .suite()); suite.addTestSuite(HelpOptionsParserTest.class); suite.addTest(com.mysql.management.jmx.AllTestsSuite.suite()); // slow tests: suite.addTestSuite(MysqldResourceTest.class); suite.addTestSuite(AcceptanceTest.class); suite .addTestSuite(com.mysql.management.driverlaunched.AcceptanceTest.class); return suite; }
public void testSetters() { shell.setRuntime(new RuntimeI.Default()); shell.setEnvironment(new String[0]); shell.setWorkingDir(new Files().testDir()); shell.run(); assertTrue(shell.hasReturned()); int rv = shell.returnCode(); // this is _not_ a prefect test. // With some JVMs we get '1', others we get '0' .... // however if the "java" command is missing we get 127 on most unix assertEquals("" + rv, true, rv == 1 || rv == 0); }