Search in sources :

Example 21 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testNonConcurrentGroups.

@Test
public void testNonConcurrentGroups() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout " + "groupA(rolling-to-servers=true,max-failure-percentage=20) , groupB");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    final ModelNode node = new ModelNode();
    final ModelNode inSeries = node.get(Util.ROLLOUT_PLAN).get(Util.IN_SERIES);
    ModelNode group = new ModelNode();
    final ModelNode groupProps = group.get("groupA");
    groupProps.get("rolling-to-servers").set("true");
    groupProps.get("max-failure-percentage").set("20");
    inSeries.add().get(Util.SERVER_GROUP).set(group);
    group = new ModelNode();
    group.get("groupB");
    inSeries.add().get(Util.SERVER_GROUP).set(group);
    final ModelNode headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ModelNode(org.jboss.dmr.ModelNode) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 22 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testTwoHeaders.

@Test
public void testTwoHeaders() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ name1 = value1 ; name2=value2 }");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertTrue(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(2, headers.size());
    final Iterator<ParsedOperationRequestHeader> i = headers.iterator();
    ParsedOperationRequestHeader header = i.next();
    assertEquals("name1", header.getName());
    ModelNode node = new ModelNode();
    node.get("name1").set("value1");
    ModelNode headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
    header = i.next();
    assertEquals("name2", header.getName());
    node = new ModelNode();
    node.get("name2").set("value2");
    headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 23 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testSingleHeader.

@Test
public void testSingleHeader() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ name = value }");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertTrue(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertEquals("name", header.getName());
    final ModelNode node = new ModelNode();
    node.get("name").set("value");
    final ModelNode headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 24 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupPropertyNameValueSeparator.

@Test
public void testEndsOnGroupPropertyNameValueSeparator() throws Exception {
    parse(":do{ rollout groupA( prop =");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertFalse(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertTrue(group.hasProperties());
    assertTrue(group.endsOnPropertyValueSeparator());
    assertEquals("prop", group.getLastPropertyName());
    assertNull(group.getLastPropertyValue());
    assertEquals(26, group.getLastSeparatorIndex());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 25 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnHeaderListEnd.

@Test
public void testEndsOnHeaderListEnd() throws Exception {
    parse(":do{ rollout groupA }");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertTrue(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    final ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    assertFalse(rollout.hasProperties());
// assertTrue(rollout.endsOnPropertyListStart());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Aggregations

ParsedOperationRequestHeader (org.jboss.as.cli.operation.ParsedOperationRequestHeader)27 Test (org.junit.Test)22 ParsedRolloutPlanHeader (org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader)19 ModelNode (org.jboss.dmr.ModelNode)13 SingleRolloutPlanGroup (org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup)7 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 TerminalString (org.aesh.readline.terminal.formatting.TerminalString)1 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)1 OperationRequestAddress (org.jboss.as.cli.operation.OperationRequestAddress)1 Node (org.jboss.as.cli.operation.OperationRequestAddress.Node)1