Examples of TestObjectStreamMarshaller


Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      }
   }

   public void testStoreSizeExceeded() throws Exception {
      assertStoreSize(0, 0);
      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      try {
         store.write(new MarshalledEntryImpl(1, "v1", null, sm));
         store.write(new MarshalledEntryImpl(2, "v2", null, sm));
         assertStoreSize(1, 1);
      } finally {
         sm.stop();
      }
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

   }

   //alwaysRun = true otherwise, when we run unstable tests, this method is not invoked (because it belongs to the unit group)
   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception {
      marshaller = new TestObjectStreamMarshaller();
      try {
         cl = createStore();
      } catch (Exception e) {
         //in IDEs this won't be printed which makes debugging harder
         e.printStackTrace();
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      originalValues.put(loaderKey, loaderValue);

      PersistenceManager persistenceManager = TestingUtil.extractComponent(cache0, PersistenceManager.class);
      DummyInMemoryStore store = persistenceManager.getStores(DummyInMemoryStore.class).iterator().next();

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      PersistenceManager pm = null;
      try {
         store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));

         final CheckPoint checkPoint = new CheckPoint();
         pm = waitUntilAboutToProcessStoreTask(cache0, checkPoint);

         Future<Void> future = fork(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
               // Wait until loader is invoked
               checkPoint.awaitStrict("pre_process_on_all_stores_invoked", 1000, TimeUnit.SECONDS);

               // Now force the entry to be moved to the in memory
               assertEquals(loaderValue, cache0.get(loaderKey));

               checkPoint.triggerForever("pre_process_on_all_stores_released");
               return null;
            }
         });

         EntryRetriever<MagicKey, String> retriever = cache1.getAdvancedCache().getComponentRegistry().getComponent(
               EntryRetriever.class);

         Iterator<CacheEntry<MagicKey, String>> iterator = retriever.retrieveEntries(null, null, null);

         // we need this count since the map will replace same key'd value
         int count = 0;
         Map<MagicKey, String> results = new HashMap<MagicKey, String>();
         while (iterator.hasNext()) {
            Map.Entry<MagicKey, String> entry = iterator.next();
            results.put(entry.getKey(), entry.getValue());
            count++;
         }
         assertEquals(count, 4);
         assertEquals(originalValues, results);

         future.get(10, TimeUnit.SECONDS);
      } finally {
         if (pm != null) {
            TestingUtil.replaceComponent(cache0, PersistenceManager.class, pm, true);
         }
         sm.stop();
      }
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      cache0.putAll(originalValues);

      PersistenceManager persistenceManager = TestingUtil.extractComponent(cache0, PersistenceManager.class);
      DummyInMemoryStore store = persistenceManager.getStores(DummyInMemoryStore.class).iterator().next();

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      PersistenceManager pm = null;
      try {
         store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));

         final CheckPoint checkPoint = new CheckPoint();
         pm = waitUntilAboutToProcessStoreTask(cache0, checkPoint);

         Future<Void> future = fork(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
               // Wait until loader is invoked
               checkPoint.awaitStrict("pre_process_on_all_stores_invoked", 1000, TimeUnit.SECONDS);

               // Now force the entry to be moved to loader
               TestingUtil.extractComponent(cache0, PassivationManager.class).passivate(new ImmortalCacheEntry(loaderKey, loaderValue));

               checkPoint.triggerForever("pre_process_on_all_stores_released");
               return null;
            }
         });

         EntryRetriever<MagicKey, String> retriever = cache1.getAdvancedCache().getComponentRegistry().getComponent(
               EntryRetriever.class);

         Iterator<CacheEntry<MagicKey, String>> iterator = retriever.retrieveEntries(null, null, null);

         // we need this count since the map will replace same key'd value
         int count = 0;
         Map<MagicKey, String> results = new HashMap<MagicKey, String>();
         while (iterator.hasNext()) {
            Map.Entry<MagicKey, String> entry = iterator.next();
            results.put(entry.getKey(), entry.getValue());
            count++;
         }
         assertEquals(4, count);
         assertEquals(originalValues, results);

         future.get(10, TimeUnit.SECONDS);
      } finally {
         if (pm != null) {
            TestingUtil.replaceComponent(cache0, PersistenceManager.class, pm, true);
         }
         sm.stop();
      }
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      originalValues.put(loaderKey, loaderValue);

      PersistenceManager persistenceManager = TestingUtil.extractComponent(cache0, PersistenceManager.class);
      DummyInMemoryStore store = persistenceManager.getStores(DummyInMemoryStore.class).iterator().next();

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      PersistenceManager pm = null;
      try {
         store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));

         final CheckPoint checkPoint = new CheckPoint();
         pm = waitUntilAboutToProcessStoreTask(cache0, checkPoint);

         Future<Void> future = fork(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
               // Wait until loader is invoked
               checkPoint.awaitStrict("pre_process_on_all_stores_invoked", 1000, TimeUnit.SECONDS);

               // Now force the entry to be moved to the in memory
               assertEquals(loaderValue, cache0.get(loaderKey));

               checkPoint.triggerForever("pre_process_on_all_stores_released");
               return null;
            }
         });

         EntryRetriever<MagicKey, String> retriever = cache1.getAdvancedCache().getComponentRegistry().getComponent(
               EntryRetriever.class);

         Iterator<CacheEntry<MagicKey, String>> iterator = retriever.retrieveEntries(null, null, null, null);

         // we need this count since the map will replace same key'd value
         int count = 0;
         Map<MagicKey, String> results = new HashMap<MagicKey, String>();
         while (iterator.hasNext()) {
            Map.Entry<MagicKey, String> entry = iterator.next();
            results.put(entry.getKey(), entry.getValue());
            count++;
         }
         assertEquals(count, 4);
         assertEquals(originalValues, results);

         future.get(10, TimeUnit.SECONDS);
      } finally {
         if (pm != null) {
            TestingUtil.replaceComponent(cache0, PersistenceManager.class, pm, true);
         }
         sm.stop();
      }
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      });
   }

   public void testConfigureMarshaller() {
      GlobalConfigurationBuilder gc = new GlobalConfigurationBuilder();
      TestObjectStreamMarshaller marshaller = new TestObjectStreamMarshaller();
      gc.serialization().marshaller(marshaller);
      withCacheManager(new CacheManagerCallable(
            createCacheManager(gc, new ConfigurationBuilder())) {
         @Override
         public void call() {
            cm.getCache();
         }
      });
      marshaller.stop();
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      underlying.start();
   }

   @BeforeMethod
   public void createMarshaller() {
      marshaller = new TestObjectStreamMarshaller();
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

      cache0.putAll(originalValues);

      PersistenceManager persistenceManager = TestingUtil.extractComponent(cache0, PersistenceManager.class);
      DummyInMemoryStore store = persistenceManager.getStores(DummyInMemoryStore.class).iterator().next();

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      try {
         String loaderValue = "loader-value";
         store.write(new MarshalledEntryImpl(loaderKey, loaderValue, null, sm));
         if (includeLoaderEntry) {
            originalValues.put(loaderKey, loaderValue);
         }
      } finally {
         sm.stop();
      }
      return originalValues;
   }
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

   private InternalEntryFactory factory;

   //alwaysRun = true otherwise, when we run unstable tests, this method is not invoked (because it belongs to the unit group)
   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception {
      marshaller = new TestObjectStreamMarshaller();
      timeService = new ControlledTimeService(0);
      factory = new InternalEntryFactoryImpl();
      ((InternalEntryFactoryImpl) factory).injectTimeService(timeService);
      try {
         //noinspection unchecked
View Full Code Here

Examples of org.infinispan.marshall.TestObjectStreamMarshaller

   }

   public void testSkipCacheLoadFlagUsage() throws PersistenceException {
      CountingStore countingCS = getCountingCacheStore();

      TestObjectStreamMarshaller sm = new TestObjectStreamMarshaller();
      try {
         store.write(new MarshalledEntryImpl("home", "Vermezzo", null, sm));
         store.write(new MarshalledEntryImpl("home-second", "Newcastle Upon Tyne", null, sm));

         assert countingCS.numLoads == 0;
         //load using SKIP_CACHE_LOAD should not find the object in the store
         assert cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).get("home") == null;
         assert countingCS.numLoads == 0;

         assert cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).put("home", "Newcastle") == null;
         assert countingCS.numLoads == 0;

         final Object put = cache.getAdvancedCache().put("home-second", "Newcastle Upon Tyne, second");
         assertEquals(put, "Newcastle Upon Tyne");
         assert countingCS.numLoads == 1;
      } finally {
         sm.stop();
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.