incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
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 GMT
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 @@
         <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache</url>
     </scm>
     
+    <properties>
+        <bundle.build.name>
+            ${basedir}/target
+        </bundle.build.name>
+        <bundle.file.name>
+            ${bundle.build.name}/${project.build.finalName}.jar
+        </bundle.file.name>
+    </properties>
 
     <build>
         <plugins>
             <plugin>
                 <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <version>2.3.6</version>
                 <extensions>true</extensions>
@@ -56,7 +68,6 @@
 		               !sun.misc,
 		               !org.jgroups.*,
 		               !org.hibernate.cache,
-		               !edu.emory.mathcs.backport.java.util.*,
 		               *
 		            </Import-Package>
 		            <Private-Package>
@@ -65,12 +76,49 @@
 		            </Private-Package>
 		            <DynamicImport-Package>sun.misc.*</DynamicImport-Package>
 		            <Embed-Transitive>true</Embed-Transitive>
-		            <Embed-Dependency>ehcache,jsr107cache</Embed-Dependency>
+		            <Embed-Dependency>ehcache,jsr107cache,backport-util-concurrent</Embed-Dependency>
                     </instructions>
                 </configuration>
             </plugin>
         </plugins>
     </build>
+    <profiles>
+        <profile>
+            <id>java6</id>
+            <activation>
+                <jdk>1.6</jdk>
+            </activation>
+            <build>
+                <plugins>
+                  <!-- integration tests run with pax-exam -->
+                    <plugin>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <version>2.12</version>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <systemProperties>
+                                <property>
+                                    <name>project.bundle.file</name>
+                                    <value>${bundle.file.name}</value>
+                                </property>
+                            </systemProperties>
+                            <includes>
+                                <include>**/*IT.java</include>
+                            </includes>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+    
 
     <dependencies>
         <dependency>
@@ -118,6 +166,12 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
-        
+        <dependency>
+	       	<groupId>org.apache.sling</groupId>
+	       	<artifactId>org.apache.sling.commons.cache.container-test</artifactId>
+	       	<version>0.1-SNAPSHOT</version>
+	       	<scope>test</scope>
+        </dependency>
+             
     </dependencies>
 </project>

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<String> 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<String> 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<String> 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<String> 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<String> 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



Mime
View raw message