protected void setUp() { fileUtil = new Files(); testUtil = new TestUtil(); }
protected void setUp() { super.setUp(); try { new com.mysql.jdbc.Driver(); } catch (SQLException e) { throw new RuntimeException(e); } orig = System.getProperty(Files.USE_TEST_DIR); System.setProperty(Files.USE_TEST_DIR, Boolean.TRUE.toString()); testUtil = new TestUtil(); }
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); } }
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(); } }
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() throws Exception { testUtil = new TestUtil(); String[] objectNames = new String[] { "mysql:name=MySQL1" }; Class mbeanClass = MysqldDynamicMBean.class; TestMBeanServer mbs = new TestMBeanServer(objectNames, mbeanClass); munger = new ConnectorMXJPropertiesTransform(mbs); }
public void testStub() throws Exception { final Method[] methods = Shell.class.getDeclaredMethods(); final Shell stub = new Shell.Stub(); final TestUtil testUtil = new TestUtil(); for (int i = 0; i < methods.length; i++) { final int x = i; testUtil.assertNotImplemented(new TestUtil.Block() { public void exec() throws Exception { testUtil.invoke(stub, methods[x]); } }); } }
public void testStub() throws Exception { final RuntimeI stub = new RuntimeI.Stub(); final TestUtil testUtil = new TestUtil(); final Method[] methods = RuntimeI.class.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { final int x = i; testUtil.assertNotImplemented(new TestUtil.Block() { public void exec() throws Exception { testUtil.invoke(stub, methods[x]); } }); } } }
public void testStub() throws Exception { new TestUtil().assertObjStubsInterface(new RuntimeI.Stub(), RuntimeI.class); } }
protected void setUp() throws Exception { testUtil = new TestUtil(); String[] objectNames = new String[] { "mysql:name=MySQL1" }; Class mbeanClass = MysqldDynamicMBean.class; TestMBeanServer mbs = new TestMBeanServer(objectNames, mbeanClass); munger = new ConnectorMXJPropertiesTransform(mbs); }
public void testStub() throws Exception { new TestUtil().assertObjStubsInterface(new Shell.Stub(), Shell.class); }
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); }
protected void setUp() { super.setUp(); fileUtil = new Files(); tmpDir = new Files().testDir(); testUtil = new TestUtil(); }
public void testOptionParser() throws Exception { String resourceVersion = new TestUtil() .getSystemPropertyWithDefaultFromResource( MysqldResourceI.MYSQLD_VERSION, MysqldResourceI.CONNECTOR_MXJ_PROPERTIES, System.err); String resourceVersionDir = resourceVersion.replaceAll("\\.", "-"); 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 Utils()); Map parsed = parser.getOptionsFromHelp(help); String optStr = new ListToString().toString(parsed); assertEquals(optStr, "TRUE", parsed.get("auto-rehash")); // assertEquals("/usr/local/mysql/", // parsed.get(MysqldResourceI.BASEDIR)); // assertEquals("FALSE", parsed.get("bdb")); // assertEquals("(No default value)", parsed.get("time-format")); // assertTrue(parsed.containsKey("time_format")); // assertEquals("", parsed.get("time_format")); }
public void testIsRunning() { String pid = "5234"; ProcessUtil kp = new ProcessUtil(pid, null, null); String[] args = kp.isRunningArgs(); new TestUtil().assertContainsIgnoreCase(args[0], "kill"); assertEquals("-0", args[1]); assertEquals(pid, args[2]); }
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()); }
protected void setUp() { super.setUp(); testUtil = new TestUtil(); threads = new Threads(); fileUtil = new TestFileUtil(); shellFactory = new Shell.Factory(); streams = new Streams(); str = new Str(); classUtil = new ClassUtil(); mysqldResource = new MysqldResource(fileUtil.nullFile(), System.out, System.err, fileUtil, shellFactory, streams, threads, str, classUtil); mysqldResource.setKillDelay(10000); File baseDir = mysqldResource.getBaseDir(); fileUtil.deleteTree(baseDir); if (baseDir.exists()) { warn("residual files"); } }
public void testGetAgentVersion() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(null, null, options, new HashMap()); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean( new TestFactory(mysqld)); String verAttName = myBean.versionAttributeName(); String expected = "$Id: " + new Str().shortClassName(myBean); String beanVersion = (String) myBean.getAttribute(verAttName); new TestUtil().assertContainsIgnoreCase(beanVersion, expected); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertFalse(atts[0].isIs()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertFalse(atts[1].isIs()); assertTrue(atts[2].isReadable()); assertFalse(atts[2].isWritable()); assertFalse(atts[2].isIs()); }
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); }
public void testGetAgentVersion() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); String verAttName = myBean.versionAttributeName(); String expected = "$Id: " + new ClassUtil().shortName(myBean); String beanVersion = (String) myBean.getAttribute(verAttName); new TestUtil().assertContainsIgnoreCase(beanVersion, expected); MBeanInfo info = myBean.getMBeanInfo(); MBeanAttributeInfo[] atts = info.getAttributes(); assertTrue(atts[0].isReadable()); assertTrue(atts[0].isWritable()); assertFalse(atts[0].isIs()); assertTrue(atts[1].isReadable()); assertTrue(atts[1].isWritable()); assertFalse(atts[1].isIs()); assertTrue(atts[2].isReadable()); assertFalse(atts[2].isWritable()); assertFalse(atts[2].isIs()); }