felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r784263 - in /felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test: ./ recipes/ src/org/apache/felix/framework/test/ src/org/apache/felix/framework/test/activationpolicy/b4/ src/org/apache/felix/framework/test/activationpolicy/b4...
Date Fri, 12 Jun 2009 20:34:20 GMT
Author: rickhall
Date: Fri Jun 12 20:34:19 2009
New Revision: 784263

URL: http://svn.apache.org/viewvc?rev=784263&view=rev
Log:
Add some tests for activation policy directives.

Added:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4a.bnd
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4b.bnd
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestActivationPolicy.java
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/NeitherClass.java
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/ExcludedClass.java
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/IncludedClass.java
Modified:
    felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd

Modified: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd?rev=784263&r1=784262&r2=784263&view=diff
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd (original)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/bnd.bnd Fri Jun 12 20:34:19
2009
@@ -8,6 +8,7 @@
  fragment.b4.jar, fragment.b5.jar, \
  fragment.b6.jar, fragment.b7.jar, fragment.b8.jar, \
  activationpolicy.b1.jar, activationpolicy.b2.jar, activationpolicy.b3.jar, \
+ activationpolicy.b4a.jar, activationpolicy.b4b.jar, \
  org/apache/felix/framework/test/fragment/Message.properties=src/resource/Message.properties,org/apache/felix/framework/test/fragment/Message_fr.properties=src/resource/Message_fr.properties
 
 -buildpath: \

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4a.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4a.bnd?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4a.bnd
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4a.bnd
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,4 @@
+Private-Package: org.apache.felix.framework.test.activationpolicy.b4.*
+Bundle-ActivationPolicy: lazy; \
+ include:="org.apache.felix.framework.test.activationpolicy.b4.included"
+ 

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4b.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4b.bnd?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4b.bnd
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/recipes/activationpolicy.b4b.bnd
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,4 @@
+Private-Package: org.apache.felix.framework.test.activationpolicy.b4.*
+Bundle-ActivationPolicy: lazy; \
+ exclude:="org.apache.felix.framework.test.activationpolicy.b4.excluded"
+ 

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestActivationPolicy.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestActivationPolicy.java?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestActivationPolicy.java
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestActivationPolicy.java
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,143 @@
+/*
+ * 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.felix.framework.test;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class TestActivationPolicy extends FelixTestCase
+{
+    private Bundle m_bundleA = null;
+    private Bundle m_bundleB = null;
+    private Bundle m_bundleC = null;
+    private Bundle m_bundleD = null;
+
+    public void testDirectives() throws Exception
+    {
+        InputStream is = null;
+
+        // Scenario #1
+        //
+        // Install host, fragment, and bundle importing fragment package.
+        // Start the importing bundle and verify that it is wired to the
+        // host bundle, not the fragment bundle.
+        try
+        {
+            is = this.getClass().getClassLoader().getResourceAsStream("activationpolicy.b4a.jar");
+            m_bundleA = getBundleContext().installBundle("activationpolicy.b4a.jar", is);
+            m_bundleA.start(Bundle.START_ACTIVATION_POLICY);
+            assertFalse("Bundle should not be active", m_bundleA.getState() == Bundle.ACTIVE);
+
+            Class clazz = m_bundleA.loadClass("org.apache.felix.framework.test.activationpolicy.b4.excluded.ExcludedClass");
+            assertFalse("Bundle should not be active", m_bundleA.getState() == Bundle.ACTIVE);
+
+            clazz = m_bundleA.loadClass("org.apache.felix.framework.test.activationpolicy.b4.included.IncludedClass");
+            assertTrue("Bundle should be active", m_bundleA.getState() == Bundle.ACTIVE);
+        }
+        finally
+        {
+            cleanup();
+        }
+
+        // Scenario #2
+        //
+        // Install host, fragment, and bundle importing fragment package.
+        // Start the importing bundle and verify that it is wired to the
+        // host bundle, not the fragment bundle.
+        try
+        {
+            is = this.getClass().getClassLoader().getResourceAsStream("activationpolicy.b4b.jar");
+            m_bundleA = getBundleContext().installBundle("activationpolicy.b4b.jar", is);
+            m_bundleA.start(Bundle.START_ACTIVATION_POLICY);
+            assertFalse("Bundle should not be active", m_bundleA.getState() == Bundle.ACTIVE);
+
+            Class clazz = m_bundleA.loadClass("org.apache.felix.framework.test.activationpolicy.b4.excluded.ExcludedClass");
+            assertFalse("Bundle should not be active", m_bundleA.getState() == Bundle.ACTIVE);
+
+            clazz = m_bundleA.loadClass("org.apache.felix.framework.test.activationpolicy.b4.included.IncludedClass");
+            assertTrue("Bundle should be active", m_bundleA.getState() == Bundle.ACTIVE);
+        }
+        finally
+        {
+            cleanup();
+        }
+    }
+
+    private void cleanup()
+    {
+        if (m_bundleA != null)
+        {
+            try
+            {
+                m_bundleA.uninstall();
+            }
+            catch (Exception ex)
+            {
+                // Ummm?
+            }
+            m_bundleA = null;
+        }
+        if (m_bundleB != null)
+        {
+            try
+            {
+                m_bundleB.uninstall();
+            }
+            catch (Exception ex)
+            {
+                // Ummm?
+            }
+            m_bundleB = null;
+        }
+        if (m_bundleC != null)
+        {
+            try
+            {
+                m_bundleC.uninstall();
+            }
+            catch (Exception ex)
+            {
+                // Ummm?
+            }
+            m_bundleC = null;
+        }
+        if (m_bundleD != null)
+        {
+            try
+            {
+                m_bundleD.uninstall();
+            }
+            catch (Exception ex)
+            {
+                // Ummm?
+            }
+            m_bundleD = null;
+        }
+        refreshAndWait();
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/NeitherClass.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/NeitherClass.java?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/NeitherClass.java
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/NeitherClass.java
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,27 @@
+/*
+ * 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.felix.framework.test.activationpolicy.b4;
+
+public class NeitherClass
+{
+    public NeitherClass()
+    {
+        System.out.println("Loading this class should NOT cause the bundle to activate.");
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/ExcludedClass.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/ExcludedClass.java?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/ExcludedClass.java
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/excluded/ExcludedClass.java
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,27 @@
+/*
+ * 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.felix.framework.test.activationpolicy.b4.excluded;
+
+public class ExcludedClass
+{
+    public ExcludedClass()
+    {
+        System.out.println("Loading this class should NOT cause the bundle to activate.");
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/IncludedClass.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/IncludedClass.java?rev=784263&view=auto
==============================================================================
--- felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/IncludedClass.java
(added)
+++ felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/activationpolicy/b4/included/IncludedClass.java
Fri Jun 12 20:34:19 2009
@@ -0,0 +1,27 @@
+/*
+ * 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.felix.framework.test.activationpolicy.b4.included;
+
+public class IncludedClass
+{
+    public IncludedClass()
+    {
+        System.out.println("Loading this class should cause the bundle to activate.");
+    }
+}
\ No newline at end of file



Mime
View raw message