Remove jolokia dependency from config-subsystem. 37/3637/1
authorTomas Olvecky <tolvecky@cisco.com>
Wed, 11 Dec 2013 13:00:34 +0000 (14:00 +0100)
committerTomas Olvecky <tolvecky@cisco.com>
Wed, 11 Dec 2013 13:01:09 +0000 (14:01 +0100)
Remove jolokia client from config-util and tests that were starting jolokia.

Change-Id: Ibadf96c6d03d5cc325b4c9d8a01cdbb230550e4b
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
16 files changed:
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigWithJolokiaTest.java [deleted file]
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionManagerImplTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/AbstractParallelAPSPTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/parallelapsp/test/DependentWiringTest.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/testingservices/threadpool/test/SimpleConfigurationTest.java
opendaylight/config/config-util/pom.xml
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigRegistryJolokiaClient.java [deleted file]
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigTransactionJolokiaClient.java [deleted file]
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClient.java [deleted file]
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/ConfigRegistryClientsTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/ConfigTransactionClientsTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/JolokiaHelper.java [deleted file]
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/LookupTest.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/TestingConfigTransactionController.java
opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClientTest.java [deleted file]
opendaylight/config/pom.xml

diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigWithJolokiaTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigWithJolokiaTest.java
deleted file mode 100644 (file)
index de26220..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.manager.impl;
-
-import org.junit.After;
-import org.junit.Before;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.JolokiaHelper;
-import org.opendaylight.controller.config.util.jolokia.ConfigRegistryJolokiaClient;
-
-public class AbstractConfigWithJolokiaTest extends AbstractConfigTest {
-    protected String jolokiaURL;
-    protected ConfigRegistryJolokiaClient configRegistryJolokiaClient;
-
-    @Before
-    public void initJolokia() {
-        jolokiaURL = JolokiaHelper.startTestingJolokia();
-    }
-
-    // this method should be called in @Before
-    @Override
-    protected void initConfigTransactionManagerImpl(
-            ModuleFactoriesResolver resolver) {
-        super.initConfigTransactionManagerImpl(resolver);
-        configRegistryJolokiaClient = new ConfigRegistryJolokiaClient(
-                jolokiaURL);
-    }
-
-    @After
-    public void cleanUpJolokia() {
-        JolokiaHelper.stopJolokia();
-    }
-}
index eaaee5e..bbb3784 100644 (file)
@@ -7,23 +7,19 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-
-import javax.management.InstanceAlreadyExistsException;
-
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.api.jmx.constants.ConfigRegistryConstants;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
+
+import javax.management.InstanceAlreadyExistsException;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
 
 public class ConfigTransactionManagerImplTest extends
