From do-not-reply at jboss.org Tue Jul 13 07:48:53 2010 Content-Type: multipart/mixed; boundary="===============5082880013762212056==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: exo-jcr-commits at lists.jboss.org Subject: [exo-jcr-commits] exo-jcr SVN: r2776 - in jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr: lab and 1 other directories. Date: Tue, 13 Jul 2010 07:48:53 -0400 Message-ID: <201007131148.o6DBmrki026305@svn01.web.mwc.hst.phx2.redhat.com> --===============5082880013762212056== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: tolusha Date: 2010-07-13 07:48:53 -0400 (Tue, 13 Jul 2010) New Revision: 2776 Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatf= orm/services/jcr/lab/infinispan/ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatf= orm/services/jcr/lab/infinispan/TestISPNCache.java Removed: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplatf= orm/services/jcr/impl/ispn/ Log: EXOJCR-837: move test to another packet Added: jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exop= latform/services/jcr/lab/infinispan/TestISPNCache.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplat= form/services/jcr/lab/infinispan/TestISPNCache.java = (rev 0) +++ jcr/branches/1.14-ISPN/exo.jcr.component.core/src/test/java/org/exoplat= form/services/jcr/lab/infinispan/TestISPNCache.java 2010-07-13 11:48:53 UTC= (rev 2776) @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2010 eXo Platform SAS. + * + * 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 software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.exoplatform.services.jcr.lab.infinispan; + +import junit.framework.TestCase; + +import org.infinispan.Cache; +import org.infinispan.config.Configuration; +import org.infinispan.config.GlobalConfiguration; +import org.infinispan.manager.DefaultCacheManager; +import org.infinispan.manager.EmbeddedCacheManager; + +import java.util.concurrent.TimeUnit; + +/** + * @author Anatoliy Bazko + * @version $Id: TestINSPCache.java 111 2010-11-11 11:11:11Z tolusha $ + * + */ +public class TestISPNCache extends TestCase +{ + + /** + * {@inheritDoc} + */ + @Override + public void setUp() throws Exception + { + super.setUp(); + } + + /** + * {@inheritDoc} + */ + @Override + public void tearDown() throws Exception + { + super.tearDown(); + } + + /** + * Test default cache and base operation. + * = + * @throws Exception + */ + public void testGetCache() throws Exception + { + // Create cache manager + GlobalConfiguration myGlobalConfig =3D new GlobalConfiguration(); + EmbeddedCacheManager manager =3D new DefaultCacheManager(myGlobalCon= fig); + + // Create a cache + Configuration config =3D new Configuration(); + manager.defineConfiguration("cache", config); + Cache cache =3D manager.getCache("cache"); + + cache.put("key", "value"); + assertTrue(cache.size() =3D=3D 1); + assertTrue(cache.containsKey("key")); + + String value =3D (String)cache.remove("key"); + assertTrue(value.equals("value")); + assertTrue(cache.isEmpty()); + + cache.put("key", "value"); + cache.putIfAbsent("key", "newValue"); + assertTrue("value".equals(cache.get("key"))); + + cache.clear(); + assertTrue(cache.isEmpty()); + + cache.put("key", "value", 2, TimeUnit.SECONDS); + assertTrue(cache.containsKey("key")); + Thread.sleep(2000); + assertFalse(cache.containsKey("key")); + } + + /** + * Test cluster cache and base operation. + * = + * @throws Exception + */ + public void testGetClusterCache() throws Exception + { + // Create cache manager + EmbeddedCacheManager manager =3D new DefaultCacheManager(GlobalConfi= guration.getClusteredDefault()); + + // Create a cache + Cache cache =3D manager.getCache(); + + cache.put("key", "value"); + assertTrue(cache.size() =3D=3D 1); + assertTrue(cache.containsKey("key")); + + String value =3D (String)cache.remove("key"); + assertTrue(value.equals("value")); + assertTrue(cache.isEmpty()); + + cache.put("key", "value"); + cache.putIfAbsent("key", "newValue"); + assertTrue("value".equals(cache.get("key"))); + + cache.clear(); + assertTrue(cache.isEmpty()); + + cache.put("key", "value", 2, TimeUnit.SECONDS); + assertTrue(cache.containsKey("key")); + Thread.sleep(2000); + assertFalse(cache.containsKey("key")); + } +} --===============5082880013762212056==--