You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/11/28 20:53:27 UTC

[2/2] activemq-artemis git commit: ARTEMIS-1521 Missing Parameter annotations in ActiveMQServerControl

ARTEMIS-1521 Missing Parameter annotations in ActiveMQServerControl

Added missing annotations
Added test


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3c19cc20
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3c19cc20
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3c19cc20

Branch: refs/heads/master
Commit: 3c19cc208168279674176dcce30e2ec9cdbeace8
Parents: 6f70bf1
Author: Howard Gao <ho...@gmail.com>
Authored: Fri Nov 24 11:54:56 2017 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Nov 28 14:47:36 2017 -0500

----------------------------------------------------------------------
 .../core/management/ActiveMQServerControl.java  | 10 ++-
 .../management/OperationAnnotationTest.java     | 84 ++++++++++++++++++++
 2 files changed, 90 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3c19cc20/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
index 2134902..b5150c9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
@@ -795,13 +795,15 @@ public interface ActiveMQServerControl {
     * Closes the session with the given id.
     */
    @Operation(desc = "Closes the session with the id", impact = MBeanOperationInfo.INFO)
-   boolean closeSessionWithID(String connectionID, String ID) throws Exception;
+   boolean closeSessionWithID(@Parameter(desc = "The connection ID", name = "connectionID") String connectionID,
+                              @Parameter(desc = "The session ID", name = "ID") String ID) throws Exception;
 
    /**
     * Closes the consumer with the given id.
     */
    @Operation(desc = "Closes the consumer with the id", impact = MBeanOperationInfo.INFO)
-   boolean closeConsumerWithID(String sessionID, String ID) throws Exception;
+   boolean closeConsumerWithID(@Parameter(desc = "The session ID", name = "sessionID") String sessionID,
+                               @Parameter(desc = "The consumer ID", name = "ID") String ID) throws Exception;
 
    /**
     * Lists all the IDs of the connections connected to this server.
@@ -848,7 +850,7 @@ public interface ActiveMQServerControl {
     * </pre>
     */
    @Operation(desc = "List all consumers associated with a connection as a JSON string")
-   String listConsumersAsJSON(String connectionID) throws Exception;
+   String listConsumersAsJSON(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
 
    /**
     * Lists all the consumers connected to this server.
@@ -998,7 +1000,7 @@ public interface ActiveMQServerControl {
                            @Parameter(desc = "allow topics to be created automatically", name = "autoCreateAddresses") boolean autoCreateAddresses,
                            @Parameter(desc = "allow auto-created topics to be deleted automatically", name = "autoDeleteAddresses") boolean autoDeleteAddresses) throws Exception;
 
-   void removeAddressSettings(String addressMatch) throws Exception;
+   void removeAddressSettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
 
    /**
     * returns the address settings as a JSON string

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3c19cc20/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/OperationAnnotationTest.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/OperationAnnotationTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/OperationAnnotationTest.java
new file mode 100644
index 0000000..d59799a
--- /dev/null
+++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/management/OperationAnnotationTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.activemq.artemis.api.core.management;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Parameterized.class)
+public class OperationAnnotationTest {
+
+   @Parameterized.Parameters(name = "class=({0})")
+   public static Collection<Object[]> getTestParameters() {
+      return Arrays.asList(new Object[][]{{ActiveMQServerControl.class},
+                                          {AddressControl.class},
+                                          {QueueControl.class},
+                                          {BridgeControl.class},
+                                          {DivertControl.class},
+                                          {AcceptorControl.class},
+                                          {ClusterConnectionControl.class},
+                                          {BroadcastGroupControl.class}});
+   }
+
+   private Class<?> managementClass;
+
+   public OperationAnnotationTest(Class<?> managementClass) {
+      this.managementClass = managementClass;
+   }
+
+   @Test
+   public void testEachParameterAnnotated() throws Exception {
+      checkControlInterface(managementClass);
+   }
+
+   private void checkControlInterface(Class controlInterface) {
+
+      Method[] methods = controlInterface.getMethods();
+      for (Method m : methods) {
+         Annotation annotation = m.getAnnotation(Operation.class);
+         if (annotation != null) {
+            //each arguments must have a Parameter annotation
+            Class<?>[] paramTypes = m.getParameterTypes();
+            if (paramTypes.length > 0) {
+               Annotation[][] paramAnnotations = m.getParameterAnnotations();
+               for (int i = 0; i < paramTypes.length; i++) {
+                  //one of them must be Parameter
+                  boolean hasParameterAnnotation = false;
+                  for (Annotation panno : paramAnnotations[i]) {
+                     if (panno.annotationType() == Parameter.class) {
+                        hasParameterAnnotation = true;
+                        break;
+                     }
+                  }
+                  assertTrue("method " + m + " has parameters with no Parameter annotation", hasParameterAnnotation);
+               }
+            }
+         }
+      }
+   }
+}