-        AbstractConfigWithJolokiaTest {
+        AbstractConfigTest {
 
     @Before
     public void setUp() {
@@ -55,23 +51,4 @@ public class ConfigTransactionManagerImplTest extends
         transaction.commit();
     }
 
-    @Test
-    public void testRemoteCallsUsingJolokia() throws Exception {
-
-        ConfigTransactionJolokiaClient transactionClient = configRegistryJolokiaClient
-                .createTransaction();
-
-        assertEquals("ConfigTransaction-0-1",
-                ObjectNameUtil.getTransactionName(transactionClient
-                        .getTransactionON()));
-
-        assertEquals(
-                ConfigRegistryConstants.ON_DOMAIN
-                        + ":TransactionName=ConfigTransaction-0-1,type=ConfigTransaction",
-                transactionClient.getTransactionON().getCanonicalName());
-
-        // commit
-        transactionClient.commit();
-
-    }
 }
index 7deb1ef..3d9d524 100644 (file)
@@ -7,16 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
 
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-
-import org.opendaylight.controller.config.manager.impl.AbstractConfigWithJolokiaTest;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
-abstract class AbstractParallelAPSPTest extends AbstractConfigWithJolokiaTest {
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+
+abstract class AbstractParallelAPSPTest extends AbstractConfigTest {
     protected final String fixed1 = "fixed1";
     protected final String apsp1 = "apsp-parallel";
 
index 5b1a6f6..f9a1130 100644 (file)
@@ -7,17 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.internal.matchers.StringContains.containsString;
-
-import java.util.Map;
-
-import javax.management.ObjectName;
-
-import org.json.simple.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -32,7 +21,15 @@ import org.opendaylight.controller.config.manager.testingservices.threadpool.Tes
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
+
+import javax.management.ObjectName;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.internal.matchers.StringContains.containsString;
 
 public class DependentWiringTest extends AbstractParallelAPSPTest {
     private final String fixed1 = "fixed1";
@@ -135,44 +132,4 @@ public class DependentWiringTest extends AbstractParallelAPSPTest {
                 parallelAPSPRuntimeProxy.getMaxNumberOfThreads());
 
     }
-
-    @Test
-    public void testUsingJolokia() throws Exception {
-
-        ConfigTransactionJolokiaClient transactionClient = configRegistryJolokiaClient
-                .createTransaction();
-        // fixed1
-        ObjectName fixed1ON = transactionClient.createModule(
-                getThreadPoolImplementationName(), fixed1);
-        transactionClient.setAttribute(fixed1ON, "ThreadCount",
-                TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
-
-        // apsp-parallel with syntetic attrib
-        String threadPoolString = "ThreadPool";
-        ObjectName apsp1ON = transactionClient.createModule(
-                TestingParallelAPSPModuleFactory.NAME, apsp1);
-        transactionClient.setAttribute(apsp1ON, threadPoolString, fixed1ON);
-        // check
-        assertEquals(ObjectNameUtil.withoutTransactionName(fixed1ON),
-                transactionClient.getAttributeON(apsp1ON, threadPoolString));
-        transactionClient.setAttribute(apsp1ON, "SomeParam", "ahoj");
-
-        // commit
-        transactionClient.commit();
-        // check thread pool
-        assertEquals(1, TestingFixedThreadPool.allExecutors.size());
-        // check platform MBeanServer
-        ObjectName apspReadOnlyON = ObjectNameUtil
-                .withoutTransactionName(apsp1ON);
-        JSONObject threadPoolONJson = (JSONObject) configRegistryJolokiaClient
-                .getAttribute(apspReadOnlyON, threadPoolString);
-        ObjectName fixed1ReadOnlyON = ObjectNameUtil
-                .withoutTransactionName(fixed1ON);
-        assertEquals(fixed1ReadOnlyON, ObjectNameUtil.createON(threadPoolONJson
-                .get("objectName").toString()));
-        assertEquals(fixed1ReadOnlyON,
-                configRegistryJolokiaClient.getAttributeON(apspReadOnlyON,
-                        threadPoolString));
-
-    }
 }
index c2f2558..13bb840 100644 (file)
@@ -7,28 +7,6 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.threadpool.test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeMBeanException;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,14 +15,32 @@ import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigWithJolokiaTest;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPool;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
+
+import javax.management.DynamicMBean;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.RuntimeMBeanException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadPoolExecutor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Tests basic functionality of configuration registry:
@@ -58,7 +54,7 @@ import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaC
  * Only one bean is being configured - {@link TestingThreadPoolIfc} which has no
  * dependencies.
  */
-public class SimpleConfigurationTest extends AbstractConfigWithJolokiaTest {
+public class SimpleConfigurationTest extends AbstractConfigTest {
     private final int numberOfThreads = 5;
     private final int numberOfThreads2 = 10;
     private static final String fixed1 = "fixed1";
@@ -134,12 +130,6 @@ public class SimpleConfigurationTest extends AbstractConfigWithJolokiaTest {
         testValidation(transaction);
     }
 
-    @Test
-    public void testValidationUsingJolokiaClient() throws Exception {
-        ConfigTransactionClient transaction = configRegistryJolokiaClient
-                .createTransaction();
-        testValidation(transaction);
-    }
 
     private void testValidation(ConfigTransactionClient transaction)
             throws InstanceAlreadyExistsException, ReflectionException,
@@ -393,68 +383,5 @@ public class SimpleConfigurationTest extends AbstractConfigWithJolokiaTest {
         }
     }
 
-    @Test
-    public void testOptimisticLock_ConfigTransactionJolokiaClient()
-            throws Exception {
-        ConfigTransactionJolokiaClient transaction1 = configRegistryJolokiaClient
-                .createTransaction();
-        ConfigTransactionJolokiaClient transaction2 = configRegistryJolokiaClient
-                .createTransaction();
-        transaction2.assertVersion(0, 2);
-        transaction2.commit();
-        try {
-            transaction1.commit();
-            fail();
-        } catch (ConflictingVersionException e) {
-            assertEquals(
-                    "Optimistic lock failed. Expected parent version 2, was 0",
-                    e.getMessage());
-        }
-    }
-
-    @Test
-    public void testOptimisticLock_ConfigRegistryJolokiaClient()
-            throws Exception {
-        ConfigTransactionJolokiaClient transaction1 = configRegistryJolokiaClient
-                .createTransaction();
-        ConfigTransactionJolokiaClient transaction2 = configRegistryJolokiaClient
-                .createTransaction();
-        transaction2.assertVersion(0, 2);
-        transaction2.commit();
-        try {
-            configRegistryJolokiaClient.commitConfig(transaction1
-                    .getObjectName());
-            fail();
-        } catch (ConflictingVersionException e) {
-            assertEquals(
-                    "Optimistic lock failed. Expected parent version 2, was 0",
-                    e.getMessage());
-        }
-    }
-
-    @Test
-    public void testUsingJolokia() throws Exception {
-        ConfigTransactionJolokiaClient transactionClient = configRegistryJolokiaClient
-                .createTransaction();
-
-        ObjectName name = transactionClient.createModule(
-                TestingFixedThreadPoolModuleFactory.NAME, fixed1);
-
-        try {
-            transactionClient.validateConfig();
-            fail();
-        } catch (ValidationException e) {
-            assertThat(
-                    e.getMessage(),
-                    containsString("Parameter 'threadCount' must be greater than 0"));
-        }
-
-        transactionClient.setAttribute(name, "ThreadCount", numberOfThreads);
-        // commit
-        CommitStatus commitStatus = transactionClient.commit();
-        CommitStatus expected = new CommitStatus(Arrays.asList(ObjectNameUtil
-                .withoutTransactionName(name)), emptyONs, emptyONs);
-        assertEquals(expected, commitStatus);
-    }
 
 }
index 206184c..23603ae 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>config-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.jolokia</groupId>
-            <artifactId>jolokia-client-java</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.jolokia</groupId>
-            <artifactId>jolokia-jvm</artifactId>
-            <classifier>agent</classifier>
-        </dependency>
-
         <!-- test dependencies -->
         <dependency>
             <groupId>com.google.guava</groupId>
diff --git a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigRegistryJolokiaClient.java b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigRegistryJolokiaClient.java
deleted file mode 100644 (file)
index 9d55f8d..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.util.jolokia;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
-import org.jolokia.client.request.J4pExecRequest;
-import org.jolokia.client.request.J4pReadRequest;
-import org.jolokia.client.request.J4pResponse;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.util.ConfigRegistryClient;
-
-@Deprecated
-public class ConfigRegistryJolokiaClient extends ListableJolokiaClient
-        implements ConfigRegistryClient {
-
-    public ConfigRegistryJolokiaClient(String url) {
-        super(url, ConfigRegistryMXBean.OBJECT_NAME);
-    }
-
-    @Override
-    public ConfigTransactionJolokiaClient createTransaction() {
-        // create transaction
-        J4pExecRequest execReq = new J4pExecRequest(objectName, "beginConfig");
-        J4pResponse<J4pExecRequest> resp = execute(execReq);
-        ObjectName transactionControllerON = extractObjectName(resp);
-        return getConfigTransactionClient(transactionControllerON);
-    }
-
-    @Override
-    public ConfigTransactionJolokiaClient getConfigTransactionClient(
-            String transactionName) {
-        ObjectName objectName = ObjectNameUtil
-                .createTransactionControllerON(transactionName);
-        return getConfigTransactionClient(objectName);
-    }
-
-    @Override
-    public ConfigTransactionJolokiaClient getConfigTransactionClient(
-            ObjectName objectName) {
-        return new ConfigTransactionJolokiaClient(url, objectName, this);
-    }
-
-    @Override
-    public CommitStatus commitConfig(ObjectName transactionControllerON)
-            throws ConflictingVersionException, ValidationException {
-        J4pExecRequest execReq = new J4pExecRequest(objectName, "commitConfig",
-                transactionControllerON);
-        JSONObject jsonObject;
-        jsonObject = execute(execReq).getValue();
-        JSONArray newInstancesArray = (JSONArray) jsonObject
-                .get("newInstances");
-        List<ObjectName> newInstances = jsonArrayToObjectNames(newInstancesArray);
-        JSONArray reusedInstancesArray = (JSONArray) jsonObject
-                .get("reusedInstances");
-        List<ObjectName> reusedInstances = jsonArrayToObjectNames(reusedInstancesArray);
-        JSONArray recreatedInstancesArray = (JSONArray) jsonObject
-                .get("recreatedInstances");
-        List<ObjectName> recreatedInstances = jsonArrayToObjectNames(recreatedInstancesArray);
-        return new CommitStatus(newInstances, reusedInstances,
-                recreatedInstances);
-    }
-
-    public Object getAttribute(ObjectName configBeanTransactionON, String key) {
-        J4pReadRequest req = new J4pReadRequest(configBeanTransactionON, key);
-        return execute(req).getValue();
-    }
-
-    public ObjectName getAttributeON(ObjectName configBeanTransactionON,
-            String key) {
-        JSONObject jsonAttrib = (JSONObject) getAttribute(
-                configBeanTransactionON, key);
-        return extractObjectName(jsonAttrib);
-    }
-
-    // proxy around ConfigTransactionManagerMXBean
-
-    @Override
-    public ObjectName beginConfig() {
-        ConfigTransactionJolokiaClient result = createTransaction();
-        return result.getTransactionON();
-    }
-
-    @Override
-    public List<ObjectName> getOpenConfigs() {
-        J4pReadRequest req = new J4pReadRequest(objectName, "OpenConfigs");
-        JSONArray jsonArray = execute(req).getValue();
-        return jsonArrayToObjectNames(jsonArray);
-    }
-
-    @Override
-    public long getVersion() {
-        J4pReadRequest req = new J4pReadRequest(objectName, "Version");
-        return (Long) execute(req).getValue();
-    }
-
-    @Override
-    public boolean isHealthy() {
-        J4pReadRequest req = new J4pReadRequest(objectName, "Healthy");
-        return (Boolean) execute(req).getValue();
-    }
-
-    @Override
-    public Set<ObjectName> lookupRuntimeBeans() {
-        return lookupSomething("lookupRuntimeBeans()", new Object[0]);
-    }
-
-    @Override
-    public Set<ObjectName> lookupRuntimeBeans(String moduleName,
-            String instanceName) {
-        return lookupSomething(
-                "lookupRuntimeBeans(java.lang.String,java.lang.String)",
-                new Object[] { moduleName, instanceName });
-    }
-
-    @Override
-    public Object invokeMethod(ObjectName on, String name, Object[] params,
-            String[] signature) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Object getAttributeCurrentValue(ObjectName on, String attributeName) {
-        throw new UnsupportedOperationException();
-    }
-
-    // TODO: implement or deprecate
-    @Override
-    public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceName, String refName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Map<String, ObjectName>> getServiceMapping() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getServiceInterfaceName(String namespace, String localName) {
-        throw new UnsupportedOperationException();
-    }
-}
diff --git a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigTransactionJolokiaClient.java b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ConfigTransactionJolokiaClient.java
deleted file mode 100644 (file)
index 834e9c6..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.util.jolokia;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
-import org.jolokia.client.request.J4pExecRequest;
-import org.jolokia.client.request.J4pReadRequest;
-import org.jolokia.client.request.J4pWriteRequest;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.util.AttributeEntry;
-import org.opendaylight.controller.config.util.ConfigTransactionClient;
-
-@Deprecated
-public class ConfigTransactionJolokiaClient extends ListableJolokiaClient
-        implements ConfigTransactionClient {
-
-    private final ConfigRegistryJolokiaClient configRegistryJolokiaClient;
-
-    public ConfigTransactionJolokiaClient(String url,
-            ObjectName transactionControllerON,
-            ConfigRegistryJolokiaClient configRegistryJolokiaClient) {
-        super(url, transactionControllerON);
-        this.configRegistryJolokiaClient = configRegistryJolokiaClient;
-    }
-
-    public ObjectName getTransactionON() {
-        return objectName;
-    }
-
-    @Override
-    public CommitStatus commit() throws ConflictingVersionException,
-            ValidationException {
-        return configRegistryJolokiaClient.commitConfig(objectName);
-    }
-
-    @Override
-    public ObjectName createModule(String moduleName, String instanceName)
-            throws InstanceAlreadyExistsException {
-        J4pExecRequest execReq = new J4pExecRequest(objectName, "createModule",
-                moduleName, instanceName);
-        try {
-            return extractObjectName(execute(execReq));
-        } catch (RuntimeException e) {
-            if (e.getMessage() != null
-                    && e.getMessage().startsWith(
-                            InstanceAlreadyExistsException.class.getName()))
-                throw new InstanceAlreadyExistsException();
-            throw e;
-        }
-    }
-
-    @Override
-    public void destroyModule(ObjectName configBeanON) {
-        J4pExecRequest execReq = new J4pExecRequest(objectName,
-                "destroyModule(javax.management.ObjectName)", configBeanON);
-        execute(execReq);
-    }
-
-    @Override
-    public void destroyConfigBean(String moduleName, String instanceName)
-            throws InstanceNotFoundException {
-        destroyModule(ObjectNameUtil.createTransactionModuleON(
-                getTransactionName(), moduleName, instanceName));
-    }
-
-    @Override
-    public void abortConfig() {
-        J4pExecRequest execReq = new J4pExecRequest(objectName, "abortConfig");
-        execute(execReq);
-    }
-
-    @Override
-    public void validateConfig() throws ValidationException {
-        J4pExecRequest execReq = new J4pExecRequest(objectName,
-                "validateConfig");
-        execute(execReq);
-    }
-
-    @Override
-    public long getParentVersion() {
-        J4pReadRequest req = new J4pReadRequest(objectName, "ParentVersion");
-        return (Long) execute(req).getValue();
-    }
-
-    @Override
-    public long getVersion() {
-        J4pReadRequest req = new J4pReadRequest(objectName, "Version");
-        return (Long) execute(req).getValue();
-    }
-
-    public void setAttribute(ObjectName configBeanTransactionON, String key,
-            Object value) {
-        J4pWriteRequest req = new J4pWriteRequest(configBeanTransactionON, key,
-                value);
-        try {
-            execute(req);
-        } catch (RuntimeException e) {
-            if (e.getMessage() != null
-                    && e.getMessage().startsWith(
-                            AttributeNotFoundException.class.getName())) {
-                // try to fix wrong case
-                Map<String, AttributeEntry> allAttributes = getAttributes(configBeanTransactionON);
-                for (AttributeEntry attrib : allAttributes.values()) {
-                    if (attrib.getKey().equalsIgnoreCase(key)) {
-                        req = new J4pWriteRequest(configBeanTransactionON,
-                                attrib.getKey(), value);
-                        execute(req);
-                        return;
-                    }
-                }
-            }
-            throw e;
-        }
-    }
-
-    public Object getAttribute(ObjectName objectName, String key) {
-        return configRegistryJolokiaClient.getAttribute(objectName, key);
-    }
-
-    public ObjectName getAttributeON(ObjectName objectName, String key) {
-        return configRegistryJolokiaClient.getAttributeON(objectName, key);
-    }
-
-    @Override
-    public String getTransactionName() {
-        return ObjectNameUtil.getTransactionName(objectName);
-    }
-
-    @Override
-    public void validateBean(ObjectName rwON) throws ValidationException {
-        J4pExecRequest req = new J4pExecRequest(rwON, "validate", new Object[0]);
-        execute(req);
-    }
-
-    @Override
-    public void assertVersion(int expectedParentVersion,
-            int expectedCurrentVersion) {
-        if (expectedParentVersion != getParentVersion()) {
-            throw new IllegalStateException();
-        }
-        if (expectedCurrentVersion != getVersion()) {
-            throw new IllegalStateException();
-        }
-    }
-
-    @Override
-    public void setAttribute(ObjectName on, String jmxName, Attribute attribute) {
-        throw new UnsupportedOperationException();
-    }
-
-    // TODO: implement or deprecate
-    @Override
-    public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void saveServiceReference(String serviceInterfaceName, String refName, ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean removeServiceReference(String serviceInterfaceName, String refName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void removeAllServiceReferences() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public ObjectName lookupConfigBeanByServiceInterfaceName(String serviceInterfaceName, String refName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Map<String, ObjectName>> getServiceMapping() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, ObjectName> lookupServiceReferencesByServiceInterfaceName(String serviceInterfaceName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Set<String> lookupServiceInterfaceNames(ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public String getServiceInterfaceName(String namespace, String localName) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException {
-        throw new UnsupportedOperationException();
-    }
-}
diff --git a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClient.java b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClient.java
deleted file mode 100644 (file)
index 321d23f..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.util.jolokia;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.jolokia.client.J4pClient;
-import org.jolokia.client.exception.J4pException;
-import org.jolokia.client.exception.J4pRemoteException;
-import org.jolokia.client.request.J4pExecRequest;
-import org.jolokia.client.request.J4pListRequest;
-import org.jolokia.client.request.J4pQueryParameter;
-import org.jolokia.client.request.J4pReadRequest;
-import org.jolokia.client.request.J4pRequest;
-import org.jolokia.client.request.J4pResponse;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.util.AttributeEntry;
-
-
-abstract class ListableJolokiaClient {
-    protected final J4pClient j4pClient;
-    protected final String url;
-    protected final ObjectName objectName;
-
-    public ListableJolokiaClient(String url, ObjectName objectName) {
-        if (url == null) {
-            throw new NullPointerException("Parameter 'url' is null");
-        }
-        if (!url.endsWith("/")) {
-            throw new IllegalArgumentException(
-                    "Parameter 'url' must end with '/'");
-        }
-
-        this.url = url;
-        this.j4pClient = new J4pClient(url);
-        this.objectName = objectName;
-    }
-
-    public ObjectName getObjectName() {
-        return objectName;
-    }
-
-    protected <R extends J4pResponse<T>, T extends J4pRequest> R execute(
-            T pRequest) {
-        try {
-            Map<J4pQueryParameter, String> pProcessingOptions = new HashMap<J4pQueryParameter, String>();
-            pProcessingOptions
-                    .put(J4pQueryParameter.INCLUDE_STACKTRACE, "true");
-            pProcessingOptions.put(J4pQueryParameter.SERIALIZE_EXCEPTION,
-                    "true");
-            return j4pClient.execute(pRequest, "POST", pProcessingOptions);
-        } catch (J4pRemoteException e) {
-            tryToConvertException(e.getRemoteStackTrace(), e.getErrorValue());
-            throw new RuntimeException(e.getRemoteStackTrace(), e);
-        } catch (J4pException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    protected void tryToConvertException(String remoteStackTrace,
-            JSONObject errorValue) {
-        String conflictPrefix = ConflictingVersionException.class.getName()
-                + ": ";
-        if (remoteStackTrace.startsWith(conflictPrefix)) {
-            remoteStackTrace = remoteStackTrace.substring(conflictPrefix
-                    .length());
-            Pattern p = Pattern.compile("\r?\n");
-            remoteStackTrace = Arrays.asList(p.split(remoteStackTrace))
-                    .iterator().next();
-            throw new ConflictingVersionException(remoteStackTrace);
-        }
-        String validationExceptionPrefix = ValidationException.class.getName();
-        if (remoteStackTrace.startsWith(validationExceptionPrefix)) {
-            throw createValidationExceptionFromJSONObject(errorValue);
-        }
-    }
-
-    static ValidationException createValidationExceptionFromJSONObject(
-            JSONObject errorValue) {
-        String fValsKey = "failedValidations";
-        JSONObject failedVals = (JSONObject) errorValue.get(fValsKey);
-
-        checkArgument(
-                !failedVals.isEmpty(),
-                fValsKey + " was not present in received JSON: "
-                        + errorValue.toJSONString());
-        Map<String, Map<String, ExceptionMessageWithStackTrace>> failedValsMap = new HashMap<String, Map<String, ExceptionMessageWithStackTrace>>();
-
-        for (Object key : failedVals.keySet()) {
-            checkArgument(key instanceof String, "Unexpected key " + key
-                    + ", expected instance of String");
-            Map<String, ExceptionMessageWithStackTrace> innerMap = new HashMap<String, ValidationException.ExceptionMessageWithStackTrace>();
-            for (Object innerKey : ((JSONObject) failedVals.get(key)).keySet()) {
-                checkArgument(innerKey instanceof String, "Unexpected key "
-                        + innerKey + ", expected instance of String");
-                JSONObject exWithStackTraceVal = (JSONObject) (((JSONObject) failedVals
-                        .get(key)).get(innerKey));
-                Object mess = exWithStackTraceVal.get("message");
-                Object stack = exWithStackTraceVal.get("trace");
-                checkArgument(mess != null && stack != null,
-                        "\"Message\" and \"trace\" elements expected in received json: "
-                                + errorValue.toJSONString());
-                innerMap.put(innerKey.toString(),
-                        new ExceptionMessageWithStackTrace((String) mess,
-                                (String) stack));
-            }
-            failedValsMap.put((String) key, innerMap);
-        }
-        return new ValidationException(failedValsMap);
-    }
-
-    private static void checkArgument(boolean b, String string) {
-        if (b == false)
-            throw new IllegalArgumentException(string);
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public Map<String, AttributeEntry> getAttributes(ObjectName on) {
-        J4pListRequest req = new J4pListRequest(on);
-        J4pResponse<J4pListRequest> response = execute(req);
-        JSONObject listJSONResponse = response.getValue();
-        JSONObject attributes = (JSONObject) listJSONResponse.get("attr");
-
-        // Empty attributes list
-        if(attributes == null)
-            return Collections.emptyMap();
-
-        Map<String, JSONObject> listMap = new HashMap<>();
-
-        for (Object entryObject : attributes.entrySet()) {
-            Entry<String, Object> entry = (Entry<String, Object>) entryObject;
-            JSONObject entryVal = (JSONObject) entry.getValue();
-
-            // read value
-            listMap.put(entry.getKey(), entryVal);
-        }
-        J4pReadRequest j4pReadRequest = new J4pReadRequest(on, listMap.keySet()
-                .toArray(new String[0]));
-        J4pResponse<J4pReadRequest> readResponse = execute(j4pReadRequest);
-        Object readResponseValue = readResponse.getValue();
-        // readResponseValue can be String if there is just one attribute or
-        // JSONObject
-        Map<String, Object> attribsToValues = new HashMap<String, Object>();
-        if (readResponseValue instanceof JSONObject) {
-            JSONObject readJSONResponse = (JSONObject) readResponseValue;
-            for (Object entryObject : readJSONResponse.entrySet()) {
-                Entry<String, Object> entry = (Entry<String, Object>) entryObject;
-                String key = entry.getKey();
-                Object value = entry.getValue();
-                attribsToValues.put(key, value);
-            }
-        }
-
-        Map<String, AttributeEntry> resultMap = new HashMap<String, AttributeEntry>();
-        for (Entry<String, JSONObject> entry : listMap.entrySet()) {
-            String key = entry.getKey();
-            Object value = attribsToValues.size() > 0 ? attribsToValues
-                    .get(key) : readResponseValue;
-            JSONObject listJSON = entry.getValue();
-            String description = (String) listJSON.get("desc");
-            String type = (String) listJSON.get("type");
-            boolean rw = (Boolean) listJSON.get("rw");
-            AttributeEntry attributeEntry = new AttributeEntry(key,
-                    description, value, type, rw);
-            resultMap.put(key, attributeEntry);
-        }
-
-        return resultMap;
-    }
-
-    public String getConfigBeanDescripton(ObjectName on) {
-        J4pListRequest req = new J4pListRequest(on);
-        J4pResponse<J4pListRequest> response = execute(req);
-        JSONObject jsonDesc = response.getValue();
-        Object description = jsonDesc.get("desc");
-        return description == null ? null : description.toString();
-    }
-
-    protected List<ObjectName> jsonArrayToObjectNames(JSONArray jsonArray) {
-        List<ObjectName> result = new ArrayList<>(jsonArray.size());
-        for (Object entry : jsonArray) {
-            JSONObject jsonObject = (JSONObject) entry;
-            String objectNameString = (String) jsonObject.get("objectName");
-            try {
-                result.add(new ObjectName(objectNameString));
-            } catch (MalformedObjectNameException e) {
-                throw new IllegalStateException("Cannot convert "
-                        + objectNameString + " to ObjectName", e);
-            }
-        }
-        return result;
-    }
-
-    protected ObjectName extractObjectName(J4pResponse<J4pExecRequest> resp) {
-        JSONObject jsonResponse = resp.getValue();
-        return extractObjectName(jsonResponse);
-    }
-
-    protected ObjectName extractObjectName(JSONObject jsonResponse) {
-        String result = jsonResponse.get("objectName").toString();
-        return ObjectNameUtil.createON(result);
-    }
-
-    protected Set<ObjectName> lookupSomething(String signature,
-            Object[] parameters) {
-        J4pExecRequest req = new J4pExecRequest(objectName, signature,
-                parameters);
-        JSONArray jsonArray = execute(req).getValue();
-        return new HashSet<>(jsonArrayToObjectNames(jsonArray));
-    }
-
-    public Set<ObjectName> lookupConfigBeans() {
-        return lookupSomething("lookupConfigBeans()", new Object[0]);
-    }
-
-    public Set<ObjectName> lookupConfigBeans(String ifcName) {
-        return lookupSomething("lookupConfigBeans(java.lang.String)",
-                new Object[] { ifcName });
-    }
-
-    public Set<ObjectName> lookupConfigBeans(String ifcName, String instanceName) {
-        return lookupSomething(
-                "lookupConfigBeans(java.lang.String,java.lang.String)",
-                new Object[] { ifcName, instanceName });
-    }
-
-    public ObjectName lookupConfigBean(String ifcName, String instanceName)
-            throws InstanceNotFoundException {
-        J4pExecRequest req = new J4pExecRequest(objectName,
-                "lookupConfigBean(java.lang.String,java.lang.String)",
-                new Object[] { ifcName, instanceName });
-        try {
-            J4pResponse<J4pExecRequest> resp = execute(req);
-            return extractObjectName(resp);
-        } catch (RuntimeException e) {
-            if (e.getMessage() != null
-                    && e.getMessage().startsWith(
-                            InstanceNotFoundException.class.getName()))
-                throw new InstanceNotFoundException();
-            throw e;
-        }
-    }
-
-    public Set<String> getAvailableModuleNames() {
-        J4pReadRequest req = new J4pReadRequest(objectName,
-                "AvailableModuleNames");
-        List<String> value = execute(req).getValue();
-        return new HashSet<>(value);
-    }
-}
index 85397d2..4c99c77 100644 (file)
@@ -7,49 +7,38 @@
  */
 package org.opendaylight.controller.config.util;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-import java.lang.management.ManagementFactory;
-import java.util.Set;
+import com.google.common.collect.Sets;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.ConfigRegistry;
 
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Set;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ConfigRegistry;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.util.jolokia.ConfigRegistryJolokiaClient;
+import static org.junit.Assert.assertEquals;
 
 public class ConfigRegistryClientsTest {
 
-    private String jolokiaURL;
-
     private TestingConfigRegistry testingRegistry;
     private ObjectName testingRegistryON;
     private final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    private ConfigRegistryClient jmxRegistryClient, jolokiaRegistryClient;
+    private ConfigRegistryClient jmxRegistryClient;
 
     @Before
     public void setUp() throws Exception {
-        jolokiaURL = JolokiaHelper.startTestingJolokia();
         testingRegistry = new TestingConfigRegistry();
         testingRegistryON = ConfigRegistry.OBJECT_NAME;
         mbs.registerMBean(testingRegistry, testingRegistryON);
         jmxRegistryClient = new ConfigRegistryJMXClient(
                 ManagementFactory.getPlatformMBeanServer());
-        jolokiaRegistryClient = new ConfigRegistryJolokiaClient(jolokiaURL);
     }
 
     @After
     public void cleanUp() throws Exception {
-        JolokiaHelper.stopJolokia();
         if (testingRegistryON != null) {
             mbs.unregisterMBean(testingRegistryON);
         }
@@ -58,8 +47,7 @@ public class ConfigRegistryClientsTest {
     @Test
     public void testLookupRuntimeBeans() throws Exception {
         Set<ObjectName> jmxLookup = lookupRuntimeBeans(jmxRegistryClient);
-        Set<ObjectName> jolokiaLookup = lookupRuntimeBeans(jolokiaRegistryClient);
-        assertEquals(jmxLookup, jolokiaLookup);
+        assertEquals(Sets.newHashSet(testingRegistry.run2, testingRegistry.run1, testingRegistry.run3), jmxLookup);
     }
 
     private Set<ObjectName> lookupRuntimeBeans(ConfigRegistryClient client)
@@ -79,28 +67,19 @@ public class ConfigRegistryClientsTest {
                 jmxRegistryClient, TestingConfigRegistry.moduleName1,
                 TestingConfigRegistry.instName1);
         assertEquals(1, jmxLookup.size());
-        Set<ObjectName> jolokiaLookup = clientLookupRuntimeBeansWithModuleAndInstance(
-                jolokiaRegistryClient, TestingConfigRegistry.moduleName1,
-                TestingConfigRegistry.instName1);
-        assertEquals(jmxLookup, jolokiaLookup);
+        assertEquals(Sets.newHashSet(testingRegistry.run2), jmxLookup);
 
         jmxLookup = clientLookupRuntimeBeansWithModuleAndInstance(
                 jmxRegistryClient, TestingConfigRegistry.moduleName2,
                 TestingConfigRegistry.instName2);
         assertEquals(1, jmxLookup.size());
-        jolokiaLookup = clientLookupRuntimeBeansWithModuleAndInstance(
-                jolokiaRegistryClient, TestingConfigRegistry.moduleName2,
-                TestingConfigRegistry.instName2);
-        assertEquals(jmxLookup, jolokiaLookup);
+        assertEquals(Sets.newHashSet(testingRegistry.run3), jmxLookup);
 
         jmxLookup = clientLookupRuntimeBeansWithModuleAndInstance(
                 jmxRegistryClient, TestingConfigRegistry.moduleName1,
                 TestingConfigRegistry.instName2);
         assertEquals(0, jmxLookup.size());
-        jolokiaLookup = clientLookupRuntimeBeansWithModuleAndInstance(
-                jolokiaRegistryClient, TestingConfigRegistry.moduleName1,
-                TestingConfigRegistry.instName2);
-        assertEquals(jmxLookup, jolokiaLookup);
+        assertEquals(Sets.newHashSet(), jmxLookup);
     }
 
     private Set<ObjectName> clientLookupRuntimeBeansWithModuleAndInstance(
@@ -112,29 +91,4 @@ public class ConfigRegistryClientsTest {
         }
         return beans;
     }
-
-    @Test
-    public void testValidationExceptionDeserialization() {
-        try {
-            jolokiaRegistryClient.commitConfig(null);
-            fail();
-        } catch (ValidationException e) {
-            String moduleName = "moduleName", instanceName = "instanceName";
-            assertThat(e.getFailedValidations().containsKey(moduleName),
-                    is(true));
-            assertThat(e.getFailedValidations().size(), is(1));
-            assertThat(e.getFailedValidations().get(moduleName).size(), is(1));
-            assertThat(
-                    e.getFailedValidations().get(moduleName)
-                            .containsKey(instanceName), is(true));
-            assertThat(
-                    e.getFailedValidations().get(moduleName).get(instanceName)
-                            .getMessage(), is("message"));
-            assertThat(
-                    e.getFailedValidations().get(moduleName).get(instanceName)
-                            .getTrace(),
-                    containsString("org.opendaylight.controller.config.util.TestingConfigRegistry.commitConfig"));
-        }
-    }
-
 }
index a6df1e9..5ce6d46 100644 (file)
@@ -7,47 +7,37 @@
  */
 package org.opendaylight.controller.config.util;
 
-import static org.junit.Assert.assertEquals;
-
-import java.lang.management.ManagementFactory;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
+import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
 
-public class ConfigTransactionClientsTest {
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.Set;
 
+import static org.junit.Assert.assertEquals;
+
+public class ConfigTransactionClientsTest {
     private final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    private String jolokiaURL;
-    private ConfigTransactionControllerMXBean transactionController;
+    private TestingConfigTransactionController transactionController;
     private ObjectName transactionControllerON;
-    private ConfigTransactionClient jmxTransactionClient,
-            jolokiaTransactionClient;
+    private ConfigTransactionClient jmxTransactionClient;
 
     @Before
     public void setUp() throws Exception {
-        jolokiaURL = JolokiaHelper.startTestingJolokia();
         transactionController = new TestingConfigTransactionController();
         transactionControllerON = new ObjectName(ObjectNameUtil.ON_DOMAIN + ":"
                 + ObjectNameUtil.TYPE_KEY + "=TransactionController");
         mbs.registerMBean(transactionController, transactionControllerON);
-        jmxTransactionClient = new ConfigTransactionJMXClient(null,
-                transactionControllerON,
+        jmxTransactionClient = new ConfigTransactionJMXClient(null, transactionControllerON,
                 ManagementFactory.getPlatformMBeanServer());
-        jolokiaTransactionClient = new ConfigTransactionJolokiaClient(
-                jolokiaURL, transactionControllerON, null);
     }
 
     @After
     public void cleanUp() throws Exception {
-        JolokiaHelper.stopJolokia();
         if (transactionControllerON != null) {
             mbs.unregisterMBean(transactionControllerON);
         }
@@ -56,8 +46,8 @@ public class ConfigTransactionClientsTest {
     @Test
     public void testLookupConfigBeans() throws Exception {
         Set<ObjectName> jmxLookup = testClientLookupConfigBeans(jmxTransactionClient);
-        Set<ObjectName> jolokiaLookup = testClientLookupConfigBeans(jolokiaTransactionClient);
-        assertEquals(jmxLookup, jolokiaLookup);
+        assertEquals(Sets.newHashSet(transactionController.conf1,
+                transactionController.conf2, transactionController.conf3), jmxLookup);
     }
 
     private Set<ObjectName> testClientLookupConfigBeans(
@@ -69,5 +59,4 @@ public class ConfigTransactionClientsTest {
         assertEquals(3, beans.size());
         return beans;
     }
-
 }
diff --git a/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/JolokiaHelper.java b/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/JolokiaHelper.java
deleted file mode 100644 (file)
index c0a2586..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.util;
-
-import org.jolokia.jvmagent.JolokiaServer;
-import org.jolokia.jvmagent.JvmAgentConfig;
-
-public class JolokiaHelper {
-    private static JolokiaServer jolokiaServer;
-
-    /**
-     * Bind to port 17777. By convention, ports above 10000 are used for testing
-     * and < 10000 for production
-     *
-     * @return url that can be passed to new J4pClient(url)
-     */
-    public static String startTestingJolokia() {
-        return startJolokia("localhost", 17777);
-    }
-
-    /**
-     * @return url that can be passed to new J4pClient(url)
-     * @throws IOException
-     */
-    public static String startJolokia(String host, int port) {
-        String agentArgs = "host=" + host + ",port=" + port;
-        JvmAgentConfig config = new JvmAgentConfig(agentArgs);
-        Exception lastException = null;
-        for (int i = 0; i < 10; i++) {
-            try {
-                jolokiaServer = new JolokiaServer(config, false);
-                jolokiaServer.start();
-                return "http://" + host + ":" + port + "/jolokia/";
-            } catch (Exception e) {
-                lastException = e;
-                try {
-                    Thread.sleep(100);
-                } catch (InterruptedException ie) {
-                    ie.printStackTrace();
-                }
-            }
-        }
-        throw new RuntimeException(lastException);
-    }
-
-    public static void stopJolokia() {
-        jolokiaServer.stop();
-    }
-}
index 52e9345..4489762 100644 (file)
@@ -7,20 +7,8 @@
  */
 package org.opendaylight.controller.config.util;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -28,35 +16,40 @@ import org.opendaylight.controller.config.api.ConfigRegistry;
 import org.opendaylight.controller.config.api.LookupRegistry;
 import org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.util.jolokia.ConfigRegistryJolokiaClient;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Sets;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 public class LookupTest {
 
-    private String jolokiaURL;
     private TestingConfigRegistry testingRegistry;
     private ObjectName testingRegistryON;
     private final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    private ConfigRegistryClient jmxRegistryClient, jolokiaRegistryClient;
+    private ConfigRegistryClient jmxRegistryClient;
     private ConfigTransactionControllerMXBean testingTransactionController;
     private ObjectName testingTransactionControllerON;
-    private ConfigTransactionClient jmxTransactionClient,
-            jolokiaTransactionClient;
+    private ConfigTransactionClient jmxTransactionClient;
 
     Map<LookupRegistry, ? extends Set<? extends LookupRegistry>> lookupProvidersToClients;
 
     @Before
     public void setUp() throws Exception {
-        jolokiaURL = JolokiaHelper.startTestingJolokia();
         testingRegistry = new TestingConfigRegistry();
         testingRegistryON = ConfigRegistry.OBJECT_NAME;
         mbs.registerMBean(testingRegistry, testingRegistryON);
         jmxRegistryClient = new ConfigRegistryJMXClient(
                 ManagementFactory.getPlatformMBeanServer());
-        jolokiaRegistryClient = new ConfigRegistryJolokiaClient(jolokiaURL);
+
 
         testingTransactionController = new TestingConfigTransactionController();
         testingTransactionControllerON = new ObjectName(
@@ -68,16 +61,15 @@ public class LookupTest {
         jmxTransactionClient = new ConfigTransactionJMXClient(null,
                 testingTransactionControllerON,
                 ManagementFactory.getPlatformMBeanServer());
-        jolokiaTransactionClient = new ConfigTransactionJolokiaClient(
-                jolokiaURL, testingTransactionControllerON, null);
-        HashSet<ConfigRegistryClient> registryClients = Sets.newHashSet(jmxRegistryClient, jolokiaRegistryClient);
-        HashSet<ConfigTransactionClient> configTransactionClients = Sets.newHashSet(jmxTransactionClient, jolokiaTransactionClient);
-        lookupProvidersToClients = ImmutableMap.of((LookupRegistry) testingRegistry, registryClients,                testingTransactionController, configTransactionClients);
+
+        HashSet<ConfigRegistryClient> registryClients = Sets.newHashSet(jmxRegistryClient);
+        HashSet<ConfigTransactionClient> configTransactionClients = Sets.newHashSet(jmxTransactionClient);
+        lookupProvidersToClients = ImmutableMap.of((LookupRegistry) testingRegistry, registryClients,
+                testingTransactionController, configTransactionClients);
     }
 
     @After
     public void cleanUp() throws Exception {
-        JolokiaHelper.stopJolokia();
         mbs.unregisterMBean(testingRegistryON);
         mbs.unregisterMBean(testingTransactionControllerON);
     }
index 0a845e1..1c522f1 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.collect.Sets;
 public class TestingConfigTransactionController implements
         ConfigTransactionControllerMXBean {
 
-    private final ObjectName conf1, conf2, conf3;
+    public final ObjectName conf1, conf2, conf3;
 
     public static final String moduleName1 = "moduleA";
     public static final String moduleName2 = "moduleB";
diff --git a/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClientTest.java b/opendaylight/config/config-util/src/test/java/org/opendaylight/controller/config/util/jolokia/ListableJolokiaClientTest.java
deleted file mode 100644 (file)
index bff8006..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  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.opendaylight.controller.config.util.jolokia;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace;
-
-public class ListableJolokiaClientTest {
-
-    private Map<String, Map<String, ExceptionMessageWithStackTrace>> failedValidations;
-
-    private ValidationException val;
-
-    private final static String ex = "{\"message\":null,"
-            + "\"failedValidations\":"
-            + "{\"ifc2\":{\"impl1\":{\"message\":\"abc\",\"trace\":\"vvv\"},"
-            + "\"impl2\":{\"message\":\"abc2\",\"trace\":\"vvv2\"}},"
-            + "\"ifc1\":"
-            + "{\"impl1\":{\"message\":\"abc\",\"trace\":\"vvv\"},"
-            + "\"impl2\":{\"message\":\"abc2\",\"trace\":\"vvv2\"}}},"
-            + "\"localizedMessage\":null," + "\"cause\":null}";
-
-    @Before
-    public void setUp() {
-        failedValidations = new HashMap<String, Map<String, ExceptionMessageWithStackTrace>>();
-        Map<String, ExceptionMessageWithStackTrace> map1 = new HashMap<String, ValidationException.ExceptionMessageWithStackTrace>();
-        map1.put("impl1", new ExceptionMessageWithStackTrace("abc", "vvv"));
-        map1.put("impl2", new ExceptionMessageWithStackTrace("abc2", "vvv2"));
-        failedValidations.put("ifc1", map1);
-        failedValidations.put("ifc2", map1);
-        val = new ValidationException(failedValidations);
-    }
-
-    @Test
-    public void testParsing() {
-        JSONObject e = (JSONObject) JSONValue.parse(ex);
-        ValidationException val2 = ListableJolokiaClient
-                .createValidationExceptionFromJSONObject(e);
-        assertThat(val2.getMessage(), is(val.getMessage()));
-        assertThat(val2.getFailedValidations(), is(val.getFailedValidations()));
-    }
-
-}
index 9943797..9f0145f 100644 (file)
@@ -63,7 +63,6 @@
         <osgi.version>5.0.0</osgi.version>
         <jacoco.version>0.6.2.201302030002</jacoco.version>
         <slf4j.version>1.7.2</slf4j.version>
-        <jolokia.version>1.1.1</jolokia.version>
         <opendaylight.yang.version>0.5.9-SNAPSHOT</opendaylight.yang.version>
         <opendaylight.binding.version>0.6.0-SNAPSHOT</opendaylight.binding.version>
         <opendaylight.yangtools.version>0.1.1-SNAPSHOT</opendaylight.yangtools.version>
                 <artifactId>guava</artifactId>
                 <version>14.0.1</version>
             </dependency>
-            <dependency>
-                <groupId>org.jolokia</groupId>
-                <artifactId>jolokia-core</artifactId>
-                <version>${jolokia.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.jolokia</groupId>
-                <artifactId>jolokia-jvm</artifactId>
-                <version>${jolokia.version}</version>
-                <classifier>agent</classifier>
-            </dependency>
-            <dependency>
-                <groupId>org.jolokia</groupId>
-                <artifactId>jolokia-client-java</artifactId>
-                <version>${jolokia.version}</version>
-            </dependency>
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>