Author: rob.stryker(a)jboss.com
Date: 2009-11-10 16:04:56 -0500 (Tue, 10 Nov 2009)
New Revision: 18583
Added:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXCoreAllTests.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXTestPlugin.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/MockConnectionWrapper.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/NodeBuilderTestCase.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/
Removed:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/DefaultProviderTest.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXCoreAllTests.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXTestPlugin.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/MockConnectionWrapper.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/NodeBuilderTestCase.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/util/
Modified:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/META-INF/MANIFEST.MF
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/FileUtil.java
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/TestProjectProvider.java
Log:
JBIDE-5180 test issue, rename package
Modified: trunk/jmx/tests/org.jboss.tools.jmx.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jmx/tests/org.jboss.tools.jmx.core.test/META-INF/MANIFEST.MF 2009-11-10 21:03:29
UTC (rev 18582)
+++ trunk/jmx/tests/org.jboss.tools.jmx.core.test/META-INF/MANIFEST.MF 2009-11-10 21:04:56
UTC (rev 18583)
@@ -3,7 +3,7 @@
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.jmx.core.test
Bundle-Version: 1.0.1.qualifier
-Bundle-Activator: org.jboss.tools.jmx.core.tests.JMXTestPlugin
+Bundle-Activator: org.jboss.tools.jmx.core.test.JMXTestPlugin
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %BundleProvider
@@ -14,7 +14,7 @@
org.eclipse.debug.core,
org.eclipse.jdt.launching,
org.jboss.tools.tests
-Export-Package: org.jboss.tools.jmx.core.tests,
- org.jboss.tools.jmx.core.tests.util
+Export-Package: org.jboss.tools.jmx.core.test,
+ org.jboss.tools.jmx.core.test.util
Bundle-ClassPath: .
Import-Package: org.jboss.tools.jmx.core
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java
(from rev 18575,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/DefaultProviderTest.java)
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java
(rev 0)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/DefaultProviderTest.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -0,0 +1,170 @@
+package org.jboss.tools.jmx.core.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.IStreamListener;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamMonitor;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.jboss.tools.jmx.core.ExtensionManager;
+import org.jboss.tools.jmx.core.IConnectionProvider;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.providers.DefaultConnectionProvider;
+import org.jboss.tools.jmx.core.test.util.TestProjectProvider;
+import org.jboss.tools.jmx.core.tree.DomainNode;
+import org.jboss.tools.jmx.core.tree.Node;
+import org.jboss.tools.jmx.core.tree.Root;
+import org.jboss.tools.test.util.JobUtils;
+
+public class DefaultProviderTest extends TestCase {
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testExtensionExists() {
+ String providerClass =
"org.jboss.tools.jmx.core.providers.DefaultConnectionProvider";
+ IExtension[] extensions = findExtension(ExtensionManager.MBEAN_CONNECTION);
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement elements[] = extensions[i]
+ .getConfigurationElements();
+ for( int j = 0; j < elements.length; j++ ) {
+ if( elements[j].getAttribute("class").equals(providerClass))
+ return;
+ }
+ }
+ fail("Default Provider extension not found");
+ }
+
+ public void testProviderExists() throws Exception {
+ IConnectionProvider defProvider = null;
+ IConnectionProvider[] providers = ExtensionManager.getProviders();
+ for( int i = 0; i < providers.length; i++ ) {
+ if( providers[i].getId().equals(DefaultConnectionProvider.PROVIDER_ID))
+ defProvider = providers[i];
+ }
+ if( defProvider == null )
+ fail("Default Provider not found");
+
+ defProvider = ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
+ if( defProvider == null )
+ fail("Default Provider not found 2");
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testConnection() throws Exception {
+ TestProjectProvider projectProvider;
+ IProject project;
+ projectProvider = new TestProjectProvider(JMXTestPlugin.PLUGIN_ID,
+ "projects" + Path.SEPARATOR + "JMX_EXAMPLE",
+ null, true);
+ project = projectProvider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+
+ ILaunchConfigurationWorkingCopy wc = createLaunch();
+ ILaunch launch = wc.launch("run", new NullProgressMonitor());
+
+
+ /* */
+ IProcess p = launch.getProcesses()[0];
+ p.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ System.out.println("[error] " + text);
+ }
+ });
+ p.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {
+ public void streamAppended(String text, IStreamMonitor monitor) {
+ System.out.println("[out] " + text);
+ }
+ });
+
+ /* */
+ Thread.sleep(10000);
+
+ try {
+ IConnectionProvider defProvider =
+ ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
+ HashMap map = new HashMap();
+ map.put(DefaultConnectionProvider.ID, "Test Connection");
+ map.put(DefaultConnectionProvider.URL,
"service:jmx:rmi:///jndi/rmi://localhost:9999" +
+ "/jmxrmi");
+ map.put(DefaultConnectionProvider.USERNAME, "");
+ map.put(DefaultConnectionProvider.PASSWORD, "");
+ IConnectionWrapper wrapper = defProvider.createConnection(map);
+ assertTrue("Connection was null", wrapper != null);
+
+ wrapper.connect();
+ Root root = wrapper.getRoot();
+ assertTrue("Root was not null", root == null);
+
+ wrapper.loadRoot(new NullProgressMonitor());
+ root = wrapper.getRoot();
+ assertTrue("Root was null", root != null);
+
+ Node[] children = root.getChildren();
+ assertTrue("children were null", children != null);
+ assertTrue("children length was less than 1", children.length >= 0);
+
+ boolean found = false;
+ for( int i = 0; i < children.length; i++ )
+ if( children[i] instanceof DomainNode &&
((DomainNode)children[i]).getDomain().equals("com.example.mbeans"))
+ found = true;
+
+ assertTrue("Domain \"com.example\" not found", found);
+ } finally {
+ projectProvider.dispose();
+ launch.terminate();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected ILaunchConfigurationWorkingCopy createLaunch() throws Exception {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
+ ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null,
"Test1");
+
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
"JMX_EXAMPLE");
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
"com.example.mbeans.Main");
+ wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_PATHS",
+ new ArrayList(Arrays.asList(new String[] {
+ "/JMX_EXAMPLE/src/com/example/mbeans/Main.java"
+ })));
+ wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
+ new ArrayList(Arrays.asList(new String[] {"1"})));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
+ "-Dcom.sun.management.jmxremote.port=9999 " +
+ "-Dcom.sun.management.jmxremote.authenticate=false " +
+ "-Dcom.sun.management.jmxremote.ssl=false");
+ return wc;
+ }
+
+ private static IExtension[] findExtension(String extensionId) {
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry
+ .getExtensionPoint(extensionId);
+ return extensionPoint.getExtensions();
+ }
+}
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXCoreAllTests.java
(from rev 18582,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXCoreAllTests.java)
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXCoreAllTests.java
(rev 0)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXCoreAllTests.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -0,0 +1,16 @@
+package org.jboss.tools.jmx.core.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class JMXCoreAllTests extends TestSuite {
+ public static Test suite(){
+ return new JMXCoreAllTests();
+ }
+
+ public JMXCoreAllTests() {
+ super("JMX Core All Tests");
+ addTest(new TestSuite(DefaultProviderTest.class));
+ addTest(new TestSuite(NodeBuilderTestCase.class));
+ }
+}
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXTestPlugin.java
(from rev 18575,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXTestPlugin.java)
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXTestPlugin.java
(rev 0)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/JMXTestPlugin.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -0,0 +1,44 @@
+package org.jboss.tools.jmx.core.test;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+
+public class JMXTestPlugin extends Plugin {
+
+ public static final String PLUGIN_ID = "org.jboss.tools.jmx.core.test";
//$NON-NLS-1$
+ private static JMXTestPlugin plugin;
+ public JMXTestPlugin() {
+ super();
+ }
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+ public static JMXTestPlugin getDefault() {
+ return plugin;
+ }
+
+ public static void log(IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+ public static void log(Throwable e) {
+ log(e.getMessage(), e);
+ }
+
+ public static void log(String message, Throwable e) {
+ log(IStatus.ERROR, message, e);
+ }
+
+ public static void log(int severity, String message, Throwable e) {
+ log(new Status(severity, PLUGIN_ID, 0, message, e));
+ }
+}
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/MockConnectionWrapper.java
(from rev 18575,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/MockConnectionWrapper.java)
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/MockConnectionWrapper.java
(rev 0)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/MockConnectionWrapper.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -0,0 +1,44 @@
+package org.jboss.tools.jmx.core.test;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.tools.jmx.core.IConnectionProvider;
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.IJMXRunnable;
+import org.jboss.tools.jmx.core.JMXException;
+import org.jboss.tools.jmx.core.tree.Root;
+
+
+public class MockConnectionWrapper implements IConnectionWrapper {
+
+ public boolean canControl() {
+ return false;
+ }
+
+ public void connect() throws IOException {
+ }
+
+ public void disconnect() throws IOException {
+ }
+
+ public IConnectionProvider getProvider() {
+ return null;
+ }
+
+ public Root getRoot() {
+ return null;
+ }
+
+ public boolean isConnected() {
+ return false;
+ }
+
+ public void run(IJMXRunnable runnable) throws JMXException {
+ }
+
+ public void loadRoot(IProgressMonitor monitor) {
+ }
+
+}
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/NodeBuilderTestCase.java
(from rev 18575,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/NodeBuilderTestCase.java)
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/NodeBuilderTestCase.java
(rev 0)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/NodeBuilderTestCase.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Jeff Mesnil
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.jboss.tools.jmx.core.test;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.tools.jmx.core.IConnectionWrapper;
+import org.jboss.tools.jmx.core.tree.DomainNode;
+import org.jboss.tools.jmx.core.tree.Node;
+import org.jboss.tools.jmx.core.tree.NodeBuilder;
+import org.jboss.tools.jmx.core.tree.ObjectNameNode;
+import org.jboss.tools.jmx.core.tree.PropertyNode;
+
+import junit.framework.TestCase;
+
+public class NodeBuilderTestCase extends TestCase {
+
+ private IConnectionWrapper mockConn;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mockConn = new MockConnectionWrapper();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mockConn = null;
+ super.tearDown();
+ }
+
+ public void testOneObjectName() throws Exception {
+ ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
+
+ Node root = NodeBuilder.createRoot(mockConn);
+ NodeBuilder.addToTree(root, on);
+
+ Node[] children = root.getChildren();
+ assertEquals(1, children.length);
+ assertTrue(children[0] instanceof DomainNode);
+ DomainNode domainNode = (DomainNode) children[0];
+ assertEquals("test", domainNode.getDomain()); //$NON-NLS-1$
+
+ children = domainNode.getChildren();
+ assertEquals(1, children.length);
+ assertTrue(children[0] instanceof PropertyNode);
+ PropertyNode typeNode = (PropertyNode) children[0];
+ assertEquals("type", typeNode.getKey()); //$NON-NLS-1$
+ assertEquals("Test", typeNode.getValue()); //$NON-NLS-1$
+
+ children = typeNode.getChildren();
+ assertEquals(1, children.length);
+ assertTrue(children[0] instanceof ObjectNameNode);
+ ObjectNameNode onNode = (ObjectNameNode) children[0];
+ assertEquals(on, onNode.getObjectName());
+ }
+
+ public void testTwoObjectNames() throws Exception {
+ ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
+ ObjectName on2 = new ObjectName("test:type=Test,name=Test2");
//$NON-NLS-1$
+
+ Node root = NodeBuilder.createRoot(mockConn);
+ NodeBuilder.addToTree(root, on);
+ NodeBuilder.addToTree(root, on2);
+
+ Node[] children = root.getChildren();
+ assertEquals(1, children.length);
+ assertTrue(children[0] instanceof DomainNode);
+ DomainNode domainNode = (DomainNode) children[0];
+ assertEquals("test", domainNode.getDomain()); //$NON-NLS-1$
+
+ children = domainNode.getChildren();
+ assertEquals(1, children.length);
+ assertTrue(children[0] instanceof PropertyNode);
+ PropertyNode typeNode = (PropertyNode) children[0];
+ assertEquals("type", typeNode.getKey()); //$NON-NLS-1$
+ assertEquals("Test", typeNode.getValue()); //$NON-NLS-1$
+
+ children = typeNode.getChildren();
+ assertEquals(2, children.length);
+ assertTrue(children[0] instanceof ObjectNameNode);
+ assertTrue(children[1] instanceof ObjectNameNode);
+ ObjectNameNode onNode = (ObjectNameNode) children[0];
+ ObjectNameNode onNode2 = (ObjectNameNode) children[1];
+ assertEquals(on, onNode.getObjectName());
+ assertEquals(on2, onNode2.getObjectName());
+ }
+
+ public void testTwoDifferentDomains() throws Exception {
+ ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
+ ObjectName other = new ObjectName("other:type=Test,name=Test2");
//$NON-NLS-1$
+
+ Node root = NodeBuilder.createRoot(mockConn);
+ NodeBuilder.addToTree(root, on);
+ NodeBuilder.addToTree(root, other);
+
+ Node[] children = root.getChildren();
+ assertEquals(2, children.length);
+ assertTrue(children[0] instanceof DomainNode);
+ assertTrue(children[1] instanceof DomainNode);
+ DomainNode domainNode1 = (DomainNode) children[0];
+ DomainNode domainNode2 = (DomainNode) children[1];
+ // domains are sorted by lexical order
+ assertEquals("other", domainNode1.getDomain()); //$NON-NLS-1$
+ assertEquals("test", domainNode2.getDomain()); //$NON-NLS-1$
+ }
+
+ public void testHierarchy() throws Exception {
+ ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
+ ObjectName on2 = new ObjectName("test:type=Test,name=Test2");
//$NON-NLS-1$
+ ObjectName on3 = new ObjectName("test:type=AnotherTest,name=Test1");
//$NON-NLS-1$
+ ObjectName on4 = new ObjectName("test:type=AnotherTest,name=Test2");
//$NON-NLS-1$
+ ObjectName on5 = new ObjectName("other:type=Test,name=Test1");
//$NON-NLS-1$
+
+ Node root = NodeBuilder.createRoot(mockConn);
+ NodeBuilder.addToTree(root, on);
+ NodeBuilder.addToTree(root, on2);
+ NodeBuilder.addToTree(root, on3);
+ NodeBuilder.addToTree(root, on4);
+ NodeBuilder.addToTree(root, on5);
+ }
+}
Copied:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util (from
rev 18575,
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/util)
Modified:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/FileUtil.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/util/FileUtil.java 2009-11-10
17:52:27 UTC (rev 18575)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/FileUtil.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -8,7 +8,7 @@
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jmx.core.tests.util;
+package org.jboss.tools.jmx.core.test.util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -41,7 +41,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.jboss.tools.jmx.core.tests.JMXTestPlugin;
+import org.jboss.tools.jmx.core.test.JMXTestPlugin;
public final class FileUtil {
Modified:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/TestProjectProvider.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/util/TestProjectProvider.java 2009-11-10
17:52:27 UTC (rev 18575)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/test/util/TestProjectProvider.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -8,7 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jmx.core.tests.util;
+package org.jboss.tools.jmx.core.test.util;
import java.io.File;
import java.io.IOException;
@@ -29,7 +29,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.jboss.tools.jmx.core.tests.JMXTestPlugin;
+import org.jboss.tools.jmx.core.test.JMXTestPlugin;
import org.osgi.framework.Bundle;
/**
Deleted:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/DefaultProviderTest.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/DefaultProviderTest.java 2009-11-10
21:03:29 UTC (rev 18582)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/DefaultProviderTest.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -1,170 +0,0 @@
-package org.jboss.tools.jmx.core.tests;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.jboss.tools.jmx.core.ExtensionManager;
-import org.jboss.tools.jmx.core.IConnectionProvider;
-import org.jboss.tools.jmx.core.IConnectionWrapper;
-import org.jboss.tools.jmx.core.providers.DefaultConnectionProvider;
-import org.jboss.tools.jmx.core.tests.util.TestProjectProvider;
-import org.jboss.tools.jmx.core.tree.DomainNode;
-import org.jboss.tools.jmx.core.tree.Node;
-import org.jboss.tools.jmx.core.tree.Root;
-import org.jboss.tools.test.util.JobUtils;
-
-public class DefaultProviderTest extends TestCase {
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testExtensionExists() {
- String providerClass =
"org.jboss.tools.jmx.core.providers.DefaultConnectionProvider";
- IExtension[] extensions = findExtension(ExtensionManager.MBEAN_CONNECTION);
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement elements[] = extensions[i]
- .getConfigurationElements();
- for( int j = 0; j < elements.length; j++ ) {
- if( elements[j].getAttribute("class").equals(providerClass))
- return;
- }
- }
- fail("Default Provider extension not found");
- }
-
- public void testProviderExists() throws Exception {
- IConnectionProvider defProvider = null;
- IConnectionProvider[] providers = ExtensionManager.getProviders();
- for( int i = 0; i < providers.length; i++ ) {
- if( providers[i].getId().equals(DefaultConnectionProvider.PROVIDER_ID))
- defProvider = providers[i];
- }
- if( defProvider == null )
- fail("Default Provider not found");
-
- defProvider = ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
- if( defProvider == null )
- fail("Default Provider not found 2");
-
- }
-
- @SuppressWarnings("unchecked")
- public void testConnection() throws Exception {
- TestProjectProvider projectProvider;
- IProject project;
- projectProvider = new TestProjectProvider(JMXTestPlugin.PLUGIN_ID,
- "projects" + Path.SEPARATOR + "JMX_EXAMPLE",
- null, true);
- project = projectProvider.getProject();
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- JobUtils.waitForIdle();
-
- ILaunchConfigurationWorkingCopy wc = createLaunch();
- ILaunch launch = wc.launch("run", new NullProgressMonitor());
-
-
- /* */
- IProcess p = launch.getProcesses()[0];
- p.getStreamsProxy().getErrorStreamMonitor().addListener(new IStreamListener() {
- public void streamAppended(String text, IStreamMonitor monitor) {
- System.out.println("[error] " + text);
- }
- });
- p.getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {
- public void streamAppended(String text, IStreamMonitor monitor) {
- System.out.println("[out] " + text);
- }
- });
-
- /* */
- Thread.sleep(10000);
-
- try {
- IConnectionProvider defProvider =
- ExtensionManager.getProvider(DefaultConnectionProvider.PROVIDER_ID);
- HashMap map = new HashMap();
- map.put(DefaultConnectionProvider.ID, "Test Connection");
- map.put(DefaultConnectionProvider.URL,
"service:jmx:rmi:///jndi/rmi://localhost:9999" +
- "/jmxrmi");
- map.put(DefaultConnectionProvider.USERNAME, "");
- map.put(DefaultConnectionProvider.PASSWORD, "");
- IConnectionWrapper wrapper = defProvider.createConnection(map);
- assertTrue("Connection was null", wrapper != null);
-
- wrapper.connect();
- Root root = wrapper.getRoot();
- assertTrue("Root was not null", root == null);
-
- wrapper.loadRoot(new NullProgressMonitor());
- root = wrapper.getRoot();
- assertTrue("Root was null", root != null);
-
- Node[] children = root.getChildren();
- assertTrue("children were null", children != null);
- assertTrue("children length was less than 1", children.length >= 0);
-
- boolean found = false;
- for( int i = 0; i < children.length; i++ )
- if( children[i] instanceof DomainNode &&
((DomainNode)children[i]).getDomain().equals("com.example.mbeans"))
- found = true;
-
- assertTrue("Domain \"com.example\" not found", found);
- } finally {
- projectProvider.dispose();
- launch.terminate();
- }
- }
-
- @SuppressWarnings("unchecked")
- protected ILaunchConfigurationWorkingCopy createLaunch() throws Exception {
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType launchConfigType =
launchManager.getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
- ILaunchConfigurationWorkingCopy wc = launchConfigType.newInstance(null,
"Test1");
-
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
"JMX_EXAMPLE");
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
"com.example.mbeans.Main");
- wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_PATHS",
- new ArrayList(Arrays.asList(new String[] {
- "/JMX_EXAMPLE/src/com/example/mbeans/Main.java"
- })));
- wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES",
- new ArrayList(Arrays.asList(new String[] {"1"})));
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
- "-Dcom.sun.management.jmxremote.port=9999 " +
- "-Dcom.sun.management.jmxremote.authenticate=false " +
- "-Dcom.sun.management.jmxremote.ssl=false");
- return wc;
- }
-
- private static IExtension[] findExtension(String extensionId) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry
- .getExtensionPoint(extensionId);
- return extensionPoint.getExtensions();
- }
-}
Deleted:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXCoreAllTests.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXCoreAllTests.java 2009-11-10
21:03:29 UTC (rev 18582)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXCoreAllTests.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -1,16 +0,0 @@
-package org.jboss.tools.jmx.core.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JMXCoreAllTests extends TestSuite {
- public static Test suite(){
- return new JMXCoreAllTests();
- }
-
- public JMXCoreAllTests() {
- super("JMX Core All Tests");
- addTest(new TestSuite(DefaultProviderTest.class));
- addTest(new TestSuite(NodeBuilderTestCase.class));
- }
-}
Deleted:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXTestPlugin.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXTestPlugin.java 2009-11-10
21:03:29 UTC (rev 18582)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/JMXTestPlugin.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -1,44 +0,0 @@
-package org.jboss.tools.jmx.core.tests;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-
-
-public class JMXTestPlugin extends Plugin {
-
- public static final String PLUGIN_ID = "org.jboss.tools.jmx.core.test";
//$NON-NLS-1$
- private static JMXTestPlugin plugin;
- public JMXTestPlugin() {
- super();
- }
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
- public static JMXTestPlugin getDefault() {
- return plugin;
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void log(Throwable e) {
- log(e.getMessage(), e);
- }
-
- public static void log(String message, Throwable e) {
- log(IStatus.ERROR, message, e);
- }
-
- public static void log(int severity, String message, Throwable e) {
- log(new Status(severity, PLUGIN_ID, 0, message, e));
- }
-}
Deleted:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/MockConnectionWrapper.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/MockConnectionWrapper.java 2009-11-10
21:03:29 UTC (rev 18582)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/MockConnectionWrapper.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -1,44 +0,0 @@
-package org.jboss.tools.jmx.core.tests;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.jmx.core.IConnectionProvider;
-import org.jboss.tools.jmx.core.IConnectionWrapper;
-import org.jboss.tools.jmx.core.IJMXRunnable;
-import org.jboss.tools.jmx.core.JMXException;
-import org.jboss.tools.jmx.core.tree.Root;
-
-
-public class MockConnectionWrapper implements IConnectionWrapper {
-
- public boolean canControl() {
- return false;
- }
-
- public void connect() throws IOException {
- }
-
- public void disconnect() throws IOException {
- }
-
- public IConnectionProvider getProvider() {
- return null;
- }
-
- public Root getRoot() {
- return null;
- }
-
- public boolean isConnected() {
- return false;
- }
-
- public void run(IJMXRunnable runnable) throws JMXException {
- }
-
- public void loadRoot(IProgressMonitor monitor) {
- }
-
-}
Deleted:
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/NodeBuilderTestCase.java
===================================================================
---
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/NodeBuilderTestCase.java 2009-11-10
21:03:29 UTC (rev 18582)
+++
trunk/jmx/tests/org.jboss.tools.jmx.core.test/src/org/jboss/tools/jmx/core/tests/NodeBuilderTestCase.java 2009-11-10
21:04:56 UTC (rev 18583)
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Jeff Mesnil
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- *
http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.jboss.tools.jmx.core.tests;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import org.jboss.tools.jmx.core.IConnectionWrapper;
-import org.jboss.tools.jmx.core.tree.DomainNode;
-import org.jboss.tools.jmx.core.tree.Node;
-import org.jboss.tools.jmx.core.tree.NodeBuilder;
-import org.jboss.tools.jmx.core.tree.ObjectNameNode;
-import org.jboss.tools.jmx.core.tree.PropertyNode;
-
-import junit.framework.TestCase;
-
-public class NodeBuilderTestCase extends TestCase {
-
- private IConnectionWrapper mockConn;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mockConn = new MockConnectionWrapper();
- }
-
- @Override
- protected void tearDown() throws Exception {
- mockConn = null;
- super.tearDown();
- }
-
- public void testOneObjectName() throws Exception {
- ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
-
- Node root = NodeBuilder.createRoot(mockConn);
- NodeBuilder.addToTree(root, on);
-
- Node[] children = root.getChildren();
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof DomainNode);
- DomainNode domainNode = (DomainNode) children[0];
- assertEquals("test", domainNode.getDomain()); //$NON-NLS-1$
-
- children = domainNode.getChildren();
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof PropertyNode);
- PropertyNode typeNode = (PropertyNode) children[0];
- assertEquals("type", typeNode.getKey()); //$NON-NLS-1$
- assertEquals("Test", typeNode.getValue()); //$NON-NLS-1$
-
- children = typeNode.getChildren();
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof ObjectNameNode);
- ObjectNameNode onNode = (ObjectNameNode) children[0];
- assertEquals(on, onNode.getObjectName());
- }
-
- public void testTwoObjectNames() throws Exception {
- ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
- ObjectName on2 = new ObjectName("test:type=Test,name=Test2");
//$NON-NLS-1$
-
- Node root = NodeBuilder.createRoot(mockConn);
- NodeBuilder.addToTree(root, on);
- NodeBuilder.addToTree(root, on2);
-
- Node[] children = root.getChildren();
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof DomainNode);
- DomainNode domainNode = (DomainNode) children[0];
- assertEquals("test", domainNode.getDomain()); //$NON-NLS-1$
-
- children = domainNode.getChildren();
- assertEquals(1, children.length);
- assertTrue(children[0] instanceof PropertyNode);
- PropertyNode typeNode = (PropertyNode) children[0];
- assertEquals("type", typeNode.getKey()); //$NON-NLS-1$
- assertEquals("Test", typeNode.getValue()); //$NON-NLS-1$
-
- children = typeNode.getChildren();
- assertEquals(2, children.length);
- assertTrue(children[0] instanceof ObjectNameNode);
- assertTrue(children[1] instanceof ObjectNameNode);
- ObjectNameNode onNode = (ObjectNameNode) children[0];
- ObjectNameNode onNode2 = (ObjectNameNode) children[1];
- assertEquals(on, onNode.getObjectName());
- assertEquals(on2, onNode2.getObjectName());
- }
-
- public void testTwoDifferentDomains() throws Exception {
- ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
- ObjectName other = new ObjectName("other:type=Test,name=Test2");
//$NON-NLS-1$
-
- Node root = NodeBuilder.createRoot(mockConn);
- NodeBuilder.addToTree(root, on);
- NodeBuilder.addToTree(root, other);
-
- Node[] children = root.getChildren();
- assertEquals(2, children.length);
- assertTrue(children[0] instanceof DomainNode);
- assertTrue(children[1] instanceof DomainNode);
- DomainNode domainNode1 = (DomainNode) children[0];
- DomainNode domainNode2 = (DomainNode) children[1];
- // domains are sorted by lexical order
- assertEquals("other", domainNode1.getDomain()); //$NON-NLS-1$
- assertEquals("test", domainNode2.getDomain()); //$NON-NLS-1$
- }
-
- public void testHierarchy() throws Exception {
- ObjectName on = new ObjectName("test:type=Test,name=Test1");
//$NON-NLS-1$
- ObjectName on2 = new ObjectName("test:type=Test,name=Test2");
//$NON-NLS-1$
- ObjectName on3 = new ObjectName("test:type=AnotherTest,name=Test1");
//$NON-NLS-1$
- ObjectName on4 = new ObjectName("test:type=AnotherTest,name=Test2");
//$NON-NLS-1$
- ObjectName on5 = new ObjectName("other:type=Test,name=Test1");
//$NON-NLS-1$
-
- Node root = NodeBuilder.createRoot(mockConn);
- NodeBuilder.addToTree(root, on);
- NodeBuilder.addToTree(root, on2);
- NodeBuilder.addToTree(root, on3);
- NodeBuilder.addToTree(root, on4);
- NodeBuilder.addToTree(root, on5);
- }
-}