Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DBA7D720 for ; Fri, 2 Nov 2012 12:12:01 +0000 (UTC) Received: (qmail 47096 invoked by uid 500); 2 Nov 2012 12:12:01 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 47032 invoked by uid 500); 2 Nov 2012 12:12:00 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 47025 invoked by uid 99); 2 Nov 2012 12:12:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2012 12:12:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Nov 2012 12:11:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 54ED82388A5B; Fri, 2 Nov 2012 12:11:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1404940 - in /sling/whiteboard/ieb/cache/ehcache: pom.xml src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java Date: Fri, 02 Nov 2012 12:11:39 -0000 To: commits@sling.apache.org From: ieb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121102121139.54ED82388A5B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ieb Date: Fri Nov 2 12:11:38 2012 New Revision: 1404940 URL: http://svn.apache.org/viewvc?rev=1404940&view=rev Log: SLING-2555 Fixed ehcache bundle and tested inside pax exam. Added: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java (with props) Modified: sling/whiteboard/ieb/cache/ehcache/pom.xml Modified: sling/whiteboard/ieb/cache/ehcache/pom.xml URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/pom.xml?rev=1404940&r1=1404939&r2=1404940&view=diff ============================================================================== --- sling/whiteboard/ieb/cache/ehcache/pom.xml (original) +++ sling/whiteboard/ieb/cache/ehcache/pom.xml Fri Nov 2 12:11:38 2012 @@ -42,11 +42,23 @@ http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache + + + ${basedir}/target + + + ${bundle.build.name}/${project.build.finalName}.jar + + org.apache.felix + maven-scr-plugin + + + org.apache.felix maven-bundle-plugin 2.3.6 true @@ -56,7 +68,6 @@ !sun.misc, !org.jgroups.*, !org.hibernate.cache, - !edu.emory.mathcs.backport.java.util.*, * @@ -65,12 +76,49 @@ sun.misc.* true - ehcache,jsr107cache + ehcache,jsr107cache,backport-util-concurrent + + + java6 + + 1.6 + + + + + + maven-failsafe-plugin + 2.12 + + + + integration-test + verify + + + + + + + project.bundle.file + ${bundle.file.name} + + + + **/*IT.java + + + + + + + + @@ -118,6 +166,12 @@ junit junit - + + org.apache.sling + org.apache.sling.commons.cache.container-test + 0.1-SNAPSHOT + test + + Added: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java?rev=1404940&view=auto ============================================================================== --- sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java (added) +++ sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java Fri Nov 2 12:11:38 2012 @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.commons.cache.ehcache; + +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.CoreOptions.provision; + +import javax.inject.Inject; + +import org.apache.sling.commons.cache.api.Cache; +import org.apache.sling.commons.cache.api.CacheManagerService; +import org.apache.sling.commons.cache.api.CacheScope; +import org.apache.sling.test.AbstractOSGiRunner; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.ExamReactorStrategy; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactorFactory; + +/** + * Spin the cache up in a container to verify we have a working system. + */ +@RunWith(JUnit4TestRunner.class) +@ExamReactorStrategy(EagerSingleStagedReactorFactory.class) // we want to spin up the container once only. +public class CacheIT extends AbstractOSGiRunner { + + + @Inject + private CacheManagerService cacheManagerService; + + + @Override + protected String getImports() { + return "org.apache.sling.commons.cache.api"; + } + + public Option[] getOptions() { + return options( + provision( + mavenBundle("org.apache.sling", "org.apache.sling.commons.cache.api") + )); + } + + protected String getArtifactName() { + return "org.apache.sling.commons.cache.ehcache"; + } + + + + @Test + public void testCacheManagerReplicated() { + String cacheName = "string-cache-replicated"; + Assert.assertNotNull(cacheManagerService); + Cache c = cacheManagerService.getCache(cacheName, + CacheScope.CLUSTERREPLICATED); + Assert.assertNotNull(c); + String v = cacheName + String.valueOf(System.currentTimeMillis()); + c.put("key", v); + Assert.assertEquals(v, c.get("key")); + cacheManagerService.unbind(CacheScope.CLUSTERREPLICATED); + cacheManagerService.unbind(CacheScope.CLUSTERINVALIDATED); + cacheManagerService.unbind(CacheScope.INSTANCE); + cacheManagerService.unbind(CacheScope.REQUEST); + cacheManagerService.unbind(CacheScope.THREAD); + c = cacheManagerService.getCache(cacheName, + CacheScope.CLUSTERREPLICATED); + Assert.assertNotNull(c); + Assert.assertEquals(v, c.get("key")); + + } + + @Test + public void testCacheManagerInvalidated() { + String cacheName = "string-cache-invalidated"; + Assert.assertNotNull(cacheManagerService); + Cache c = cacheManagerService.getCache(cacheName, + CacheScope.CLUSTERINVALIDATED); + Assert.assertNotNull(c); + String v = cacheName + String.valueOf(System.currentTimeMillis()); + c.put("key", v); + Assert.assertEquals(v, c.get("key")); + cacheManagerService.unbind(CacheScope.CLUSTERREPLICATED); + cacheManagerService.unbind(CacheScope.CLUSTERINVALIDATED); + cacheManagerService.unbind(CacheScope.INSTANCE); + cacheManagerService.unbind(CacheScope.REQUEST); + cacheManagerService.unbind(CacheScope.THREAD); + c = cacheManagerService.getCache(cacheName, + CacheScope.CLUSTERINVALIDATED); + Assert.assertNotNull(c); + Assert.assertEquals(v, c.get("key")); + } + + //@Test + public void testCacheManagerInstance() { + String cacheName = "string-cache-instance"; + Assert.assertNotNull(cacheManagerService); + Cache c = cacheManagerService.getCache(cacheName, + CacheScope.INSTANCE); + Assert.assertNotNull(c); + String v = cacheName + String.valueOf(System.currentTimeMillis()); + c.put("key", v); + Assert.assertEquals(v, c.get("key")); + cacheManagerService.unbind(CacheScope.CLUSTERREPLICATED); + cacheManagerService.unbind(CacheScope.CLUSTERINVALIDATED); + cacheManagerService.unbind(CacheScope.INSTANCE); + cacheManagerService.unbind(CacheScope.REQUEST); + cacheManagerService.unbind(CacheScope.THREAD); + c = cacheManagerService.getCache(cacheName, CacheScope.INSTANCE); + Assert.assertNotNull(c); + Assert.assertEquals(v, c.get("key")); + } + + @Test + public void testCacheManagerRequest() { + String cacheName = "string-cache-request"; + Assert.assertNotNull(cacheManagerService); + Cache c = cacheManagerService.getCache(cacheName, + CacheScope.REQUEST); + Assert.assertNotNull(c); + String v = cacheName + String.valueOf(System.currentTimeMillis()); + c.put("key", v); + Assert.assertEquals(v, c.get("key")); + cacheManagerService.unbind(CacheScope.CLUSTERREPLICATED); + cacheManagerService.unbind(CacheScope.CLUSTERINVALIDATED); + cacheManagerService.unbind(CacheScope.INSTANCE); + cacheManagerService.unbind(CacheScope.REQUEST); + cacheManagerService.unbind(CacheScope.THREAD); + c = cacheManagerService.getCache(cacheName, CacheScope.REQUEST); + Assert.assertNotNull(c); + Assert.assertNull(c.get("key")); + } + + @Test + public void testCacheManagerThread() { + String cacheName = "string-cache-thread"; + Assert.assertNotNull(cacheManagerService); + Cache c = cacheManagerService.getCache(cacheName, + CacheScope.THREAD); + Assert.assertNotNull(c); + String v = cacheName + String.valueOf(System.currentTimeMillis()); + c.put("key", v); + Assert.assertEquals(v, c.get("key")); + cacheManagerService.unbind(CacheScope.CLUSTERREPLICATED); + cacheManagerService.unbind(CacheScope.CLUSTERINVALIDATED); + cacheManagerService.unbind(CacheScope.INSTANCE); + cacheManagerService.unbind(CacheScope.REQUEST); + cacheManagerService.unbind(CacheScope.THREAD); + c = cacheManagerService.getCache(cacheName, CacheScope.THREAD); + Assert.assertNotNull(c); + Assert.assertNull(c.get("key")); + } + +} Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheIT.java ------------------------------------------------------------------------------ svn:eol-style = native