You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directmemory.apache.org by ol...@apache.org on 2012/02/28 13:25:26 UTC

svn commit: r1294618 - in /incubator/directmemory/trunk/itests: ./ osgi/ osgi/src/test/java/org/apache/directmemory/tests/osgi/ osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/

Author: olamy
Date: Tue Feb 28 12:25:25 2012
New Revision: 1294618

URL: http://svn.apache.org/viewvc?rev=1294618&view=rev
Log:
fix osgi test compilation
make vm debug mode configurable tru cli -Dosgi.debug=true.

Modified:
    incubator/directmemory/trunk/itests/osgi/pom.xml
    incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/DirectMemoryOsgiTestSupport.java
    incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheServiceExportingActivator.java
    incubator/directmemory/trunk/itests/pom.xml

Modified: incubator/directmemory/trunk/itests/osgi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/pom.xml?rev=1294618&r1=1294617&r2=1294618&view=diff
==============================================================================
--- incubator/directmemory/trunk/itests/osgi/pom.xml (original)
+++ incubator/directmemory/trunk/itests/osgi/pom.xml Tue Feb 28 12:25:25 2012
@@ -21,8 +21,8 @@ under the License.
          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>
+    <artifactId>itests</artifactId>
     <version>0.6.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
@@ -31,7 +31,11 @@ under the License.
   <artifactId>osgi</artifactId>
   <name>Apache DirectMemory :: Integration Tests :: OSGi</name>
   <description>${project.name}</description>
-
+  <properties>
+    <osgi.debug>false</osgi.debug>
+    <osgi.debug.port>5005</osgi.debug.port>
+    <osgi.debug.suspend>true</osgi.debug.suspend>
+  </properties>
   <dependencies>
 
     <dependency>
@@ -80,4 +84,23 @@ under the License.
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.12</version>
+        <configuration>
+          <argLine>-Xmx512m -Xms512m -XX:MaxDirectMemorySize=512m</argLine>
+          <systemPropertyVariables>
+            <osgi.debug>${osgi.debug}</osgi.debug>
+            <osgi.debug.port>${osgi.debug.port}</osgi.debug.port>
+            <osgi.debug.suspend>${osgi.debug.suspend}</osgi.debug.suspend>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+
 </project>
\ No newline at end of file

Modified: incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/DirectMemoryOsgiTestSupport.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/DirectMemoryOsgiTestSupport.java?rev=1294618&r1=1294617&r2=1294618&view=diff
==============================================================================
--- incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/DirectMemoryOsgiTestSupport.java (original)
+++ incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/DirectMemoryOsgiTestSupport.java Tue Feb 28 12:25:25 2012
@@ -19,16 +19,10 @@
 
 package org.apache.directmemory.tests.osgi;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
 import org.ops4j.pax.exam.Inject;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.options.VMOption;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.options.UrlProvisionOption;
 import org.ops4j.store.Store;
 import org.ops4j.store.StoreFactory;
@@ -40,6 +34,15 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
 
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
@@ -159,7 +162,7 @@ public class DirectMemoryOsgiTestSupport
      */
     public static Option[] getDynamicMemoryOptions()
     {
-        return new Option[]{
+        List<MavenArtifactProvisionOption> mavenOptions = Arrays.asList(
             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" ),
@@ -173,7 +176,14 @@ public class DirectMemoryOsgiTestSupport
                 "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.6.0-SNAPSHOT" ) };
+                "0.6.0-SNAPSHOT" ));
+        List<Option> options = new ArrayList<Option>( mavenOptions );
+        if ( Boolean.getBoolean( "osgi.debug" ) )
+        {
+            options.add( enabledDebuggingOnPort( Integer.getInteger( "osgi.debug.port" ),
+                                                 Boolean.getBoolean( "osgi.debug.suspend" ) ) );
+        }
+        return options.toArray( new Option[options.size()] );
     }
 
     protected static UrlProvisionOption bundle( final InputStream stream )

Modified: incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheServiceExportingActivator.java
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheServiceExportingActivator.java?rev=1294618&r1=1294617&r2=1294618&view=diff
==============================================================================
--- incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheServiceExportingActivator.java (original)
+++ incubator/directmemory/trunk/itests/osgi/src/test/java/org/apache/directmemory/tests/osgi/cache/CacheServiceExportingActivator.java Tue Feb 28 12:25:25 2012
@@ -19,27 +19,45 @@
 
 package org.apache.directmemory.tests.osgi.cache;
 
-import java.util.Properties;
-
+import org.apache.directmemory.DirectMemory;
 import org.apache.directmemory.cache.CacheService;
-import org.apache.directmemory.cache.CacheServiceImpl;
 import org.apache.directmemory.measures.Ram;
+import org.apache.directmemory.memory.AllocationPolicy;
+import org.apache.directmemory.memory.MemoryManagerService;
+import org.apache.directmemory.memory.MemoryManagerServiceWithAllocationPolicyImpl;
+import org.apache.directmemory.memory.RoundRobinAllocationPolicy;
+import org.apache.directmemory.serialization.SerializerFactory;
+import org.apache.directmemory.serialization.StandardSerializer;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
+import java.util.Properties;
+
 public class CacheServiceExportingActivator
     implements BundleActivator
 {
 
-    CacheService cacheService = new CacheServiceImpl();
+    CacheService<String, SimpleObject> cacheService;
 
     @Override
     public void start( BundleContext context )
         throws Exception
     {
-        cacheService.init( 1, Ram.Mb( 16 ) );
+        AllocationPolicy<SimpleObject> allocationPolicy = new RoundRobinAllocationPolicy<SimpleObject>();
+        MemoryManagerService<SimpleObject> memoryManager =
+            new MemoryManagerServiceWithAllocationPolicyImpl<SimpleObject>( allocationPolicy, true );
+        this.cacheService =
+            new DirectMemory<String, SimpleObject>().setNumberOfBuffers( 1 ).setSize( Ram.Mb( 1 ) ).setMemoryManager(
+                memoryManager ).setSerializer(
+                SerializerFactory.createNewSerializer( StandardSerializer.class ) ).newCacheService();
         cacheService.put( "1", new SimpleObject( "1,", "Activator Object" ) );
         context.registerService( CacheService.class.getCanonicalName(), cacheService, new Properties() );
+
+        /*CacheService<Integer, byte[]> cache = new DirectMemory<Integer, byte[]>()
+        .setMemoryManager( memoryManager )
+        .setNumberOfBuffers( 1 )
+        .setSize(  )
+        .newCacheService();*/
     }
 
     @Override

Modified: incubator/directmemory/trunk/itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/directmemory/trunk/itests/pom.xml?rev=1294618&r1=1294617&r2=1294618&view=diff
==============================================================================
--- incubator/directmemory/trunk/itests/pom.xml (original)
+++ incubator/directmemory/trunk/itests/pom.xml Tue Feb 28 12:25:25 2012
@@ -21,13 +21,12 @@ under the License.
          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>
+    <artifactId>directmemory-parent</artifactId>
     <version>0.6.0-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>