Search in sources :

Example 1 with ParseArgumentsUnexpectedException

use of io.airlift.airline.ParseArgumentsUnexpectedException in project activemq-artemis by apache.

the class OptionsValidationTest method testCommand.

@Test
public void testCommand() throws Exception {
    ActionContext context = new TestActionContext();
    String[] invalidArgs = null;
    if (group == null) {
        invalidArgs = new String[] { command, "--blahblah-" + command, "--rubbish-" + command + "=" + "more-rubbish", "--input=blahblah" };
    } else {
        invalidArgs = new String[] { group, command, "--blahblah-" + command, "--rubbish-" + command + "=" + "more-rubbish", "--input=blahblah" };
    }
    try {
        Artemis.internalExecute(null, needInstance ? this.artemisInstance : null, invalidArgs, context);
        fail("cannot detect invalid options");
    } catch (InvalidOptionsError e) {
        assertTrue(e.getMessage().contains("Found unexpected parameters"));
    } catch (ParseArgumentsUnexpectedException e) {
    // airline can detect some invalid args during parsing
    // which is fine.
    }
}
Also used : InvalidOptionsError(org.apache.activemq.artemis.cli.commands.InvalidOptionsError) ParseArgumentsUnexpectedException(io.airlift.airline.ParseArgumentsUnexpectedException) ActionContext(org.apache.activemq.artemis.cli.commands.ActionContext) Test(org.junit.Test)

Aggregations

ParseArgumentsUnexpectedException (io.airlift.airline.ParseArgumentsUnexpectedException)1 ActionContext (org.apache.activemq.artemis.cli.commands.ActionContext)1 InvalidOptionsError (org.apache.activemq.artemis.cli.commands.InvalidOptionsError)1 Test (org.junit.Test)1