Author: rickhall
Date: Tue May 25 18:42:20 2010
New Revision: 948163
URL: http://svn.apache.org/viewvc?rev=948163&view=rev
Log:
Test if fragments resolve correctly after being updated.
Modified:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java
Modified:
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java
URL:
http://svn.apache.org/viewvc/felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java?rev=948163&r1=948162&r2=948163&view=diff
==============================================================================
---
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java
(original)
+++
felix/sandbox/rickhall/bnd-test/org.apache.felix.framework.test/src/org/apache/felix/framework/test/TestFragment.java
Tue May 25 18:42:20 2010
@@ -474,6 +474,81 @@ public class TestFragment extends FelixT
}
}
+ public void testFragmentUpdate() throws Exception
+ {
+ InputStream is = null;
+
+ // Scenario #1
+ //
+ // Install host and fragment. Update the fragment and then resolve
+ // the host and verify everyone is resolved and we can access a
+ // fragment class.
+ try
+ {
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b001.jar");
+ m_bundleA = getBundleContext().installBundle("fragment.b001.jar",
is);
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b003.jar");
+ m_bundleB = getBundleContext().installBundle("fragment.b003.jar",
is);
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b003.jar");
+ m_bundleB.update(is);
+
+ // Verify that importer has no wires to the fragment.
+ PackageAdmin pa = getPackageAdmin();
+ assertTrue("Host should resolve", pa.resolveBundles(new Bundle[] {
m_bundleA }));
+ assertEquals("Host should be resolved", Bundle.RESOLVED,
m_bundleA.getState());
+ assertEquals("Fragment should be resolved", Bundle.RESOLVED,
m_bundleB.getState());
+ try
+ {
+ Class clazz = m_bundleA.loadClass(
+
"org.apache.felix.framework.test.fragment.b003.FragmentClass");
+ assertNotNull("Class should not be null", clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ assertTrue("Class should be found", false);
+ }
+ }
+ finally
+ {
+ cleanup();
+ }
+
+ // Scenario #2
+ //
+ // Install host and fragment. Update the fragment and then resolve
+ // the fragment and verify everyone is resolved and we can access a
+ // fragment class.
+ try
+ {
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b001.jar");
+ m_bundleA = getBundleContext().installBundle("fragment.b001.jar",
is);
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b003.jar");
+ m_bundleB = getBundleContext().installBundle("fragment.b003.jar",
is);
+ is =
this.getClass().getClassLoader().getResourceAsStream("fragment.b003.jar");
+ m_bundleB.update(is);
+
+ // Verify that importer has no wires to the fragment.
+ PackageAdmin pa = getPackageAdmin();
+ assertTrue("Host should resolve", pa.resolveBundles(new Bundle[] {
m_bundleB }));
+ assertEquals("Host should be resolved", Bundle.RESOLVED,
m_bundleA.getState());
+ assertEquals("Fragment should be resolved", Bundle.RESOLVED,
m_bundleB.getState());
+ try
+ {
+ Class clazz = m_bundleA.loadClass(
+
"org.apache.felix.framework.test.fragment.b003.FragmentClass");
+ assertNotNull("Class should not be null", clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ assertTrue("Class should be found", false);
+ }
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
public void testFragmentMisc() throws Exception
{
InputStream is = null;