/* * Copyright 2011 Red Hat, Inc. and/or its affiliates. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA */ package org.infinispan; import org.infinispan.config.Configuration; import org.infinispan.context.Flag; import org.infinispan.manager.CacheContainer; import org.infinispan.manager.DefaultCacheManager; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.test.MultipleCacheManagersTest; import org.infinispan.test.SingleCacheManagerTest; import org.infinispan.test.fwk.TestCacheManagerFactory; import org.infinispan.transaction.LockingMode; import org.infinispan.transaction.lookup.GenericTransactionManagerLookup; import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup; import org.infinispan.util.concurrent.IsolationLevel; import org.testng.annotations.Test; import javax.transaction.NotSupportedException; import javax.transaction.SystemException; import javax.transaction.Transaction; import static org.infinispan.context.Flag.FAIL_SILENTLY; /** * // TODO: Document this * * @author Galder ZamarreƱo * @since // TODO */ @Test(groups = "functional", testName = "SampleTest") public class SampleTest extends MultipleCacheManagersTest { @Override protected void createCacheManagers() throws Throwable { Configuration cfg = new Configuration().fluent() .clustering().mode(Configuration.CacheMode.REPL_SYNC) .locking() .concurrencyLevel(10000).isolationLevel(IsolationLevel.REPEATABLE_READ) .lockAcquisitionTimeout(100L).useLockStriping(false).writeSkewCheck(true) .transaction() .lockingMode(LockingMode.PESSIMISTIC) .recovery() .transactionManagerLookup(new JBossStandaloneJTAManagerLookup()) .build(); registerCacheManager(TestCacheManagerFactory.createClusteredCacheManager(cfg), TestCacheManagerFactory.createClusteredCacheManager(cfg)); } // @Override // protected EmbeddedCacheManager createCacheManager() throws Exception { // // // // String newCacheName = "conversationDetails"; // manager.defineConfiguration(newCacheName, config); // return manager; // } public void test000() throws Exception { Cache c0 = cache(0), c1 = cache(1); c0.put(1, "v1"); tm(1).begin(); c1.put(1, "v2"); Transaction suspendedTx = tm(1).suspend(); try { Cache silentC0 = c0.getAdvancedCache().withFlags( Flag.FAIL_SILENTLY, Flag.ZERO_LOCK_ACQUISITION_TIMEOUT); tm(0).begin(); assert !silentC0.getAdvancedCache().lock(1); // assert !c0.getAdvancedCache().withFlags(Flag.FAIL_SILENTLY).lock(1); assert "v1".equals(silentC0.get(1)); tm(0).rollback(); } finally { tm(1).resume(suspendedTx); tm(1).commit(); } } // public void testSilentLockFailure() throws SystemException, NotSupportedException { // Cache cache1 = cache(0), cache2 = cache(1); // // cache1.put("k", "v"); // tm(1).begin(); // cache2.put("k", "v2"); // tm(1).suspend(); // // tm(0).begin(); // assert !cache1.getAdvancedCache().withFlags(FAIL_SILENTLY).lock("k"); // tm(0).rollback(); // } }