Package org.apache.commons.chain.impl

Examples of org.apache.commons.chain.impl.ContextBase


            System.setProperty("logback.configurationFile", "logback-cli.xml");

            String uri = command.getOptionValue("cli");
            Repository repository = JcrUtils.getRepository(uri);

            Context context = new ContextBase();
            CommandHelper.setRepository(context, repository, uri);
            try {
                Session session = repository.login();
                CommandHelper.setSession(context, session);
                CommandHelper.setCurrentNode(context, session.getRootNode());


    /**
     * Constructor
     */
    JcrClient() {
        super();
        ctx = new ContextBase();
        initOptions();
        initContext();
    }

     */
    public void setUp() {
        catalog = new CatalogBase();
        CatalogFactoryBase.getInstance().setCatalog(catalog);
        command = new LookupCommand();       
        context = new ContextBase();
    }

     */
    public void setUp() {
        catalog = new CatalogBase();
        CatalogFactoryBase.getInstance().setCatalog(catalog);
        command = new DispatchLookupCommand();       
        context = new ContextBase();
    }

    public void testMethodDispatch() throws Exception {
        TestCommand test = new TestCommand();

        test.setMethod("testMethod");
        Context context = new ContextBase();
        assertNull(context.get("foo"));
        boolean result = test.execute(context);
        assertTrue(result);
        assertNotNull(context.get("foo"));
        assertEquals("foo", context.get("foo"));


    }

    public void testMethodKeyDispatch() throws Exception {
        TestCommand test = new TestCommand();

        test.setMethodKey("foo");
        Context context = new ContextBase();
        context.put("foo", "testMethodKey");
        assertNull(context.get("bar"));
        boolean result = test.execute(context);
        assertFalse(result);
        assertNotNull(context.get("bar"));
        assertEquals("bar", context.get("bar"));


    }

    public void testAlternateContext() throws Exception {
        TestAlternateContextCommand test = new TestAlternateContextCommand();

        test.setMethod("foo");
        Context context = new ContextBase();
        assertNull(context.get("elephant"));
        boolean result = test.execute(context);
        assertTrue(result);
        assertNotNull(context.get("elephant"));
        assertEquals("elephant", context.get("elephant"));


    }

  /**
   * Instantiate ActionContextBase, wrapping a default ContextBase instance.
   */
  public ActionContextBase() {
    this(new ContextBase());
  }

      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());

   }

         DummyAction daction = new DummyAction();
         // test by path
         prepareActionCatalog(daction, actionInfo.getEventType(), new QPath[]{((NodeImpl)node).getInternalPath()},
            true, null, null, null);
         assertEquals(0, daction.getActionExecuterCount());
         Context ctx = new ContextBase();
         ctx.put("node", otherNode);
         actionInfo.execute(ctx);
         assertEquals(0, daction.getActionExecuterCount());
         actionInfo.tearDown(ctx);

         ctx.put("node", node3);
         actionInfo.execute(ctx);
         assertEquals(1, daction.getActionExecuterCount());
         actionInfo.tearDown(ctx);

         // Not deep
         daction = new DummyAction();
         prepareActionCatalog(daction, actionInfo.getEventType(), new QPath[]{((NodeImpl)node).getInternalPath()},
            false, null, null, null);

         assertEquals(0, daction.getActionExecuterCount());

         ctx.put("node", otherNode);
         actionInfo.execute(ctx);
         assertEquals(0, daction.getActionExecuterCount());
         actionInfo.tearDown(ctx);

         ctx.put("node", node3);
         actionInfo.execute(ctx);
         assertEquals(0, daction.getActionExecuterCount());
         actionInfo.tearDown(ctx);

         node.remove();

TOP

Related Classes of org.apache.commons.chain.impl.ContextBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.