Package org.infinispan.cli.interpreter

Examples of org.infinispan.cli.interpreter.Interpreter


      return TestCacheManagerFactory.createCacheManager(c);
   }

   private Interpreter getInterpreter() {
      GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(this.cacheManager);
      Interpreter interpreter = gcr.getComponent(Interpreter.class);
      return interpreter;
   }
View Full Code Here


      Interpreter interpreter = gcr.getComponent(Interpreter.class);
      return interpreter;
   }

   public void testSimple() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "put 'a' 'b'; get 'a';");
      interpreter
            .execute(sessionId, "put 'c' {\"org.infinispan.cli.interpreter.MyClass\":{\"i\":5,\"x\":null,\"b\":true}};");
      Object o = cache.get("c");
      assert o != null;
      assert o instanceof MyClass;
      assert ((MyClass) o).i == 5;
      assert ((MyClass) o).b;
      interpreter.execute(sessionId, "put 'f' 0.5;");
      Double f = (Double) cache.get("f");
      assert f == 0.5;
   }
View Full Code Here

      Double f = (Double) cache.get("f");
      assert f == 0.5;
   }

   public void testPutIfAbsent() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "put 'a' 'a'; put --ifabsent 'a' 'b';");
      assertEquals("a", (String)cache.get("a"));
   }
View Full Code Here

      interpreter.execute(sessionId, "put 'a' 'a'; put --ifabsent 'a' 'b';");
      assertEquals("a", (String)cache.get("a"));
   }

   public void testCacheQualifier() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      Cache<Object, Object> otherCache = cacheManager.getCache("otherCache");
      interpreter.execute(sessionId, "put 'a' 'a'; put 'otherCache'.'b' 'b'; cache 'otherCache'; put 'c' 'c';");
      Object a = cache.get("a");
      assert a.equals("a");
      Object b = otherCache.get("b");
      assert b.equals("b");
      Object c = otherCache.get("c");
View Full Code Here

      Object c = otherCache.get("c");
      assert c.equals("c");
   }

   public void testBatching() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "start; put 'a' 'a'; put 'b' 'b'; end;");
      Object a = cache.get("a");
      assert a.equals("a");
      Object b = cache.get("b");
      assert b.equals("b");
   }
View Full Code Here

      Object b = cache.get("b");
      assert b.equals("b");
   }

   public void testTx() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "begin; put 'a' 'a'; commit;");
      Object a = cache.get("a");
      assert a.equals("a");
      interpreter.execute(sessionId, "begin; put 'b' 'b'; rollback;");
      assert !cache.containsKey("b");
   }
View Full Code Here

      interpreter.execute(sessionId, "begin; put 'b' 'b'; rollback;");
      assert !cache.containsKey("b");
   }

   public void testDangling() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "begin; put 'a' 'a';");
      assert cache.getAdvancedCache().getTransactionManager().getTransaction() == null;
      assert !cache.containsKey("a");
      interpreter.execute(sessionId, "start; put 'a' 'a';");
      assert cache.getAdvancedCache().getBatchContainer().getBatchTransaction() == null;
      assert !cache.containsKey("a");
   }
View Full Code Here

      assert cache.getAdvancedCache().getBatchContainer().getBatchTransaction() == null;
      assert !cache.containsKey("a");
   }

   public void testRemove() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "put 'a' 'a';");
      Object a = cache.get("a");
      assert a.equals("a");
      interpreter.execute(sessionId, "remove 'a';");
      assert !cache.containsKey("a");
      interpreter.execute(sessionId, "put 'b' 'b';");
      Object b = cache.get("b");
      assert b.equals("b");
      interpreter.execute(sessionId, "remove 'b' 'c';");
      assert cache.containsKey("b");
   }
View Full Code Here

      interpreter.execute(sessionId, "remove 'b' 'c';");
      assert cache.containsKey("b");
   }

   public void testReplace() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "put 'a' 'a';");
      Object a = cache.get("a");
      assert a.equals("a");
      interpreter.execute(sessionId, "replace 'a' 'b';");
      a = cache.get("a");
      assert a.equals("b");
      interpreter.execute(sessionId, "replace 'a' 'b' 'c';");
      a = cache.get("a");
      assert a.equals("c");
      interpreter.execute(sessionId, "replace 'a' 'b' 'd';");
      a = cache.get("a");
      assert a.equals("c");
   }
View Full Code Here

      a = cache.get("a");
      assert a.equals("c");
   }

   public void testCreateLocal() throws Exception {
      Interpreter interpreter = getInterpreter();
      String sessionId = interpreter.createSessionId(BasicCacheContainer.DEFAULT_CACHE_NAME);
      interpreter.execute(sessionId, "create newcache;");
      assert cacheManager.cacheExists("newcache");
      interpreter.execute(sessionId, "create anothercache like newcache;");
      assert cacheManager.cacheExists("anothercache");
   }
View Full Code Here

TOP

Related Classes of org.infinispan.cli.interpreter.Interpreter

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.