Author: iocanel
Date: Wed Oct 19 20:43:00 2011
New Revision: 1186472
URL: http://svn.apache.org/viewvc?rev=1186472&view=rev
Log:
[DIRECTMEMORY-22] Added pretty basic osgi integration tests.
Added:
incubator/directmemory/trunk/itests/
incubator/directmemory/trunk/itests/osgi/
incubator/directmemory/trunk/itests/osgi/pom.xml
incubator/directmemory/trunk/itests/osgi/src/
incubator/directmemory/trunk/itests/osgi/src/test/
incubator/directmemory/trunk/itests/osgi/src/test/java/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheTest.java
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/SimpleObject.java
incubator/directmemory/trunk/itests/pom.xml
Modified:
incubator/directmemory/trunk/pom.xml
Added: incubator/directmemory/trunk/itests/osgi/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/pom.xml?rev=1186472&view=auto
==============================================================================
--- incubator/directmemory/trunk/itests/osgi/pom.xml (added)
+++ incubator/directmemory/trunk/itests/osgi/pom.xml Wed Oct 19 20:43:00 2011
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>itests</artifactId>
+ <groupId>org.apache.directmemory</groupId>
+ <version>0.5.5-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.directmemory.itests</groupId>
+ <artifactId>osgi</artifactId>
+ <name>Apache DirectMemory :: Integration Tests :: OSGi</name>
+ <description>${project.name}</description>
+
+ <dependencies>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>org.apache.directmemory</groupId>
+ <artifactId>directmemory-cache</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added:
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheTest.java
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheTest.java?rev=1186472&view=auto
==============================================================================
---
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheTest.java
(added)
+++
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheTest.java
Wed Oct 19 20:43:00 2011
@@ -0,0 +1,131 @@
+/*
+ * 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.directmemory.tests.osgi.cache;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import org.apache.directmemory.cache.Cache;
+import org.apache.directmemory.measures.Every;
+import org.apache.directmemory.measures.Monitor;
+import org.apache.directmemory.measures.Ram;
+import org.apache.directmemory.memory.Pointer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.ops4j.pax.exam.Customizer;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.Constants;
+
+
+import static org.junit.Assert.*;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+import static org.ops4j.pax.exam.OptionUtils.expand;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static
org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.modifyBundle;
+
+@RunWith(JUnit4TestRunner.class)
+public class CacheTest {
+
+ /**
+ * This tests basic cache operations(put,retrieve) inside OSGi
+ */
+ @Test
+ public void testWithString() {
+ String key = "1";
+ String obj = "Simple String Object";
+ Cache.init(1, Ram.Mb(16));
+ Cache.scheduleDisposalEvery(Every.seconds(1));
+ Cache.dump();
+
+ Pointer p = Cache.put("1", obj);
+ Object result = Cache.retrieve("1");
+
+ Cache.dump();
+ Monitor.dump("cache");
+
+ assertEquals(obj, result);
+ }
+
+ /**
+ * This test basic cache operations(put,retrieve) inside OSGi using an
object of an imported class (provided by an other bundle).
+ */
+ @Test
+ public void testWithImportedObject() {
+ SimpleObject obj1 = new SimpleObject("1","Object One");
+ SimpleObject obj2 = new SimpleObject("2","Object Two");
+ Cache.init(1, Ram.Mb(16));
+ Cache.scheduleDisposalEvery(Every.seconds(1));
+ Cache.dump();
+
+ Pointer p1 = Cache.put("1",obj1 );
+ Pointer p2 = Cache.put("2",obj2 );
+ Object result1 = Cache.retrieve("1");
+ Object result2 = Cache.retrieve("2");
+
+ Cache.dump();
+ Monitor.dump("cache");
+
+ assertEquals(obj1, result1);
+ assertEquals(obj2, result2);
+ }
+
+
+ @Configuration
+ public Option[] configure() {
+ return expand(
+
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.configadmin").version("1.2.8"),
+
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version("1.6.2"),
+
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-service").version("1.6.2"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.guava").version("09_1"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.ant").version("1.7.0_5"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.ant").version("1.7.0_5"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.ant").version("1.7.0_5"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.oro").version("2.0.8_5"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.josql").version("1.5_5"),
+
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.aspectj").version("1.6.8_2"),
+
mavenBundle().groupId("com.dyuproject.protostuff").artifactId("protostuff-uberjar").version("1.0.2"),
+
mavenBundle().groupId("org.apache.directmemory").artifactId("directmemory-cache").version("0.5.5-SNAPSHOT"),
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe(InputStream
testProbe) {
+ return modifyBundle(testProbe)
+ .add(SimpleObject.class)
+ .set(Constants.DYNAMICIMPORT_PACKAGE, "*")
+ .build();
+ }
+ },
+ //Uncomment the line below to debug test
+
vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+ felix(),
+ equinox()
+ );
+ }
+}
\ No newline at end of file
Added:
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/SimpleObject.java
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/SimpleObject.java?rev=1186472&view=auto
==============================================================================
---
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/SimpleObject.java
(added)
+++
incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/SimpleObject.java
Wed Oct 19 20:43:00 2011
@@ -0,0 +1,66 @@
+/*
+ * 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.directmemory.tests.osgi.cache;
+
+public class SimpleObject {
+ private String id;
+ private String name;
+
+ public SimpleObject() {
+ }
+
+ public SimpleObject(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ SimpleObject that = (SimpleObject) o;
+
+ if (!id.equals(that.id)) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+}
Added: incubator/directmemory/trunk/itests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/pom.xml?rev=1186472&view=auto
==============================================================================
--- incubator/directmemory/trunk/itests/pom.xml (added)
+++ incubator/directmemory/trunk/itests/pom.xml Wed Oct 19 20:43:00 2011
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>directmemory-parent</artifactId>
+ <groupId>org.apache.directmemory</groupId>
+ <version>0.5.5-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.directmemory</groupId>
+ <artifactId>itests</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache DirectMemory :: Integration Tests</name>
+ <description>${project.name}</description>
+
+ <modules>
+ <module>osgi</module>
+ </modules>
+
+</project>
\ No newline at end of file
Modified: incubator/directmemory/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/pom.xml?rev=1186472&r1=1186471&r2=1186472&view=diff
==============================================================================
--- incubator/directmemory/trunk/pom.xml (original)
+++ incubator/directmemory/trunk/pom.xml Wed Oct 19 20:43:00 2011
@@ -193,6 +193,7 @@ under the License.
<modules>
<module>directmemory-cache</module>
+ <module>itests</module>
</modules>
<scm>
@@ -237,6 +238,8 @@ under the License.
<junit.version>4.10</junit.version>
<junit-benchamrks.version>0.3.0-SNAPSHOT</junit-benchamrks.version>
<logback.version>0.9.26</logback.version>
+ <pax-exam.version>1.2.4</pax-exam.version>
+ <pax-tiny-bundle.version>1.3.1</pax-tiny-bundle.version>
<protostuff.version>1.0.1</protostuff.version>
<slf4j.version>1.6.1</slf4j.version>
<wagon.version>2.0</wagon.version>
@@ -449,6 +452,12 @@ under the License.
<dependencyManagement>
<dependencies>
+ <!-- Intenral Project Artifacts -->
+ <dependency>
+ <groupId>org.apache.directmemory</groupId>
+ <artifactId>directmemory-cache</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
@@ -510,6 +519,31 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>${pax-exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>${pax-exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>${pax-exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>${pax-tiny-bundle.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.dyuproject.protostuff</groupId>
<artifactId>protostuff-runtime</artifactId>
<version>${protostuff.version}</version>
@@ -533,6 +567,12 @@ under the License.
<version>${slf4j.version}</version>
<type>jar</type>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4j.version}</version>
+ <type>jar</type>
+ </dependency>
</dependencies>
</dependencyManagement>