[jboss-osgi-commits] JBoss-OSGI SVN: r93653 - in projects/jboss-osgi/trunk/testsuite: example/src/test/java/org/jboss/test/osgi/example/blueprint and 5 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Thu Sep 17 12:16:13 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-17 12:16:11 -0400 (Thu, 17 Sep 2009)
New Revision: 93653

Added:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/blueprint/BlueprintStressTestCase.java
Modified:
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/blueprint/example-blueprint.bnd
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java
   projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
[JBOSGI-155] VirtualFile instance leak

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/blueprint/BlueprintStressTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/blueprint/BlueprintStressTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/blueprint/BlueprintStressTestCase.java	2009-09-17 16:16:11 UTC (rev 93653)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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.jboss.test.osgi.example.blueprint;
+
+//$Id: BlueprintTestCase.java 91550 2009-07-22 13:10:41Z thomas.diesler at jboss.com $
+
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.blueprint.BlueprintCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.example.blueprint.bundle.ServiceA;
+import org.jboss.test.osgi.example.blueprint.bundle.ServiceB;
+import org.jboss.virtual.VirtualFile;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+/**
+ * A simple Blueprint Container test.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 12-Jul-2009
+ */
+public class BlueprintStressTestCase
+{
+   private static int RUN_COUNT = 100;
+
+   @Test
+   @Ignore
+   public void testBlueprintBundleInstall() throws Exception
+   {
+      OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+      BlueprintCapability blueprintCapability = new BlueprintCapability();
+      try
+      {
+         long lastTime = System.currentTimeMillis();
+         for (int i = 0; i < RUN_COUNT; i++)
+         {
+            runtime.addCapability(blueprintCapability);
+
+            OSGiBundle bundle = runtime.installBundle("example-blueprint.jar");
+            bundle.start();
+
+            OSGiServiceReference sref = runtime.getServiceReference(BlueprintContainer.class.getName());
+            assertNotNull("BlueprintContainer service not null", sref);
+
+            OSGiServiceReference srefA = runtime.getServiceReference(ServiceA.class.getName());
+            assertNotNull("ServiceA not null", srefA);
+
+            OSGiServiceReference srefB = runtime.getServiceReference(ServiceB.class.getName());
+            assertNotNull("ServiceB not null", srefB);
+
+            bundle.uninstall();
+            runtime.removeCapability(blueprintCapability);
+            
+            long currTime = System.currentTimeMillis();
+            System.out.println("#" + (i + 1) + " " + (currTime - lastTime) + "ms " + VirtualFile.getCount());
+
+            Thread.sleep(3000);
+            lastTime = currTime;
+         }
+      }
+      finally
+      {
+         runtime.shutdown();
+      }
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-09-17 16:16:11 UTC (rev 93653)
@@ -21,6 +21,8 @@
           <!-- [JBOSGI-145]  JAXB classes are loaded from the system classpath -->
           com.sun.xml.internal.bind.v2,
           
+          com.yourkit.runtime,
+          
           org.jboss.beans.metadata.plugins;version=2.0,
           org.jboss.beans.metadata.plugins.builder;version=2.0,
           org.jboss.beans.metadata.spi;version=2.0,
@@ -28,6 +30,7 @@
           org.jboss.dependency.spi;version=2.0,
           org.jboss.kernel.spi.dependency;version=2.0,
           org.jboss.logging;version=2.0,
+          org.jboss.virtual;version=2.1,
           
           org.jboss.osgi.spi;version=1.0,
           org.jboss.osgi.spi.capability;version=1.0,

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/blueprint/example-blueprint.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/blueprint/example-blueprint.bnd	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/blueprint/example-blueprint.bnd	2009-09-17 16:16:11 UTC (rev 93653)
@@ -7,11 +7,12 @@
 Import-Package: \
 	javax.management, \
 	org.jboss.osgi.blueprint, \
-	org.jboss.osgi.husky, \
-	org.jboss.osgi.husky.annotation, \
+	org.jboss.osgi.husky;resolution=optional, \
+	org.jboss.osgi.husky.annotation;resolution=optional, \
 	org.jboss.osgi.spi.capability, \
 	org.jboss.osgi.spi.testing, \
-	org.junit, \
+	org.jboss.virtual, \
+	org.junit;resolution=optional, \
 	org.osgi.framework, \
 	org.osgi.service.blueprint.* 
 

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/OSGI99TestCase.java	2009-09-17 16:16:11 UTC (rev 93653)
@@ -25,9 +25,11 @@
 
 import static org.junit.Assert.assertEquals;
 
+import org.jboss.osgi.spi.capability.LogServiceCapability;
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiRuntime;
 import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.virtual.VirtualFile;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 
@@ -45,15 +47,29 @@
    public void testInstallOnly() throws Exception
    {
       OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+      LogServiceCapability logCapability = new LogServiceCapability();
       try
       {
-         OSGiBundle bundleA = runtime.installBundle("jbosgi99-bundleA.jar");
-         assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+         runtime.addCapability(logCapability);
+         
+         long lastTime = System.currentTimeMillis();
+         for (int i = 0; i < 1; i++)
+         {
+            
+            OSGiBundle bundleA = runtime.installBundle("jbosgi99-bundleA.jar");
+            assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
 
-         bundleA.start();
-         assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
-         
-         bundleA.uninstall();
+            bundleA.start();
+            assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+
+            bundleA.uninstall();
+            
+            long currTime = System.currentTimeMillis();
+            System.out.println("#" + (i + 1) + " " + (currTime - lastTime) + "ms " + VirtualFile.getCount());
+
+            //Thread.sleep(10000);
+            lastTime = currTime;
+         }
       }
       finally
       {

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi99/bundleA/ActivatorBundleA.java	2009-09-17 16:16:11 UTC (rev 93653)
@@ -25,14 +25,26 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
 
 public class ActivatorBundleA implements BundleActivator
 {
+   private LogService log;
+   
    public void start(BundleContext context)
    {
+      ServiceReference sref = context.getServiceReference(LogService.class.getName());
+      if (sref != null)
+      {
+         log = (LogService)context.getService(sref);
+         log.log(LogService.LOG_INFO, "ActivatorBundleA.start()");
+      }
    }
 
    public void stop(BundleContext context)
    {
+      if (log != null)
+         log.log(LogService.LOG_INFO, "ActivatorBundleA.stop()");
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-09-17 16:16:11 UTC (rev 93653)
@@ -21,6 +21,8 @@
           <!-- [JBOSGI-145]  JAXB classes are loaded from the system classpath -->
           com.sun.xml.internal.bind.v2,
           
+          com.yourkit.runtime,
+          
           org.jboss.beans.metadata.plugins;version=2.0,
           org.jboss.beans.metadata.plugins.builder;version=2.0,
           org.jboss.beans.metadata.spi;version=2.0,

Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml	2009-09-17 16:13:51 UTC (rev 93652)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml	2009-09-17 16:16:11 UTC (rev 93653)
@@ -170,27 +170,6 @@
   <profiles>
 
     <!--
-      Name: framework-default 
-      Descr: Setup for default framework integration testing
-    -->
-    <profile>
-      <id>framework-default</id>
-      <activation>
-        <property>
-          <name>!framework</name>
-        </property>
-      </activation>
-      <dependencies>
-        <dependency>
-          <groupId>org.jboss.osgi.runtime</groupId>
-          <artifactId>jboss-osgi-runtime-microcontainer</artifactId>
-          <version>${version.jboss.osgi.runtime.jbossmc}</version>
-          <scope>provided</scope>
-        </dependency>
-      </dependencies>
-    </profile>
-
-    <!--
       Name: framework-equinox
       Descr: Setup for Equinox framework integration testing
     -->
@@ -267,12 +246,28 @@
           <scope>provided</scope>
         </dependency>
       </dependencies>
+    </profile>
+    <profile>
+      <id>framework-default</id>
+      <activation>
+        <property>
+          <name>!framework</name>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.jboss.osgi.runtime</groupId>
+          <artifactId>jboss-osgi-runtime-microcontainer</artifactId>
+          <version>${version.jboss.osgi.runtime.jbossmc}</version>
+          <scope>provided</scope>
+        </dependency>
+      </dependencies>
       <build>
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
-              <argLine>-Xmx1024m</argLine>
+              <argLine>-agentlib:yjpagent</argLine>
             </configuration>
           </plugin>
         </plugins>



More information about the jboss-osgi-commits mailing list