public File testDir() { return new File(tmp(), "test-c.mxj"); }
public File testDir() { return new File(tmp(), "test-c.mxj"); }
public File tmp(String subdir) { String useTestDir = System.getProperty(USE_TEST_DIR); if (Boolean.TRUE.toString().equalsIgnoreCase(useTestDir)) { return new File(testDir(), subdir); } return new File(tmp(), subdir); }
public File tmp(String subdir) { String useTestDir = System.getProperty(USE_TEST_DIR); if (Boolean.TRUE.toString().equalsIgnoreCase(useTestDir)) { return new File(testDir(), subdir); } return new File(tmp(), subdir); }
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(); }
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 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()); } }
int port = 3306; File baseDir = new Files().tmp(MysqldResource.MYSQL_C_MXJ);
public MysqldResource(File baseDir, File dataDir, String mysqlVersionString, boolean guessArch, PrintStream out, PrintStream err, Utils util, String binDir) { this.out = out; this.err = err; this.utils = util; this.binDir = binDir; this.optionParser = new HelpOptionsParser(err, utils); this.killDelay = 30000; this.baseDir = utils.files().validCononicalDir(baseDir, utils.files().tmp(MYSQL_C_MXJ)); this.dataDir = utils.files().validCononicalDir(dataDir, new File(this.baseDir, DATA)); String className = utils.str().shortClassName(getClass()); this.pidFile = utils.files().cononical( new File(this.dataDir, className + ".pid")); this.portFile = new File(dataDir, "port"); setVersion(false, mysqlVersionString); this.msgPrefix = "[" + utils.str().shortClassName(getClass()) + "] "; this.options = new HashMap(); this.setShell(null); setOsAndArch(System.getProperty(Platform.OS_NAME), guessArch, System .getProperty(Platform.OS_ARCH)); this.completionListensers = new ArrayList(); initTrace(); }
public void testIsEmpty() throws Exception { foo = fileUtil.tmp("foo"); assertEquals(false, foo.exists()); assertEquals(true, fileUtil.isEmpty(foo)); foo.mkdirs(); assertEquals(true, foo.exists()); assertEquals(true, foo.isDirectory()); assertEquals(true, fileUtil.isEmpty(foo)); File bar = new File(foo, "bar"); assertEquals(false, bar.exists()); assertEquals(true, fileUtil.isEmpty(bar)); writeToFile(bar, "stuff"); assertEquals(true, bar.exists()); assertEquals(false, fileUtil.isEmpty(bar)); assertEquals(false, fileUtil.isEmpty(foo)); assertEquals(true, bar.delete()); assertEquals(true, fileUtil.isEmpty(foo)); }
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); } } }
MysqldResource(File pBaseDir, File pDataDir, String pMysqlVersionString, PrintStream pOut, PrintStream pErr, Utils pUtils) { this.out = (pOut != null) ? pOut : System.out; this.err = (pErr != null) ? pErr : System.err; this.utils = (pUtils != null) ? pUtils : new Utils(); this.platformProperties = utils.streams().loadProperties( PLATFORM_MAP_PROPERTIES, pErr); this.connectorMxjProperties = utils.streams().loadProperties( CONNECTOR_MXJ_PROPERTIES, pErr); this.baseDir = utils.files().validCononicalDir(pBaseDir, utils.files().tmp(MYSQL_C_MXJ)); this.dataDir = utils.files().validCononicalDir(pDataDir, new File(baseDir, DATA)); this.optionParser = new HelpOptionsParser(err, utils); this.killDelay = getKillDelyFromProperties(connectorMxjProperties); this.windowsKillCommand = getWindowsKillCommand(connectorMxjProperties); String className = utils.str().shortClassName(getClass()); this.pidFile = utils.files().cononical( new File(dataDir, className + ".pid")); this.portFile = new File(dataDir, className + ".port"); setVersion(false, pMysqlVersionString); this.msgPrefix = "[" + className + "] "; this.options = new HashMap(); setShell(null); setOsAndArch(System.getProperty(Platform.OS_NAME), System .getProperty(Platform.OS_ARCH)); this.completionListensers = new ArrayList(); initTrace(); }