public void assertConnectViaJDBC(String url, String user, String password) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { assertConnectViaJDBC(url, user, password, false); }
public void assertConnectViaJDBC(String url, boolean dbInUrl) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { assertConnectViaJDBC(url, "root", "", dbInUrl); }
public void assertConnectViaJDBC(String url, String user, String password) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { assertConnectViaJDBC(url, user, password, false); }
public void assertConnectViaJDBC(String url, boolean dbInUrl) throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException { assertConnectViaJDBC(url, "root", "", dbInUrl); }
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"); } }
private void makeDb(String url, String userName, String password) throws Exception { new TestUtil().assertConnectViaJDBC(url, userName, password, true); Class.forName(com.mysql.jdbc.Driver.class.getName()); conn = DriverManager.getConnection(url, userName, password); stmt = conn.createStatement(); stmt.execute("CREATE DATABASE MY1"); stmt.execute("USE MY1"); String sql = "GRANT ALL PRIVILEGES ON MY1.*" + " TO 'JAVA'@'%' IDENTIFIED BY 'SAPR3'" + " WITH GRANT OPTION"; stmt.execute(sql); sql = "GRANT ALL PRIVILEGES ON MY1.*" + " TO 'JAVA'@'localhost' IDENTIFIED BY 'SAPR3'" + " WITH GRANT OPTION"; stmt.execute(sql); stmt.execute("commit"); stmt.close(); } }
public void testServerDriverLauncherFactory() throws Exception { int port = new TestUtil().testPort(); hostAndPort = "localhost:" + port; Class sf = com.mysql.management.driverlaunched.ServerLauncherSocketFactory.class; String url = "jdbc:mysql://" + hostAndPort + "/test?" + "socketFactory=" + sf.getName(); new TestUtil().assertConnectViaJDBC(url); ServerLauncherSocketFactory.shutdown(hostAndPort); } }
testUtil.assertConnectViaJDBC(url1); testUtil.assertConnectViaJDBC(url2); testUtil.assertConnectViaJDBC(url2); testUtil.assertConnectViaJDBC(url1); } catch (SQLException e) { expected = e; expected = null; try { testUtil.assertConnectViaJDBC(url2); } catch (SQLException e) { expected = e;
private void makeDb(String url, String userName, String password) throws Exception { testUtil.assertConnectViaJDBC(url, userName, password, true); Class.forName(com.mysql.jdbc.Driver.class.getName()); conn = DriverManager.getConnection(url, userName, password); QueryUtil util = new QueryUtil(conn); util.execute("CREATE DATABASE MY1"); util.execute("USE MY1"); String sql = "GRANT ALL PRIVILEGES ON MY1.*" + " TO 'JAVA'@'%' IDENTIFIED BY 'SAPR3'" + " WITH GRANT OPTION"; util.execute(sql); sql = "GRANT ALL PRIVILEGES ON MY1.*" + " TO 'JAVA'@'localhost' IDENTIFIED BY 'SAPR3'" + " WITH GRANT OPTION"; util.execute(sql); util.execute("commit"); }
testUtil.assertConnectViaJDBC(url1); testUtil.assertConnectViaJDBC(url2); testUtil.assertConnectViaJDBC(url2); testUtil.assertConnectViaJDBC(url1); } catch (SQLException e) { expected = e; expected = null; try { testUtil.assertConnectViaJDBC(url2); } catch (SQLException e) { expected = e;
public void testLaunch() throws Exception { Map args = new HashMap(); String port = "" + testUtil.testPort(); args.put(MysqldResourceI.PORT, port); String url = "jdbc:mysql://localhost:" + port + "/test"; String threadName = "testLaunch"; assertFalse("mysqld should not be running", mysqldResource.isRunning()); mysqldResource.start(threadName, args); Shell s1 = mysqldResource.getShell(); /* this asserts the thread starts */ assertRunning(); /* pause for mysqld to bind to port */ for (int i = 0; i < 100 && !mysqldResource.isReadyForConnections(); i++) { threads.pause(25); } testUtil.assertConnectViaJDBC(url, true); mysqldResource.start(threadName, args); Shell s2 = mysqldResource.getShell(); assertEquals(s1, s2); assertTrue(s1.isDaemon()); assertRunningThenShutdown(); }
public void testEverything() throws Exception { agent = new MysqldDynamicMBeanTestAgent("mysql"); String url = "jdbc:mysql:///test" + "?" + NonRegisteringDriver.PROPERTIES_TRANSFORM_KEY + "=" + ConnectorMXJPropertiesTransform.class.getName(); bean = new MysqldDynamicMBean(); MysqldResourceI mysqldResource = bean.getMysqldResource(); // mysqldResource.setKillDelay(3000); agent.addBean("mysql", "MySQL1", bean); assertEquals(false, mysqldResource.isRunning()); String port = "" + new TestUtil().testPort(); assertEquals("3306", mysqldResource.getServerOptions().get( MysqldResourceI.PORT)); bean.setAttribute(new Attribute(MysqldResourceI.PORT, port)); bean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); int i = 0; while (++i < 100) { if (mysqldResource.isRunning()) { break; } threads.pause(50); } assertTrue("still not started: " + i, mysqldResource.isRunning()); assertEquals(port, mysqldResource.getServerOptions().get( MysqldResourceI.PORT)); new TestUtil().assertConnectViaJDBC(url); }
public void testUseDatabase() throws Exception { String url = "jdbc:mysql://localhost:" + testUtil.testPort() + "/test"; String threadName = "testLaunch"; assertFalse("mysqld should not be running", mysqldResource.isRunning()); startMysql(threadName); Shell s1 = mysqldResource.getShell(); /* this asserts the thread starts */ assertRunning(); /* pause for mysqld to bind to port */ for (int i = 0; i < 100 && !mysqldResource.isReadyForConnections(); i++) { utils.threads().pause(25); } testUtil.assertConnectViaJDBC(url); if (!mysqldResource.isWindows()) { File sockFile = new File(mysqldResource.getDataDir(), "mysql.sock"); assertTrue(sockFile.exists()); } mysqldResource.start(threadName, new HashMap()); Shell s2 = mysqldResource.getShell(); assertEquals(s1, s2); assertTrue(s1.isDaemon()); assertRunningThenShutdown(); }
public void testLaunch() throws Exception { Map args = new HashMap(); String port = "" + testUtil.testPort(); args.put(MysqldResourceI.PORT, port); String url = "jdbc:mysql://localhost:" + port + "/test"; String threadName = "testLaunch"; assertFalse("mysqld should not be running", mysqldResource.isRunning()); mysqldResource.start(threadName, args); Shell s1 = mysqldResource.getShell(); /* this asserts the thread starts */ assertRunning(); /* pause for mysqld to bind to port */ for (int i = 0; i < 100 && !mysqldResource.isReadyForConnections(); i++) { utils.threads().pause(25); } testUtil.assertConnectViaJDBC(url, true); mysqldResource.start(threadName, args); Shell s2 = mysqldResource.getShell(); assertEquals(s1, s2); assertTrue(s1.isDaemon()); assertRunningThenShutdown(); }
public void testUseDatabase() throws Exception { String url = "jdbc:mysql://localhost:" + testUtil.testPort() + "/test"; String threadName = "testLaunch"; assertFalse("mysqld should not be running", mysqldResource.isRunning()); startMysql(threadName); Shell s1 = mysqldResource.getShell(); /* this asserts the thread starts */ assertRunning(); /* pause for mysqld to bind to port */ for (int i = 0; i < 100 && !mysqldResource.isReadyForConnections(); i++) { threads.pause(25); } testUtil.assertConnectViaJDBC(url); mysqldResource.start(threadName, new HashMap()); Shell s2 = mysqldResource.getShell(); assertEquals(s1, s2); assertTrue(s1.isDaemon()); assertRunningThenShutdown(); }
public void testEverything() throws Exception { agent = new MysqldDynamicMBeanTestAgent("mysql"); String url = "jdbc:mysql:///test" + "?" + NonRegisteringDriver.PROPERTIES_TRANSFORM_KEY + "=" + ConnectorMXJPropertiesTransform.class.getName(); bean = new MysqldDynamicMBean(); bean.getMysqldResource().setKillDelay(testUtil.testKillDelay()); agent.addBean("mysql", "MySQL1", bean); assertEquals(false, bean.getMysqldResource().isRunning()); String port = "" + testUtil.testPort(); assertEquals("3306", bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); bean.setAttribute(new Attribute(MysqldResourceI.PORT, port)); bean.invoke(SimpleMysqldDynamicMBean.START_METHOD, null, null); int i = 0; while (++i < 100) { if (bean.getMysqldResource().isRunning()) { break; } threads.pause(50); } assertTrue("still not started: " + i, bean.getMysqldResource() .isRunning()); assertEquals(port, bean.getMysqldResource().getServerOptions().get( MysqldResourceI.PORT)); new TestUtil().assertConnectViaJDBC(url); }
new TestUtil().assertConnectViaJDBC(url);