This commit is contained in:
Clebert Suconic 2017-11-28 14:47:36 -05:00
commit 4bb32b3794
2 changed files with 90 additions and 4 deletions

View File

@ -795,13 +795,15 @@ public interface ActiveMQServerControl {
* Closes the session with the given id. * Closes the session with the given id.
*/ */
@Operation(desc = "Closes the session with the id", impact = MBeanOperationInfo.INFO) @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. * Closes the consumer with the given id.
*/ */
@Operation(desc = "Closes the consumer with the id", impact = MBeanOperationInfo.INFO) @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. * Lists all the IDs of the connections connected to this server.
@ -848,7 +850,7 @@ public interface ActiveMQServerControl {
* </pre> * </pre>
*/ */
@Operation(desc = "List all consumers associated with a connection as a JSON string") @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. * 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 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; @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 * returns the address settings as a JSON string

View File

@ -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);
}
}
}
}
}
}