Search in sources :

Example 1 with CommandService

use of org.exoplatform.services.command.impl.CommandService in project kernel by exoplatform.

the class CommandServiceTest method testPluginConf.

public void testPluginConf() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    assertNotNull(cservice);
    // preconfigured commands
    assertTrue(cservice.getCatalog().getNames().hasNext());
    assertNotNull(cservice.getCatalog().getNames().next());
}
Also used : CommandService(org.exoplatform.services.command.impl.CommandService)

Example 2 with CommandService

use of org.exoplatform.services.command.impl.CommandService in project kernel by exoplatform.

the class CommandServiceTest method testExcecute.

public void testExcecute() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    Command c1 = cservice.getCatalog().getCommand("Execute2");
    Command c2 = cservice.getCatalog().getCommand("Command1");
    Catalog c = cservice.getCatalog();
    Context ctx = new ContextBase();
    ctx.put("test", Integer.valueOf(0));
    c1.execute(ctx);
    c2.execute(ctx);
    assertEquals(3, ((Integer) ctx.get("test")).intValue());
}
Also used : Context(org.apache.commons.chain.Context) Command(org.apache.commons.chain.Command) CommandService(org.exoplatform.services.command.impl.CommandService) Catalog(org.apache.commons.chain.Catalog) ContextBase(org.apache.commons.chain.impl.ContextBase)

Example 3 with CommandService

use of org.exoplatform.services.command.impl.CommandService in project kernel by exoplatform.

the class MultiConfigServiceTest method testIfPutCatalogDoesNotRemoveCommands.

public void testIfPutCatalogDoesNotRemoveCommands() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    assertNotNull(cservice);
    assertTrue(cservice.getCatalogNames().hasNext());
    Iterator commands = cservice.getCatalog().getNames();
    int cnt = 0;
    while (commands.hasNext()) {
        commands.next();
        cnt++;
    }
    ByteArrayInputStream is = new ByteArrayInputStream(IS.getBytes());
    cservice.putCatalog(is);
    assertTrue(cservice.getCatalogNames().hasNext());
    commands = cservice.getCatalog().getNames();
    cnt = 0;
    while (commands.hasNext()) {
        commands.next();
        cnt++;
    }
    commands = cservice.getCatalog("fromput").getNames();
    cnt = 0;
    while (commands.hasNext()) {
        commands.next();
        cnt++;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CommandService(org.exoplatform.services.command.impl.CommandService) Iterator(java.util.Iterator)

Example 4 with CommandService

use of org.exoplatform.services.command.impl.CommandService in project kernel by exoplatform.

the class MultiConfigServiceTest method testMultiConfig.

/**
 * Tests if multiple configuration is allowed
 *
 * @throws Exception
 */
public void testMultiConfig() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    assertNotNull(cservice);
    assertTrue(cservice.getCatalogNames().hasNext());
    Iterator commands = cservice.getCatalog().getNames();
    int cnt = 0;
    while (commands.hasNext()) {
        commands.next();
        cnt++;
    }
    assertEquals(NUMBER_OF_COMMANDS_IN_DEF, cnt);
    commands = cservice.getCatalog("catalog1").getNames();
    cnt = 0;
    while (commands.hasNext()) {
        commands.next();
        cnt++;
    }
    assertEquals(NUMBER_OF_COMMANDS_IN_CATALOG1, cnt);
}
Also used : CommandService(org.exoplatform.services.command.impl.CommandService) Iterator(java.util.Iterator)

Example 5 with CommandService

use of org.exoplatform.services.command.impl.CommandService in project kernel by exoplatform.

the class CommandServiceTest method testInitWithFile.

public void testInitWithFile() throws Exception {
    CommandService cservice = (CommandService) container.getComponentInstanceOfType(CommandService.class);
    cservice.putCatalog(getClass().getResourceAsStream("/conf/test-commands3.xml"));
    assertTrue(cservice.getCatalogNames().hasNext());
    Catalog c1 = cservice.getCatalog("catalog1");
    assertNotNull(c1.getCommand("Command2"));
}
Also used : CommandService(org.exoplatform.services.command.impl.CommandService) Catalog(org.apache.commons.chain.Catalog)

Aggregations

CommandService (org.exoplatform.services.command.impl.CommandService)6 Catalog (org.apache.commons.chain.Catalog)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Iterator (java.util.Iterator)2 Command (org.apache.commons.chain.Command)1 Context (org.apache.commons.chain.Context)1 ContextBase (org.apache.commons.chain.impl.ContextBase)1