update to easymock 3.2 and felix 3.2.2
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/CmConfigAndCtxPropertiesConfigurationTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/CmConfigAndCtxPropertiesConfigurationTest.java
index 79dfa0b..dbb079b 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/CmConfigAndCtxPropertiesConfigurationTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/CmConfigAndCtxPropertiesConfigurationTest.java
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

  * is available at http://www.opensource.org/licenses/apache2.0.php.

  * You may elect to redistribute this code under either of these licenses. 

- * 

+ *

  * Contributors:

  *   VMware Inc.

  *****************************************************************************/

@@ -19,7 +19,8 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

+

 import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.ServiceReference;

@@ -32,58 +33,45 @@
 

 /**

  * @author Costin Leau

- * 

  */

 public class CmConfigAndCtxPropertiesConfigurationTest extends TestCase {

 

-	private GenericApplicationContext appContext;

-

-	private BundleContext bundleContext;

-

-	private MockControl adminControl;

-

-	private ConfigurationAdmin admin;

-

-	private Dictionary config;

+    private ConfigurationAdmin admin;

 

 

-	protected void setUp() throws Exception {

+    protected void setUp() throws Exception {

+        admin = createMock(ConfigurationAdmin.class);

+        Configuration cfg = createMock(Configuration.class);

 

-		adminControl = MockControl.createControl(ConfigurationAdmin.class);

-		admin = (ConfigurationAdmin) adminControl.getMock();

-		MockControl configMock = MockControl.createControl(Configuration.class);

-		Configuration cfg = (Configuration) configMock.getMock();

+        Dictionary config = new Hashtable();

 

-		config = new Hashtable();

+        expect(admin.getConfiguration("com.xyz.myapp")).andReturn(cfg).atLeastOnce();

+        expect(cfg.getProperties()).andReturn(config).atLeastOnce();

 

-		adminControl.expectAndReturn(admin.getConfiguration("com.xyz.myapp"), cfg, MockControl.ONE_OR_MORE);

-		configMock.expectAndReturn(cfg.getProperties(), config, MockControl.ONE_OR_MORE);

+        replay(admin, cfg);

 

-		adminControl.replay();

-		configMock.replay();

+        BundleContext bundleContext = new MockBundleContext() {

 

-		bundleContext = new MockBundleContext() {

+            // add Configuration admin support

+            public Object getService(ServiceReference reference) {

+                return admin;

+            }

+        };

 

-			// add Configuration admin support

-			public Object getService(ServiceReference reference) {

-				return admin;

-			}

-		};

+        GenericApplicationContext appContext = new GenericApplicationContext();

+        appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

 

-		appContext = new GenericApplicationContext();

-		appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

+        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);

+        // reader.setEventListener(this.listener);

+        reader.loadBeanDefinitions(new ClassPathResource("osgiPropertyPlaceholder.xml", getClass()));

+        appContext.refresh();

+    }

 

-		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);

-		// reader.setEventListener(this.listener);

-		reader.loadBeanDefinitions(new ClassPathResource("osgiPropertyPlaceholder.xml", getClass()));

-		appContext.refresh();

-	}

+    protected void tearDown() throws Exception {

+        verify(admin);

+    }

 

-	protected void tearDown() throws Exception {

-		adminControl.verify();

-	}

+    public void testValidateConfiguration() throws Exception {

 

-	public void testValidateConfiguration() throws Exception {

-

-	}

+    }

 }
\ No newline at end of file
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ConfigPropertiesHandlerTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ConfigPropertiesHandlerTest.java
index 75fbab1..2f01f4b 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ConfigPropertiesHandlerTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ConfigPropertiesHandlerTest.java
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

  * is available at http://www.opensource.org/licenses/apache2.0.php.

  * You may elect to redistribute this code under either of these licenses. 

- * 

+ *

  * Contributors:

  *   VMware Inc.

  *****************************************************************************/

@@ -21,7 +21,9 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

+

+import org.easymock.IMocksControl;

 import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;

 import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeEvent;

 import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeListener;

@@ -43,270 +45,268 @@
  */

 public class ConfigPropertiesHandlerTest extends TestCase {

 

-	private GenericApplicationContext appContext;

+    private GenericApplicationContext appContext;

 

-	private BundleContext bundleContext;

+    private BundleContext bundleContext;

 

-	private MockControl adminControl;

-

-	private ConfigurationAdmin admin;

-

-	private Dictionary<String, String> config;

-

-	private String persistentId = "foo.bar";

-	private Configuration cfg;

-	private ManagedService msCallback;

+    private IMocksControl adminControl;

+    private ConfigurationAdmin admin;

 

 

-	protected void setUp() throws Exception {

+    private Dictionary<String, String> config;

 

-		adminControl = MockControl.createControl(ConfigurationAdmin.class);

-		admin = (ConfigurationAdmin) adminControl.getMock();

-		MockControl configMock = MockControl.createControl(Configuration.class);

-		cfg = (Configuration) configMock.getMock();

+    private String persistentId = "foo.bar";

+    private Configuration cfg;

+    private ManagedService msCallback;

 

-		config = new Hashtable<String, String>();

 

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		configMock.expectAndReturn(cfg.getProperties(), config, MockControl.ONE_OR_MORE);

+    protected void setUp() throws Exception {

+        adminControl = createControl();

+        admin = adminControl.createMock(ConfigurationAdmin.class);

+        cfg = createMock(Configuration.class);

 

-		adminControl.replay();

-		configMock.replay();

+        config = new Hashtable<String, String>();

 

-		bundleContext = new MockBundleContext() {

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        expect(cfg.getProperties()).andReturn(config).atLeastOnce();

 

-			// add Configuration admin support

-			@Override

-			public Object getService(ServiceReference reference) {

-				return admin;

-			}

+        adminControl.replay();

+        replay(cfg);

 

-			// ManagedService registration

-			@Override

-			public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) {

-				// save the callback

-				if (ManagedService.class.getName().equals(clazz)) {

-					msCallback = (ManagedService) service;

-				}

-				return super.registerService(clazz, service, properties);

-			}

-		};

+        bundleContext = new MockBundleContext() {

 

-		appContext = new GenericApplicationContext();

-		appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

+            // add Configuration admin support

+            @Override

+            public Object getService(ServiceReference reference) {

+                return admin;

+            }

 

-		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);

-		// reader.setEventListener(this.listener);

-		reader.loadBeanDefinitions(new ClassPathResource("configProperties.xml", getClass()));

-		appContext.refresh();

-	}

+            // ManagedService registration

+            @Override

+            public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) {

+                // save the callback

+                if (ManagedService.class.getName().equals(clazz)) {

+                    msCallback = (ManagedService) service;

+                }

+                return super.registerService(clazz, service, properties);

+            }

+        };

 

-	protected void tearDown() throws Exception {

-		adminControl.verify();

-	}

+        appContext = new GenericApplicationContext();

+        appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

 

-	public void testPropertiesLazyInit() throws Exception {

-		adminControl.reset();

-		adminControl.replay();

-	}

+        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);

+        // reader.setEventListener(this.listener);

+        reader.loadBeanDefinitions(new ClassPathResource("configProperties.xml", getClass()));

+        appContext.refresh();

+    }

 

-	public void testBlankConfigProperties() throws Exception {

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean("named");

-		assertTrue(bean instanceof Properties);

-		assertEquals(config, bean);

-	}

+    protected void tearDown() throws Exception {

+        adminControl.verify();

+    }

 

-	public void testPropertiesWithDefaultsAndNoOverride() throws Exception {

-		persistentId = "noLocalOverride";

+    public void testPropertiesLazyInit() throws Exception {

+        adminControl.reset();

+        adminControl.replay();

+    }

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+    public void testBlankConfigProperties() throws Exception {

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean("named");

+        assertTrue(bean instanceof Properties);

+        assertEquals(config, bean);

+    }

 

-		config.put("foo", "foo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(persistentId);

-		assertTrue(bean instanceof Properties);

-		Properties props = (Properties) bean;

-		assertFalse(config.equals(bean));

-		// the local property has been replaced

-		assertEquals("foo", props.getProperty("foo"));

-		// but the one not present on the CM are still present

-		assertTrue(props.containsKey("kry"));

-		assertTrue(props.containsKey("Spring"));

-		assertEquals(3, props.entrySet().size());

-	}

+    public void testPropertiesWithDefaultsAndNoOverride() throws Exception {

+        persistentId = "noLocalOverride";

 

-	public void testPropertiesWithDefaultsAndOverride() throws Exception {

-		persistentId = "localOverride";

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+        config.put("foo", "foo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(persistentId);

+        assertTrue(bean instanceof Properties);

+        Properties props = (Properties) bean;

+        assertFalse(config.equals(bean));

+        // the local property has been replaced

+        assertEquals("foo", props.getProperty("foo"));

+        // but the one not present on the CM are still present

+        assertTrue(props.containsKey("kry"));

+        assertTrue(props.containsKey("Spring"));

+        assertEquals(3, props.entrySet().size());

+    }

 

-		config.put("foo", "foo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(persistentId);

-		assertTrue(bean instanceof Properties);

-		Properties props = (Properties) bean;

-		assertFalse(config.equals(bean));

-		// the local property is still present

-		assertEquals("bar", props.getProperty("foo"));

-		// the CM props are still there

-		assertTrue(props.containsKey("kry"));

-		// and so are the local props

-		assertTrue(props.containsKey("Spring"));

-		assertEquals(3, props.entrySet().size());

-	}

+    public void testPropertiesWithDefaultsAndOverride() throws Exception {

+        persistentId = "localOverride";

 

-	// disabled until custom attributes are enabled again

-	public void tstPropertiesWithPropRef() throws Exception {

-		persistentId = "custom-attributes";

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+        config.put("foo", "foo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(persistentId);

+        assertTrue(bean instanceof Properties);

+        Properties props = (Properties) bean;

+        assertFalse(config.equals(bean));

+        // the local property is still present

+        assertEquals("bar", props.getProperty("foo"));

+        // the CM props are still there

+        assertTrue(props.containsKey("kry"));

+        // and so are the local props

+        assertTrue(props.containsKey("Spring"));

+        assertEquals(3, props.entrySet().size());

+    }

 

-		config.put("foo", "foo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(persistentId);

-		BeanDefinition bd = appContext.getBeanDefinition(persistentId);

-		System.out.println(bd.getScope());

-		assertTrue(bean instanceof Properties);

-		Properties props = (Properties) bean;

-		assertFalse(config.equals(bean));

-		// the local property is still present

-		assertEquals("bar", props.getProperty("foo"));

-		// the CM props are still there

-		assertTrue(props.containsKey("kry"));

-		// and so are the local props

-		assertTrue(props.containsKey("Spring"));

-		assertEquals(3, props.entrySet().size());

-	}

+    // disabled until custom attributes are enabled again

+    public void tstPropertiesWithPropRef() throws Exception {

+        persistentId = "custom-attributes";

 

-	public void testDynamicNoOverride() throws Exception {

-		persistentId = "noLocalOverride";

-		String beanId = "dynamic-noOverride";

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+        config.put("foo", "foo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(persistentId);

+        BeanDefinition bd = appContext.getBeanDefinition(persistentId);

+        System.out.println(bd.getScope());

+        assertTrue(bean instanceof Properties);

+        Properties props = (Properties) bean;

+        assertFalse(config.equals(bean));

+        // the local property is still present

+        assertEquals("bar", props.getProperty("foo"));

+        // the CM props are still there

+        assertTrue(props.containsKey("kry"));

+        // and so are the local props

+        assertTrue(props.containsKey("Spring"));

+        assertEquals(3, props.entrySet().size());

+    }

 

-		// initial config

-		config.put("bo", "bozo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(beanId);

-		assertTrue(bean instanceof Properties);

-		Properties props = (Properties) bean;

-		assertFalse(config.equals(bean));

-		// the local property has been replaced

-		assertEquals("bozo", props.getProperty("bo"));

-		// but the one not present on the CM are still present

-		assertTrue(props.containsKey("kry"));

-		assertEquals("pton", props.getProperty("kry"));

-		assertEquals("Source", props.getProperty("Spring"));

-		assertEquals(3, props.entrySet().size());

+    public void testDynamicNoOverride() throws Exception {

+        persistentId = "noLocalOverride";

+        String beanId = "dynamic-noOverride";

 

-		// CM updates

-		assertNotNull(msCallback);

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-		Dictionary<String, String> newProps = new Hashtable<String, String>();

-		newProps.put("bo", "b0z0");

-		newProps.put("new", "prop");

-		// trigger update

-		msCallback.updated(newProps);

+        // initial config

+        config.put("bo", "bozo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(beanId);

+        assertTrue(bean instanceof Properties);

+        Properties props = (Properties) bean;

+        assertFalse(config.equals(bean));

+        // the local property has been replaced

+        assertEquals("bozo", props.getProperty("bo"));

+        // but the one not present on the CM are still present

+        assertTrue(props.containsKey("kry"));

+        assertEquals("pton", props.getProperty("kry"));

+        assertEquals("Source", props.getProperty("Spring"));

+        assertEquals(3, props.entrySet().size());

 

-		// verify properties

-		assertSame(props, appContext.getBean(beanId));

-		assertEquals("b0z0", props.getProperty("bo"));

-		assertEquals("prop", props.getProperty("new"));

-		assertNull(props.getProperty("Spring"));

-		// verify local properties

-		assertEquals("pton", props.getProperty("kry"));

-	}

+        // CM updates

+        assertNotNull(msCallback);

 

-	public void testDynamicOverride() throws Exception {

-		persistentId = "localOverride";

-		String beanId = "dynamic-override";

+        Dictionary<String, String> newProps = new Hashtable<String, String>();

+        newProps.put("bo", "b0z0");

+        newProps.put("new", "prop");

+        // trigger update

+        msCallback.updated(newProps);

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+        // verify properties

+        assertSame(props, appContext.getBean(beanId));

+        assertEquals("b0z0", props.getProperty("bo"));

+        assertEquals("prop", props.getProperty("new"));

+        assertNull(props.getProperty("Spring"));

+        // verify local properties

+        assertEquals("pton", props.getProperty("kry"));

+    }

 

-		// initial config

-		config.put("bo", "bozo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(beanId);

-		assertTrue(bean instanceof Properties);

-		Properties props = (Properties) bean;

-		assertFalse(config.equals(bean));

-		// the local property has been replaced

-		assertEquals("zo", props.getProperty("bo"));

-		// but the one not present on the CM are still present

-		assertEquals("pton", props.getProperty("kry"));

-		assertEquals("Source", props.getProperty("Spring"));

-		assertEquals(3, props.entrySet().size());

+    public void testDynamicOverride() throws Exception {

+        persistentId = "localOverride";

+        String beanId = "dynamic-override";

 

-		// CM updates

-		assertNotNull(msCallback);

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-		Dictionary<String, String> newProps = new Hashtable<String, String>();

-		newProps.put("bo", "b0z0");

-		newProps.put("new", "prop");

-		// trigger update

-		msCallback.updated(newProps);

+        // initial config

+        config.put("bo", "bozo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(beanId);

+        assertTrue(bean instanceof Properties);

+        Properties props = (Properties) bean;

+        assertFalse(config.equals(bean));

+        // the local property has been replaced

+        assertEquals("zo", props.getProperty("bo"));

+        // but the one not present on the CM are still present

+        assertEquals("pton", props.getProperty("kry"));

+        assertEquals("Source", props.getProperty("Spring"));

+        assertEquals(3, props.entrySet().size());

 

-		// verify properties

-		assertSame(props, appContext.getBean(beanId));

-		assertEquals("zo", props.getProperty("bo"));

-		assertEquals("prop", props.getProperty("new"));

-		assertNull(props.getProperty("Spring"));

-		// verify local properties

-		assertEquals("pton", props.getProperty("kry"));

-	}

+        // CM updates

+        assertNotNull(msCallback);

 

-	public void testExtendedProperties() throws Exception {

-		persistentId = "noLocalOverride";

-		String beanId = "dynamic-noOverride";

+        Dictionary<String, String> newProps = new Hashtable<String, String>();

+        newProps.put("bo", "b0z0");

+        newProps.put("new", "prop");

+        // trigger update

+        msCallback.updated(newProps);

 

-		adminControl.reset();

-		adminControl.expectAndReturn(admin.getConfiguration(persistentId), cfg, MockControl.ONE_OR_MORE);

-		adminControl.replay();

+        // verify properties

+        assertSame(props, appContext.getBean(beanId));

+        assertEquals("zo", props.getProperty("bo"));

+        assertEquals("prop", props.getProperty("new"));

+        assertNull(props.getProperty("Spring"));

+        // verify local properties

+        assertEquals("pton", props.getProperty("kry"));

+    }

 

-		// initial config

-		config.put("bo", "bozo");

-		config.put("Spring", "Source");

-		Object bean = appContext.getBean(beanId);

-		assertTrue(bean instanceof Properties);

-		assertTrue(bean instanceof ServicePropertiesListenerManager);

-		Properties props = (Properties) bean;

-		ServicePropertiesListenerManager manager = (ServicePropertiesListenerManager) bean;

+    public void testExtendedProperties() throws Exception {

+        persistentId = "noLocalOverride";

+        String beanId = "dynamic-noOverride";

 

-		final Map<?, ?>[] updatedProps = new Map<?, ?>[1];

-		manager.addListener(new ServicePropertiesChangeListener() {

+        adminControl.reset();

+        expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();

+        adminControl.replay();

 

-			public void propertiesChange(ServicePropertiesChangeEvent event) {

-				updatedProps[0] = event.getServiceProperties();

-			}

-		});

+        // initial config

+        config.put("bo", "bozo");

+        config.put("Spring", "Source");

+        Object bean = appContext.getBean(beanId);

+        assertTrue(bean instanceof Properties);

+        assertTrue(bean instanceof ServicePropertiesListenerManager);

+        Properties props = (Properties) bean;

+        ServicePropertiesListenerManager manager = (ServicePropertiesListenerManager) bean;

 

-		// CM updates

-		assertNotNull(msCallback);

+        final Map<?, ?>[] updatedProps = new Map<?, ?>[1];

+        manager.addListener(new ServicePropertiesChangeListener() {

 

-		Dictionary<String, String> newProps = new Hashtable<String, String>();

-		newProps.put("bo", "b0z0");

-		newProps.put("new", "prop");

-		// trigger update

-		msCallback.updated(newProps);

+            public void propertiesChange(ServicePropertiesChangeEvent event) {

+                updatedProps[0] = event.getServiceProperties();

+            }

+        });

 

-		// verify listener properties

-		assertNotNull(updatedProps[0]);

-		// the properties contains both the CM props

-		assertEquals("b0z0", updatedProps[0].get("bo"));

-		assertEquals("prop", updatedProps[0].get("new"));

-		// and the local defined ones

-		assertEquals("pton", updatedProps[0].get("kry"));

-		assertEquals(3, updatedProps[0].size());

-	}

+        // CM updates

+        assertNotNull(msCallback);

+

+        Dictionary<String, String> newProps = new Hashtable<String, String>();

+        newProps.put("bo", "b0z0");

+        newProps.put("new", "prop");

+        // trigger update

+        msCallback.updated(newProps);

+

+        // verify listener properties

+        assertNotNull(updatedProps[0]);

+        // the properties contains both the CM props

+        assertEquals("b0z0", updatedProps[0].get("bo"));

+        assertEquals("prop", updatedProps[0].get("new"));

+        // and the local defined ones

+        assertEquals("pton", updatedProps[0].get("kry"));

+        assertEquals(3, updatedProps[0].size());

+    }

 }
\ No newline at end of file
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedPropertiesTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedPropertiesTest.java
index 21fbd2d..db193b3 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedPropertiesTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedPropertiesTest.java
@@ -20,7 +20,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.TestUtils;

 import org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedServiceInstanceTrackerPostProcessor;

 import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;

@@ -47,10 +47,9 @@
 

 	protected void setUp() throws Exception {

 

-		MockControl mc = MockControl.createNiceControl(Configuration.class);

-		final Configuration cfg = (Configuration) mc.getMock();

-		mc.expectAndReturn(cfg.getProperties(), new Properties());

-		mc.replay();

+		final Configuration cfg = createNiceMock(Configuration.class);

+        expect(cfg.getProperties()).andReturn(new Properties());

+        replay(cfg);

 

 		registrationCounter = 0;

 		unregistrationCounter = 0;

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedServiceFactoryTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedServiceFactoryTest.java
index bd3ea4b..41dce0e 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedServiceFactoryTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/config/ManagedServiceFactoryTest.java
@@ -22,7 +22,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.TestUtils;

 import org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedServiceFactoryFactoryBean;

 import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;

@@ -47,10 +47,10 @@
 

 	protected void setUp() throws Exception {

 

-		MockControl mc = MockControl.createNiceControl(Configuration.class);

-		final Configuration cfg = (Configuration) mc.getMock();

-		mc.expectAndReturn(cfg.getProperties(), new Properties());

-		mc.replay();

+

+		final Configuration cfg = createMock(Configuration.class);

+		expect(cfg.getProperties()).andReturn(new Properties());

+		replay(cfg);

 

 		BundleContext bundleContext = new MockBundleContext() {

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/internal/cm/ConfigurationAdminManagerTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/internal/cm/ConfigurationAdminManagerTest.java
index b06efc3..7dc69a3 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/compendium/internal/cm/ConfigurationAdminManagerTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/compendium/internal/cm/ConfigurationAdminManagerTest.java
@@ -24,7 +24,9 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

+

+import org.easymock.IMocksControl;

 import org.eclipse.gemini.blueprint.compendium.config.MockConfigurationAdmin;

 import org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedServiceBeanManager;

 import org.osgi.framework.Constants;

@@ -46,9 +48,9 @@
 

 	protected void setUp() throws Exception {

 		services = new LinkedHashMap();

-		MockControl mc = MockControl.createNiceControl(Configuration.class);

-		cfg = (Configuration) mc.getMock();

-		mc.expectAndReturn(cfg.getProperties(), new Properties());

+		IMocksControl mc = createNiceControl();

+		cfg = mc.createMock(Configuration.class);

+		expect(cfg.getProperties()).andReturn(new Properties());

 		mc.replay();

 		bundleContext = new MockBundleContext() {

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/config/BundleFactoryBeanParserTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/config/BundleFactoryBeanParserTest.java
index 3f5c15b..accbc73 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/config/BundleFactoryBeanParserTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/config/BundleFactoryBeanParserTest.java
@@ -20,7 +20,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.TestUtils;

 import org.eclipse.gemini.blueprint.bundle.BundleActionEnum;

 import org.eclipse.gemini.blueprint.bundle.BundleFactoryBean;

@@ -46,8 +46,6 @@
 

 	private Bundle startBundle, installBundle, updateBundle, bundleA;

 

-	private MockControl installBundleMC, startBundleMC, updateBundleMC;

-

 	private static List INSTALL_BUNDLE_ACTION;

 

 	private Bundle[] bundleToInstall = new Bundle[1];

@@ -57,17 +55,15 @@
 	protected void setUp() throws Exception {

 		INSTALL_BUNDLE_ACTION = new ArrayList();

 

-		installBundleMC = MockControl.createControl(Bundle.class);

-		installBundle = (Bundle) installBundleMC.getMock();

-		installBundleMC.expectAndReturn(installBundle.getSymbolicName(), "installBundle", MockControl.ZERO_OR_MORE);

+		installBundle = createMock("installBundle", Bundle.class);

+		expect(installBundle.getSymbolicName()).andReturn("installBundle").anyTimes();

 

-		updateBundleMC = MockControl.createControl(Bundle.class);

-		updateBundle = (Bundle) updateBundleMC.getMock();

-		updateBundleMC.expectAndReturn(updateBundle.getSymbolicName(), "updateBundle", MockControl.ONE_OR_MORE);

+		updateBundle = createMock("updateBundle", Bundle.class);

+		expect(updateBundle.getSymbolicName()).andReturn("updateBundle").atLeastOnce();

 

-		startBundleMC = MockControl.createControl(Bundle.class);

-		startBundle = (Bundle) startBundleMC.getMock();

-		startBundleMC.expectAndReturn(startBundle.getSymbolicName(), "startBundle", MockControl.ONE_OR_MORE);

+		startBundle = createMock("startBundle", Bundle.class);

+        expect(startBundle.getSymbolicName()).andReturn("startBundle").atLeastOnce();

+

 

 		bundleA = new MockBundle("bundleA");

 

@@ -106,9 +102,7 @@
 	}

 

 	private void refresh() {

-		installBundleMC.replay();

-		startBundleMC.replay();

-		updateBundleMC.replay();

+		replay(installBundle, startBundle, updateBundle);

 

 		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);

 		reader.loadBeanDefinitions(new ClassPathResource("bundleBeanFactoryTest.xml", getClass()));

@@ -118,7 +112,7 @@
 

 	public void testWithSymName() throws Exception {

 		refresh();

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&wSymName", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&wSymName", BundleFactoryBean.class);

 		assertSame(bundleA, fb.getObject());

 		assertNull(fb.getLocation());

 		assertNull(fb.getResource());

@@ -127,7 +121,7 @@
 

 	public void testLocationAndResource() throws Exception {

 		refresh();

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&wLocation", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&wLocation", BundleFactoryBean.class);

 		assertEquals("fromServer", fb.getLocation());

 		assertNull(fb.getSymbolicName());

 		assertNotNull(fb.getResource());

@@ -139,14 +133,14 @@
 

 		refresh();

 

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&start", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&start", BundleFactoryBean.class);

 

 		BundleActionEnum action = getAction(fb);

 		assertSame(BundleActionEnum.START, action);

 		assertNull(getDestroyAction(fb));

 

 		assertSame(startBundle, appContext.getBean("start"));

-		startBundleMC.verify();

+		verify(startBundle);

 	}

 

 	public void testStopBundle() throws Exception {

@@ -157,13 +151,13 @@
 

 		refresh();

 

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&stop", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&stop", BundleFactoryBean.class);

 		assertSame(BundleActionEnum.STOP, getDestroyAction(fb));

 

 		assertSame(startBundle, appContext.getBean("stop"));

 

 		appContext.close();

-		startBundleMC.verify();

+		verify(startBundle);

 	}

 

 	public void testUpdateBundle() throws Exception {

@@ -173,7 +167,7 @@
 		updateBundle.stop();

 		refresh();

 

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&update", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&update", BundleFactoryBean.class);

 

 		BundleActionEnum action = getAction(fb);

 		assertSame(BundleActionEnum.UPDATE, action);

@@ -181,7 +175,7 @@
 

 		assertSame(updateBundle, appContext.getBean("update"));

 		appContext.close();

-		updateBundleMC.verify();

+		verify(updateBundle);

 	}

 

 	public void testInstall() throws Exception {

@@ -192,14 +186,14 @@
 

 		refresh();

 

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&install", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&install", BundleFactoryBean.class);

 		assertEquals("fromClient", fb.getLocation());

 		assertEquals(1, INSTALL_BUNDLE_ACTION.size());

 		assertEquals("fromClient", INSTALL_BUNDLE_ACTION.get(0));

 

 		assertSame(installBundle, appContext.getBean("install"));

 		appContext.close();

-		installBundleMC.verify();

+		verify(installBundle);

 	}

 

 	public void testInstallImpliedByUpdateUsingRealLocation() throws Exception {

@@ -211,7 +205,7 @@
 		refresh();

 

 		BundleFactoryBean fb =

-				(BundleFactoryBean) appContext.getBean("&updateFromActualLocation", BundleFactoryBean.class);

+                appContext.getBean("&updateFromActualLocation", BundleFactoryBean.class);

 		assertEquals(1, INSTALL_BUNDLE_ACTION.size());

 

 		assertSame(BundleActionEnum.UPDATE, getAction(fb));

@@ -221,22 +215,23 @@
 

 		assertSame(installBundle, appContext.getBean("updateFromActualLocation"));

 		appContext.close();

-		installBundleMC.verify();

+		verify(installBundle);

 	}

 

 	public void testNestedBundleDeclaration() throws Exception {

-		MockControl ctrl = MockControl.createControl(Bundle.class);

-		Bundle bnd = (Bundle) ctrl.getMock();

+		Bundle bnd = createMock(Bundle.class);

 

 		bnd.start();

-		ctrl.replay();

+

+        replay(bnd);

+

 		appContext.getBeanFactory().registerSingleton("createdByTheTest", bnd);

 		refresh();

 

 		appContext.getBean("nested");

-		BundleFactoryBean fb = (BundleFactoryBean) appContext.getBean("&nested", BundleFactoryBean.class);

+		BundleFactoryBean fb = appContext.getBean("&nested", BundleFactoryBean.class);

 

-		ctrl.verify();

+		verify(bnd);

 	}

 

 	private BundleActionEnum getAction(BundleFactoryBean fb) {

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceLifecycleListenerAdapterTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceLifecycleListenerAdapterTest.java
index da99088..c4b2c10 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceLifecycleListenerAdapterTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceLifecycleListenerAdapterTest.java
@@ -24,7 +24,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceLifecycleListenerAdapter;

 import org.eclipse.gemini.blueprint.service.importer.ImportedOsgiServiceProxy;

 import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener;

@@ -623,13 +623,12 @@
 	}

 

 	private ConfigurableBeanFactory createMockBF(Object target) {

-		MockControl ctrl = MockControl.createNiceControl(ConfigurableBeanFactory.class);

-		ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) ctrl.getMock();

+		ConfigurableBeanFactory cbf = createNiceMock(ConfigurableBeanFactory.class);

 

-		ctrl.expectAndReturn(cbf.getBean(BEAN_NAME), target);

-		ctrl.expectAndReturn(cbf.getType(BEAN_NAME), target.getClass());

+		expect(cbf.getBean(BEAN_NAME)).andReturn(target);

+		expect(cbf.getType(BEAN_NAME)).andReturn((Class)target.getClass());

 

-		ctrl.replay();

+		replay(cbf);

 		return cbf;

 	}

 }

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceRegistrationListenerAdapterTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceRegistrationListenerAdapterTest.java
index 185542d..61d04d2 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceRegistrationListenerAdapterTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/config/internal/OsgiServiceRegistrationListenerAdapterTest.java
@@ -23,7 +23,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.config.internal.adapter.OsgiServiceRegistrationListenerAdapter;

 import org.eclipse.gemini.blueprint.service.exporter.OsgiServiceRegistrationListener;

 import org.eclipse.gemini.blueprint.util.internal.MapBasedDictionary;

@@ -527,13 +527,12 @@
 	}

 

 	private BeanFactory createMockBF() {

-		MockControl ctrl = MockControl.createNiceControl(BeanFactory.class);

-		BeanFactory cbf = (BeanFactory) ctrl.getMock();

+        BeanFactory cbf = createNiceMock(BeanFactory.class);

 

 		// ctrl.expectAndReturn(cbf.getBean(BEAN_NAME), target);

 		// ctrl.expectAndReturn(cbf.getType(BEAN_NAME), target.getClass());

 

-		ctrl.replay();

+		replay(cbf);

 		return cbf;

 	}

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractBundleXmlApplicationContextTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractBundleXmlApplicationContextTest.java
index 3833afd..399fe11 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractBundleXmlApplicationContextTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractBundleXmlApplicationContextTest.java
@@ -19,8 +19,9 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext;

+import static org.easymock.EasyMock.*;

+import org.easymock.IMocksControl;

+

 import org.eclipse.gemini.blueprint.util.OsgiStringUtils;

 import org.osgi.framework.Bundle;

 import org.osgi.framework.BundleContext;

@@ -35,7 +36,7 @@
 

 	OsgiBundleXmlApplicationContext xmlContext;

 

-	MockControl bundleCtxCtrl, bundleCtrl;

+	IMocksControl bundleCtxCtrl, bundleCtrl;

 

 	BundleContext context;

 

@@ -44,17 +45,17 @@
 	Dictionary dictionary;

 

 	protected void setUp() throws Exception {

-		bundleCtxCtrl = MockControl.createNiceControl(BundleContext.class);

-		context = (BundleContext) bundleCtxCtrl.getMock();

-		bundleCtrl = MockControl.createNiceControl(Bundle.class);

-		bundle = (Bundle) bundleCtrl.getMock();

+		bundleCtxCtrl = createNiceControl();

+		context = bundleCtxCtrl.createMock(BundleContext.class);

+		bundleCtrl = createNiceControl();

+		bundle = bundleCtrl.createMock(Bundle.class);

 

-		bundleCtxCtrl.expectAndReturn(context.getBundle(), bundle, MockControl.ONE_OR_MORE);

+        expect(context.getBundle()).andReturn(bundle).atLeastOnce();

 

 		dictionary = new Hashtable();

 

 		// allow headers to be taken multiple times

-		bundleCtrl.expectAndReturn(bundle.getHeaders(), dictionary, MockControl.ONE_OR_MORE);

+        expect(bundle.getHeaders()).andReturn(dictionary).atLeastOnce();

 	}

 

 	private void createContext() {

@@ -67,8 +68,6 @@
     }

 

 	protected void tearDown() throws Exception {

-		// bundleCtxCtrl.verify();

-		// bundleCtrl.verify();

 		context = null;

 		bundleCtxCtrl = null;

 		xmlContext = null;

@@ -78,8 +77,7 @@
 

 	public void testGetBundleName() {

 		String symbolicName = "symbolic";

-		// bundleCtrl.reset();

-		bundleCtrl.expectAndReturn(bundle.getSymbolicName(), symbolicName, MockControl.ONE_OR_MORE);

+        expect(bundle.getSymbolicName()).andReturn(symbolicName).atLeastOnce();

 		bundleCtxCtrl.replay();

 		bundleCtrl.replay();

 

@@ -105,8 +103,7 @@
 

 	public void testGetServiceName() {

 		String symbolicName = "symbolic";

-		// bundleCtrl.reset();

-		bundleCtrl.expectAndReturn(bundle.getSymbolicName(), symbolicName, MockControl.ONE_OR_MORE);

+        expect(bundle.getSymbolicName()).andReturn(symbolicName).atLeastOnce();

 		bundleCtxCtrl.replay();

 		bundleCtrl.replay();

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractRefreshableOsgiBundleApplicationContextTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractRefreshableOsgiBundleApplicationContextTest.java
index 19bab55..209eab0 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractRefreshableOsgiBundleApplicationContextTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/AbstractRefreshableOsgiBundleApplicationContextTest.java
@@ -7,7 +7,7 @@
  * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

  * is available at http://www.opensource.org/licenses/apache2.0.php.

  * You may elect to redistribute this code under either of these licenses. 

- * 

+ *

  * Contributors:

  *   VMware Inc.

  *****************************************************************************/

@@ -20,107 +20,108 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext;

-import org.eclipse.gemini.blueprint.io.OsgiBundleResource;

-import org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader;

+import static org.easymock.EasyMock.*;

+

+import org.easymock.IMocksControl;

+

+import org.eclipse.gemini.blueprint.mock.MockBundleContext;

+import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;

 import org.osgi.framework.Bundle;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.ServiceRegistration;

-import org.springframework.beans.BeansException;

-import org.springframework.beans.factory.support.DefaultListableBeanFactory;

-import org.springframework.core.io.Resource;

+

+import org.eclipse.gemini.blueprint.io.OsgiBundleResource;

+import org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader;

 import org.eclipse.gemini.blueprint.mock.MockBundleContext;

 import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;

 

+import org.springframework.beans.BeansException;

+import org.springframework.beans.factory.support.DefaultListableBeanFactory;

+import org.springframework.core.io.Resource;

+

 /**

  * @author Costin Leau

- * 

  */

 public class AbstractRefreshableOsgiBundleApplicationContextTest extends TestCase {

 

-	private AbstractOsgiBundleApplicationContext context;

-	private Bundle bundle;

-	private BundleContext bundleCtx;

-	private MockControl bundleCtrl, bundleCtxCtrl;

+    private AbstractOsgiBundleApplicationContext context;

+    private IMocksControl mocksControl;

+    private Bundle bundle;

+    private BundleContext bundleCtx;

 

+    protected void setUp() throws Exception {

+        context = new AbstractOsgiBundleApplicationContext() {

 

-	protected void setUp() throws Exception {

-		context = new AbstractOsgiBundleApplicationContext() {

+            protected void loadBeanDefinitions(DefaultListableBeanFactory arg0) throws IOException, BeansException {

+            }

+        };

 

-			protected void loadBeanDefinitions(DefaultListableBeanFactory arg0) throws IOException, BeansException {

-			}

-		};

+        mocksControl = createStrictControl();

 

-		bundleCtxCtrl = MockControl.createStrictControl(BundleContext.class);

-		bundleCtx = (BundleContext) bundleCtxCtrl.getMock();

+        bundleCtx = mocksControl.createMock(BundleContext.class);

+        bundle = createNiceMock(Bundle.class);

+        expect(bundleCtx.getBundle()).andReturn(bundle);

+    }

 

-		bundleCtrl = MockControl.createNiceControl(Bundle.class);

-		bundle = (Bundle) bundleCtrl.getMock();

+    protected void tearDown() throws Exception {

+        context = null;

+    }

 

-		bundleCtxCtrl.expectAndReturn(bundleCtx.getBundle(), bundle);

+    public void testBundleContext() throws Exception {

 

-	}

+        String location = "osgibundle://someLocation";

+        Resource bundleResource = new OsgiBundleResource(bundle, location);

 

-	protected void tearDown() throws Exception {

-		context = null;

-	}

+        Dictionary dict = new Properties();

 

-	public void testBundleContext() throws Exception {

+        expect(bundle.getHeaders()).andReturn(dict);

+        expect(bundle.getSymbolicName()).andReturn("symName").atLeastOnce();

 

-		String location = "osgibundle://someLocation";

-		Resource bundleResource = new OsgiBundleResource(bundle, location);

+        replay(bundle, bundleCtx);

 

-		Dictionary dict = new Properties();

-		bundleCtrl.expectAndReturn(bundle.getHeaders(), dict);

-		bundleCtrl.expectAndReturn(bundle.getSymbolicName(), "symName", MockControl.ONE_OR_MORE);

-		bundleCtrl.replay();

-		bundleCtxCtrl.replay();

+        context.setBundleContext(bundleCtx);

+        assertSame(bundle, context.getBundle());

+        assertSame(bundleCtx, context.getBundleContext());

 

-		context.setBundleContext(bundleCtx);

-		assertSame(bundle, context.getBundle());

-		assertSame(bundleCtx, context.getBundleContext());

+        ClassLoader loader = context.getClassLoader();

+        assertTrue(loader instanceof BundleDelegatingClassLoader);

 

-		ClassLoader loader = context.getClassLoader();

-		assertTrue(loader instanceof BundleDelegatingClassLoader);

+        // do some resource loading

+        assertEquals(bundleResource, context.getResource(location));

 

-		// do some resource loading

-		assertEquals(bundleResource, context.getResource(location));

+        verify(bundle, bundleCtx);

+    }

 

-		bundleCtrl.verify();

-		bundleCtxCtrl.verify();

-	}

+    public void testServicePublicationBetweenRefreshes() throws Exception {

+        // [0] = service registration

+        // [1] = service unregistration

 

-	public void testServicePublicationBetweenRefreshes() throws Exception {

-		// [0] = service registration

-		// [1] = service unregistration

-		

-		final int[] counters = new int[] { 0, 0 };

+        final int[] counters = new int[]{0, 0};

 

-		MockBundleContext mCtx = new MockBundleContext() {

+        MockBundleContext mCtx = new MockBundleContext() {

 

-			public ServiceRegistration registerService(String clazz[], Object service, Dictionary properties) {

-				counters[0]++;

-				return new MockServiceRegistration(clazz, properties) {

+            public ServiceRegistration registerService(String clazz[], Object service, Dictionary properties) {

+                counters[0]++;

+                return new MockServiceRegistration(clazz, properties) {

 

-					public void unregister() {

-						counters[1]++;

-					}

-				};

-			}

+                    public void unregister() {

+                        counters[1]++;

+                    }

+                };

+            }

 

-		};

-		context.setBundleContext(mCtx);

+        };

+        context.setBundleContext(mCtx);

 

-		assertEquals(counters[0], 0);

-		assertEquals(counters[1], 0);

+        assertEquals(counters[0], 0);

+        assertEquals(counters[1], 0);

 

-		context.refresh();

-		assertEquals(counters[0], 1);

-		assertEquals(counters[1], 0);

+        context.refresh();

+        assertEquals(counters[0], 1);

+        assertEquals(counters[1], 0);

 

-		context.refresh();

-		assertEquals(counters[0], 2);

-		assertEquals(counters[1], 1);

-	}

+        context.refresh();

+        assertEquals(counters[0], 2);

+        assertEquals(counters[1], 1);

+    }

 }
\ No newline at end of file
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/BundleContextAwareProcessorTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/BundleContextAwareProcessorTest.java
index 2676975..b74402f 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/context/support/BundleContextAwareProcessorTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/context/support/BundleContextAwareProcessorTest.java
@@ -1,25 +1,26 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

+/******************************************************************************
+ * Copyright (c) 2006, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution. 
+ * The Eclipse Public License is available at 
+ * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ * is available at http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses. 
+ * 
+ * Contributors:
+ *   VMware Inc.
+ *****************************************************************************/
+
 package org.eclipse.gemini.blueprint.context.support;
 
-import junit.framework.TestCase;

-

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.context.BundleContextAware;

-import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;

-import org.osgi.framework.BundleContext;

+import junit.framework.TestCase;
+
+import static org.easymock.EasyMock.*;
+
+import org.eclipse.gemini.blueprint.context.BundleContextAware;
+import org.eclipse.gemini.blueprint.context.support.BundleContextAwareProcessor;
+import org.osgi.framework.BundleContext;
 
 /**
  * 
@@ -28,38 +29,36 @@
  */
 public abstract class BundleContextAwareProcessorTest extends TestCase{
 
-	private MockControl bundleContextControl;
-	private MockControl bundleContextAwareControl;
+    // TODO: is this test still applicable?  Does not look like it is testing anything.
+
 	private BundleContext mockContext;
 	private BundleContextAware mockAware;
 	
 	protected void setUp() throws Exception {
-		this.bundleContextControl = MockControl.createControl(BundleContext.class);
-		this.mockContext = (BundleContext) this.bundleContextControl.getMock();
+		this.mockContext = createMock(BundleContext.class);
 		// no tests should ever call the mockContext, we're really
 		// using it just as a convenient implementation
-		this.bundleContextControl.replay();
-		
-		this.bundleContextAwareControl = MockControl.createControl(BundleContextAware.class);
-		this.mockAware = (BundleContextAware) this.bundleContextAwareControl.getMock();
+		replay(mockContext);
+
+		this.mockAware = createMock(BundleContextAware.class);
 	}
 	
 	protected void tearDown() throws Exception {
-		this.bundleContextControl.verify();
+		verify(mockContext);
 	}
 	
 	public void testBeforeInitializationNoBundleContext() {
 		BundleContextAwareProcessor bcaProcessor = new BundleContextAwareProcessor(null);
-		this.bundleContextAwareControl.replay();
+		replay(mockAware);
 		try {
-			//bcaProcessor.postProcessAfterInstantiation(this.mockAware, "aName");
+//			bcaProcessor.postProcessAfterInstantiation(this.mockAware, "aName");
 			fail("should throw an IllegalStateException when no BundleContext available");
 		} 
 		catch(IllegalStateException ex) {
 			assertEquals("Cannot satisfy BundleContextAware for bean 'aName' without BundleContext",
 					     ex.getMessage());
 		}
-		this.bundleContextAwareControl.verify();
+		verify(mockAware);
 	}
 	
 	public void testBeforeInitializationNonImplementer() {
@@ -72,9 +71,9 @@
 	public void testBeforeInitializationBundleContextImplementer() {
 		BundleContextAwareProcessor bcaProcessor = new BundleContextAwareProcessor(this.mockContext);
 		this.mockAware.setBundleContext(this.mockContext);
-		this.bundleContextAwareControl.replay();
+		replay(mockAware);
 		//boolean ret = bcaProcessor.postProcessAfterInstantiation(this.mockAware, "aName");
-		this.bundleContextAwareControl.verify();
+		verify(mockAware);
 		//assertTrue("should return true",ret);
 	}
 	
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
index 9b513f1..f38615f 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceReferenceUtilsTest.java
@@ -20,7 +20,9 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

+

+import org.easymock.IMocksControl;

 import org.eclipse.gemini.blueprint.util.OsgiFilterUtils;

 import org.eclipse.gemini.blueprint.util.OsgiServiceReferenceUtils;

 import org.osgi.framework.BundleContext;

@@ -42,7 +44,7 @@
 

 	private ServiceReference ref1, ref2, ref3;

 

-	MockControl ctrl;

+	IMocksControl ctrl;

 

 	/*

 	 * (non-Javadoc)

@@ -53,23 +55,23 @@
 

 		// lowest service reference

 		Dictionary dict1 = new Hashtable();

-		dict1.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));

+		dict1.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);

 		ref1 = new MockServiceReference(null, dict1, null);

 

 		// neutral service reference

 		Dictionary dict2 = new Hashtable();

-		dict2.put(Constants.SERVICE_ID, new Long(20));

+		dict2.put(Constants.SERVICE_ID, (long) 20);

 

 		ref2 = new MockServiceReference(null, dict2, null);

 

 		// neutral service reference

 		Dictionary dict3 = new Hashtable();

-		dict3.put(Constants.SERVICE_ID, new Long(30));

+		dict3.put(Constants.SERVICE_ID, (long) 30);

 

 		ref3 = new MockServiceReference(null, dict3, null);

 

-		ctrl = MockControl.createStrictControl(BundleContext.class);

-		context = (BundleContext) ctrl.getMock();

+		ctrl = createStrictControl();

+		context = ctrl.createMock(BundleContext.class);

 

 	}

 

@@ -87,7 +89,7 @@
 	 */

 	public void testServiceSortingAlgorithm() throws Exception {

 		String filter = OsgiFilterUtils.unifyFilter(classes, null);

-		ctrl.expectAndReturn(context.getServiceReferences(classes[0], filter), new ServiceReference[] { ref1 });

+		expect(context.getServiceReferences(classes[0], filter)).andReturn(new ServiceReference[] { ref1 });

 

 		ctrl.replay();

 		ServiceReference ref = OsgiServiceReferenceUtils.getServiceReference(context, classes, null);

@@ -101,8 +103,7 @@
 	 */

 	public void testGetServiceReferenceBundleContextStringString() throws Exception {

 

-		ctrl.expectAndReturn(context.getServiceReferences(Object.class.getName(), null), new ServiceReference[] { ref1,

-				ref3, ref2 });

+		expect(context.getServiceReferences(Object.class.getName(), null)).andReturn(new ServiceReference[] { ref1, ref3, ref2 });

 

 		ctrl.replay();

 		// ref2 should win since it has the highest ranking and the lowest id

@@ -118,8 +119,7 @@
 	public void testGetServiceReferenceBundleContextStringArrayString() throws Exception {

 		String smallFilter = "(cn=John)";

 		String filter = OsgiFilterUtils.unifyFilter(classes, smallFilter);

-		ctrl.expectAndReturn(context.getServiceReferences(Object.class.getName(), filter),

-				new ServiceReference[] { ref1 });

+		expect(context.getServiceReferences(Object.class.getName(), filter)).andReturn(new ServiceReference[] { ref1 });

 

 		ctrl.replay();

 		ServiceReference ref = OsgiServiceReferenceUtils.getServiceReference(context, classes, smallFilter);

@@ -132,7 +132,7 @@
 	 * {@link org.eclipse.gemini.blueprint.util.OsgiServiceReferenceUtils#getServiceReference(org.osgi.framework.BundleContext, java.lang.String)}.

 	 */

 	public void testAlwaysGetAnArrayOfServiceReferences() throws Exception {

-		ctrl.expectAndReturn(context.getServiceReferences(Object.class.getName(), null), null);

+		expect(context.getServiceReferences(Object.class.getName(), null)).andReturn(null);

 		ctrl.replay();

 		ServiceReference[] refs = OsgiServiceReferenceUtils.getServiceReferences(context, Object.class.getName(), null);

 		assertNotNull(refs);

@@ -147,7 +147,7 @@
 	public void testGetServiceId() {

 		long id = 12345;

 		Dictionary dict = new Hashtable();

-		dict.put(Constants.SERVICE_ID, new Long(id));

+		dict.put(Constants.SERVICE_ID, id);

 		ServiceReference ref = new MockServiceReference(null, dict, null);

 		assertEquals(id, OsgiServiceReferenceUtils.getServiceId(ref));

 	}

@@ -159,7 +159,7 @@
 	public void testGetServiceRankingAvailable() {

 		int ranking = 12345;

 		Dictionary dict = new Hashtable();

-		dict.put(Constants.SERVICE_RANKING, new Integer(ranking));

+		dict.put(Constants.SERVICE_RANKING, ranking);

 		ServiceReference ref = new MockServiceReference(null, dict, null);

 		assertEquals(ranking, OsgiServiceReferenceUtils.getServiceRanking(ref));

 	}

@@ -167,7 +167,7 @@
 	public void testGetServiceRankingWithInvalidClass() {

 		int ranking = 12345;

 		Dictionary dict = new Hashtable();

-		dict.put(Constants.SERVICE_RANKING, new Long(ranking));

+		dict.put(Constants.SERVICE_RANKING, (long) ranking);

 		ServiceReference ref = new MockServiceReference(null, dict, null);

 		assertEquals(0, OsgiServiceReferenceUtils.getServiceRanking(ref));

 	}

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceUtilsTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceUtilsTest.java
index 2a7a3b0..546d335 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceUtilsTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/OsgiServiceUtilsTest.java
@@ -1,30 +1,30 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

+/******************************************************************************
+ * Copyright (c) 2006, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution. 
+ * The Eclipse Public License is available at 
+ * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ * is available at http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses. 
+ * 
+ * Contributors:
+ *   VMware Inc.
+ *****************************************************************************/
+
 package org.eclipse.gemini.blueprint.service;
 
-import java.io.Serializable;

-import java.util.Arrays;

-

-import junit.framework.TestCase;

-

-import org.easymock.MockControl;

-import org.osgi.framework.BundleContext;

-import org.osgi.framework.ServiceReference;

-import org.springframework.aop.framework.ProxyFactory;

-import org.springframework.util.ClassUtils;

-import org.springframework.util.ObjectUtils;

+import java.io.Serializable;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import static org.easymock.EasyMock.*;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.springframework.aop.framework.ProxyFactory;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.ObjectUtils;
 
 /**
  * @author Adrian Colyer
@@ -32,15 +32,11 @@
  * @since 2.0
  */
 public class OsgiServiceUtilsTest extends TestCase {
-
-	private MockControl mockControl;
-
 	private BundleContext bundleContext;
 
 	protected void setUp() throws Exception {
 		super.setUp();
-		this.mockControl = MockControl.createControl(BundleContext.class);
-		this.bundleContext = (BundleContext) this.mockControl.getMock();
+		this.bundleContext = createMock(BundleContext.class);
 	}
 
 //	public void testGetServiceWithBadFilter() throws InvalidSyntaxException {
@@ -140,8 +136,7 @@
 //	}
 
 	private ServiceReference getServiceReference() {
-		MockControl sRefControl = MockControl.createNiceControl(ServiceReference.class);
-		return (ServiceReference) sRefControl.getMock();
+		return createNiceMock(ServiceReference.class);
 	}
 
 	public void testSimpleClassDetermination() throws Exception {
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/BeanNameServicePropertiesResolverTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/BeanNameServicePropertiesResolverTest.java
index bcef7b8..32f7b2b 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/BeanNameServicePropertiesResolverTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/BeanNameServicePropertiesResolverTest.java
@@ -1,30 +1,33 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc., Oracle Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *   Oracle Inc.

- *****************************************************************************/

-

+/******************************************************************************
+ * Copyright (c) 2006, 2010 VMware Inc., Oracle Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution. 
+ * The Eclipse Public License is available at 
+ * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ * is available at http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses. 
+ * 
+ * Contributors:
+ *   VMware Inc.
+ *   Oracle Inc.
+ *****************************************************************************/
+
 package org.eclipse.gemini.blueprint.service.exporter;
 
-import java.util.Map;

-import java.util.Properties;

-

-import junit.framework.TestCase;

-

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.service.exporter.support.BeanNameServicePropertiesResolver;

-import org.osgi.framework.Bundle;

-import org.osgi.framework.BundleContext;

-import org.osgi.framework.Constants;

+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import static org.easymock.EasyMock.*;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+import org.eclipse.gemini.blueprint.service.exporter.support.BeanNameServicePropertiesResolver;
+
 
 /**
  * @author Adrian Colyer
@@ -43,36 +46,30 @@
 	}
 
 	public void testGetServiceProperties() {
-		MockControl bundleContextControl = MockControl.createControl(BundleContext.class);
-		BundleContext mockContext = (BundleContext) bundleContextControl.getMock();
-		MockControl bundleControl = MockControl.createControl(Bundle.class);
-		Bundle mockBundle = (Bundle) bundleControl.getMock();
+        BundleContext mockContext = createMock(BundleContext.class);
+        Bundle mockBundle = createMock(Bundle.class);
 
-		mockContext.getBundle();
-		bundleContextControl.setReturnValue(mockBundle);
-		mockBundle.getSymbolicName();
-		bundleControl.setReturnValue("symbolic-name");
-		mockContext.getBundle();
-		bundleContextControl.setReturnValue(mockBundle);
-		mockBundle.getHeaders();
-		Properties props = new Properties();
-		props.put(Constants.BUNDLE_VERSION, "1.0.0");
-		bundleControl.setReturnValue(props);
+		expect(mockContext.getBundle()).andReturn(mockBundle);
+		expect(mockBundle.getSymbolicName()).andReturn("symbolic-name");
+        expect(mockContext.getBundle()).andReturn(mockBundle);
 
-		bundleContextControl.replay();
-		bundleControl.replay();
+        Properties props = new Properties();
+        props.put(Constants.BUNDLE_VERSION, "1.0.0");
+
+        expect(mockBundle.getHeaders()).andReturn(props);
+
+        replay(mockBundle, mockContext);
 
 		BeanNameServicePropertiesResolver resolver = new BeanNameServicePropertiesResolver();
 		resolver.setBundleContext(mockContext);
 		Map ret = resolver.getServiceProperties("myBean");
 
-		bundleControl.verify();
-		bundleContextControl.verify();
+		verify(mockBundle, mockContext);
 
 		assertEquals("5 properties", 5, ret.size());
 		assertEquals("symbolic-name", ret.get("Bundle-SymbolicName"));
 		assertEquals("1.0.0", ret.get("Bundle-Version"));
-		assertEquals("myBean", ret.get("org.eclipse.gemini.blueprint.bean.name"));

+		assertEquals("myBean", ret.get("org.eclipse.gemini.blueprint.bean.name"));
 		assertEquals("myBean", ret.get("org.springframework.osgi.bean.name"));
 		assertEquals("myBean", ret.get("osgi.service.blueprint.compname"));
 	}
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBeanTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBeanTest.java
index 9b7d401..f909da4 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBeanTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/OsgiServiceFactoryBeanTest.java
@@ -1,520 +1,524 @@
-/******************************************************************************

- * Copyright (c) 2006, 2010 VMware Inc.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * and Apache License v2.0 which accompanies this distribution. 

- * The Eclipse Public License is available at 

- * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0

- * is available at http://www.opensource.org/licenses/apache2.0.php.

- * You may elect to redistribute this code under either of these licenses. 

- * 

- * Contributors:

- *   VMware Inc.

- *****************************************************************************/

-

+/******************************************************************************
+ * Copyright (c) 2006, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution. 
+ * The Eclipse Public License is available at 
+ * http://www.eclipse.org/legal/epl-v10.html and the Apache License v2.0
+ * is available at http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses. 
+ *
+ * Contributors:
+ *   VMware Inc.
+ *****************************************************************************/
+
 package org.eclipse.gemini.blueprint.service.exporter.support;
 
-import java.io.Serializable;

-import java.util.AbstractMap;

-import java.util.ArrayList;

-import java.util.Dictionary;

-import java.util.HashMap;

-import java.util.LinkedHashMap;

-import java.util.List;

-import java.util.Map;

-import java.util.Properties;

-

-import junit.framework.TestCase;

-

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.service.exporter.OsgiServiceRegistrationListener;

-import org.eclipse.gemini.blueprint.service.exporter.TestRegistrationListener;

-import org.eclipse.gemini.blueprint.service.exporter.support.DefaultInterfaceDetector;

-import org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean;

-import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeEvent;

-import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeListener;

-import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesListenerManager;

-import org.osgi.framework.Bundle;

-import org.osgi.framework.BundleContext;

-import org.osgi.framework.ServiceFactory;

-import org.osgi.framework.ServiceRegistration;

-import org.springframework.beans.factory.config.ConfigurableBeanFactory;

-import org.eclipse.gemini.blueprint.mock.MockBundleContext;

-import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;

+import java.io.Serializable;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import static org.easymock.EasyMock.*;
+
+import org.easymock.IMocksControl;
+import org.eclipse.gemini.blueprint.service.exporter.OsgiServiceRegistrationListener;
+import org.eclipse.gemini.blueprint.service.exporter.TestRegistrationListener;
+import org.eclipse.gemini.blueprint.service.exporter.support.DefaultInterfaceDetector;
+import org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean;
+import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeEvent;
+import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesChangeListener;
+import org.eclipse.gemini.blueprint.service.exporter.support.ServicePropertiesListenerManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.eclipse.gemini.blueprint.mock.MockBundleContext;
+import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;
 
 /**
  * @author Costin Leau
  */
 public class OsgiServiceFactoryBeanTest extends TestCase {
 
-	private OsgiServiceFactoryBean exporter;
+    private OsgiServiceFactoryBean exporter;
 
-	private ConfigurableBeanFactory beanFactory;
+    private ConfigurableBeanFactory beanFactory;
 
-	private MockControl beanFactoryControl;
+    private IMocksControl beanFactoryControl;
 
-	private BundleContext bundleContext;
+    private BundleContext bundleContext;
 
-	private MockControl ctxCtrl;
+    private IMocksControl ctxCtrl;
 
-	private BundleContext ctx;
+    private BundleContext ctx;
 
-	class MockServiceFactory implements ServiceFactory {
+    class MockServiceFactory implements ServiceFactory {
 
-		public Object getService(Bundle bundle, ServiceRegistration registration) {
-			return null;
-		}
+        public Object getService(Bundle bundle, ServiceRegistration registration) {
+            return null;
+        }
 
-		public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
-		}
-	}
+        public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+        }
+    }
 
-	class UpdateableProperties extends Properties implements ServicePropertiesListenerManager {
+    class UpdateableProperties extends Properties implements ServicePropertiesListenerManager {
 
-		public List<ServicePropertiesChangeListener> listeners = new ArrayList<ServicePropertiesChangeListener>();
+        public List<ServicePropertiesChangeListener> listeners = new ArrayList<ServicePropertiesChangeListener>();
 
-		public void addListener(ServicePropertiesChangeListener listener) {
-			listeners.add(listener);
-		}
+        public void addListener(ServicePropertiesChangeListener listener) {
+            listeners.add(listener);
+        }
 
-		public void removeListener(ServicePropertiesChangeListener listener) {
-			listeners.remove(listener);
-		}
+        public void removeListener(ServicePropertiesChangeListener listener) {
+            listeners.remove(listener);
+        }
 
-		public void update() {
-			ServicePropertiesChangeEvent event = new ServicePropertiesChangeEvent(this);
-			for (ServicePropertiesChangeListener listener : listeners) {
-				listener.propertiesChange(event);
-			}
-		}
-	}
+        public void update() {
+            ServicePropertiesChangeEvent event = new ServicePropertiesChangeEvent(this);
+            for (ServicePropertiesChangeListener listener : listeners) {
+                listener.propertiesChange(event);
+            }
+        }
+    }
 
-	protected void setUp() throws Exception {
-		exporter = new OsgiServiceFactoryBean();
-		beanFactoryControl = MockControl.createControl(ConfigurableBeanFactory.class);
-		beanFactory = (ConfigurableBeanFactory) this.beanFactoryControl.getMock();
-		bundleContext = new MockBundleContext();
-		ctxCtrl = MockControl.createControl(BundleContext.class);
-		ctx = (BundleContext) ctxCtrl.getMock();
+    protected void setUp() throws Exception {
+        exporter = new OsgiServiceFactoryBean();
+        beanFactoryControl = createControl();
+        beanFactory = this.beanFactoryControl.createMock(ConfigurableBeanFactory.class);
+        bundleContext = new MockBundleContext();
+        ctxCtrl = createControl();
+        ctx = ctxCtrl.createMock(BundleContext.class);
 
-		exporter.setBeanFactory(beanFactory);
-		exporter.setBundleContext(bundleContext);
-	}
+        exporter.setBeanFactory(beanFactory);
+        exporter.setBundleContext(bundleContext);
+    }
 
-	protected void tearDown() throws Exception {
-		exporter = null;
-		bundleContext = null;
-		ctxCtrl = null;
-		ctx = null;
-	}
+    protected void tearDown() throws Exception {
+        exporter = null;
+        bundleContext = null;
+        ctxCtrl = null;
+        ctx = null;
+    }
 
-	public void testInitWithoutBundleContext() throws Exception {
-		exporter.setBundleContext(null);
-		exporter.setTarget(new Object());
+    public void testInitWithoutBundleContext() throws Exception {
+        exporter.setBundleContext(null);
+        exporter.setTarget(new Object());
 
-		try {
-			this.exporter.afterPropertiesSet();
-			fail("Expecting IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// expected
-		}
-	}
+        try {
+            this.exporter.afterPropertiesSet();
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
 
-	public void testInitWithoutBeanFactory() throws Exception {
-		exporter.setBeanFactory(null);
-		exporter.setTarget(new Object());
+    public void testInitWithoutBeanFactory() throws Exception {
+        exporter.setBeanFactory(null);
+        exporter.setTarget(new Object());
 
-		try {
-			this.exporter.afterPropertiesSet();
-			fail("Expecting IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// expected
-		}
-	}
+        try {
+            this.exporter.afterPropertiesSet();
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
 
-	public void testInitWithoutTargetOrTargetReference() throws Exception {
-		try {
-			this.exporter.afterPropertiesSet();
-			fail("Expecting IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// expected
-		}
-	}
+    public void testInitWithoutTargetOrTargetReference() throws Exception {
+        try {
+            this.exporter.afterPropertiesSet();
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
 
-	public void testInitWithTargetAndTargetRerefence() throws Exception {
-		exporter.setTarget(new Object());
-		exporter.setTargetBeanName("costin");
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton("costin"), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean("costin"), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getType("costin"), Object.class);
-		beanFactoryControl.replay();
-		try {
-			this.exporter.afterPropertiesSet();
-			fail("Expecting IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
-			// expected
-		}
-	}
+    public void testInitWithTargetAndTargetRerefence() throws Exception {
+        final Object obj = new Object();
+        exporter.setTarget(obj);
+        exporter.setTargetBeanName("costin");
+        expect(beanFactory.isSingleton("costin")).andReturn(false);
+        expect(beanFactory.containsBean("costin")).andReturn(true);
+        expect(beanFactory.getType("costin")).andReturn((Class)Object.class);
+        beanFactoryControl.replay();
+        try {
+            this.exporter.afterPropertiesSet();
+            fail("Expecting IllegalArgumentException");
+        } catch (IllegalArgumentException ex) {
+            // expected
+        }
+    }
 
-	public void testInitWithOnlyJustTarget() throws Exception {
-		exporter.setTarget(new Object());
-		exporter.setInterfaces(new Class<?>[] { Object.class });
-		exporter.afterPropertiesSet();
-	}
+    public void testInitWithOnlyJustTarget() throws Exception {
+        exporter.setTarget(new Object());
+        exporter.setInterfaces(new Class<?>[]{Object.class});
+        exporter.afterPropertiesSet();
+    }
 
-	public void testAutoDetectClassesForPublishingDisabled() throws Exception {
-		exporter.setInterfaceDetector(DefaultInterfaceDetector.DISABLED);
-		Class<?>[] clazz = DefaultInterfaceDetector.DISABLED.detect(Integer.class);
-		assertNotNull(clazz);
-		assertEquals(0, clazz.length);
-	}
+    public void testAutoDetectClassesForPublishingDisabled() throws Exception {
+        exporter.setInterfaceDetector(DefaultInterfaceDetector.DISABLED);
+        Class<?>[] clazz = DefaultInterfaceDetector.DISABLED.detect(Integer.class);
+        assertNotNull(clazz);
+        assertEquals(0, clazz.length);
+    }
 
-	public void testAutoDetectClassesForPublishingInterfaces() throws Exception {
-		exporter.setInterfaceDetector(DefaultInterfaceDetector.INTERFACES);
-		Class<?>[] clazz = DefaultInterfaceDetector.INTERFACES.detect(HashMap.class);
-		Class<?>[] expected = new Class<?>[] { Cloneable.class, Serializable.class, Map.class };
+    public void testAutoDetectClassesForPublishingInterfaces() throws Exception {
+        exporter.setInterfaceDetector(DefaultInterfaceDetector.INTERFACES);
+        Class<?>[] clazz = DefaultInterfaceDetector.INTERFACES.detect(HashMap.class);
+        Class<?>[] expected = new Class<?>[]{Cloneable.class, Serializable.class, Map.class};
 
-		assertTrue(compareArrays(expected, clazz));
-	}
+        assertTrue(compareArrays(expected, clazz));
+    }
 
-	public void testAutoDetectClassesForPublishingClassHierarchy() throws Exception {
-		exporter.setInterfaceDetector(DefaultInterfaceDetector.CLASS_HIERARCHY);
-		Class<?>[] clazz = DefaultInterfaceDetector.CLASS_HIERARCHY.detect(HashMap.class);
-		Class<?>[] expected = new Class<?>[] { HashMap.class, AbstractMap.class };
-		assertTrue(compareArrays(expected, clazz));
-	}
+    public void testAutoDetectClassesForPublishingClassHierarchy() throws Exception {
+        exporter.setInterfaceDetector(DefaultInterfaceDetector.CLASS_HIERARCHY);
+        Class<?>[] clazz = DefaultInterfaceDetector.CLASS_HIERARCHY.detect(HashMap.class);
+        Class<?>[] expected = new Class<?>[]{HashMap.class, AbstractMap.class};
+        assertTrue(compareArrays(expected, clazz));
+    }
 
-	public void testAutoDetectClassesForPublishingAll() throws Exception {
-		exporter.setInterfaceDetector(DefaultInterfaceDetector.ALL_CLASSES);
-		Class<?>[] clazz = DefaultInterfaceDetector.ALL_CLASSES.detect(HashMap.class);
-		Class<?>[] expected =
-				new Class<?>[] { Map.class, Cloneable.class, Serializable.class, HashMap.class, AbstractMap.class };
-		assertTrue(compareArrays(expected, clazz));
-	}
+    public void testAutoDetectClassesForPublishingAll() throws Exception {
+        exporter.setInterfaceDetector(DefaultInterfaceDetector.ALL_CLASSES);
+        Class<?>[] clazz = DefaultInterfaceDetector.ALL_CLASSES.detect(HashMap.class);
+        Class<?>[] expected =
+                new Class<?>[]{Map.class, Cloneable.class, Serializable.class, HashMap.class, AbstractMap.class};
+        assertTrue(compareArrays(expected, clazz));
+    }
 
-	public void testRegisterServiceWithNullClasses() throws Exception {
-		try {
-			exporter.registerService(null, new Properties());
-			fail("Expected to throw IllegalArgumentException");
-		} catch (IllegalArgumentException e) {
-			// expected
-		}
-	}
+    public void testRegisterServiceWithNullClasses() throws Exception {
+        try {
+            exporter.registerService(null, new Properties());
+            fail("Expected to throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
 
-	public void testRegisterServiceWOClasses() throws Exception {
-		try {
-			exporter.registerService(new Class[0], new Properties());
-			fail("Expected to throw IllegalArgumentException");
-		} catch (IllegalArgumentException e) {
-			// expected
-		}
-	}
+    public void testRegisterServiceWOClasses() throws Exception {
+        try {
+            exporter.registerService(new Class[0], new Properties());
+            fail("Expected to throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
 
-	public void testRegisterService() throws Exception {
-		Class<?>[] clazz =
-				new Class<?>[] { Serializable.class, HashMap.class, Cloneable.class, Map.class, LinkedHashMap.class };
+    public void testRegisterService() throws Exception {
+        Class<?>[] clazz =
+                new Class<?>[]{Serializable.class, HashMap.class, Cloneable.class, Map.class, LinkedHashMap.class};
 
-		String[] names = new String[clazz.length];
+        String[] names = new String[clazz.length];
 
-		for (int i = 0; i < clazz.length; i++) {
-			names[i] = clazz[i].getName();
-		}
+        for (int i = 0; i < clazz.length; i++) {
+            names[i] = clazz[i].getName();
+        }
 
-		final Properties props = new Properties();
-		final ServiceRegistration reg = new MockServiceRegistration();
+        final Properties props = new Properties();
+        final ServiceRegistration reg = new MockServiceRegistration();
 
-		exporter.setBundleContext(new MockBundleContext() {
+        exporter.setBundleContext(new MockBundleContext() {
 
-			public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
-				assertTrue(service instanceof ServiceFactory);
-				return reg;
-			}
-		});
+            public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
+                assertTrue(service instanceof ServiceFactory);
+                return reg;
+            }
+        });
 
-		Object proxy = MockControl.createControl(ServiceFactory.class).getMock();
-		exporter.setTarget(proxy);
-		exporter.setInterfaces(new Class<?>[] { ServiceFactory.class });
-		String beanName = "boo";
-		exporter.setTargetBeanName(beanName);
+        Object proxy = createMock(ServiceFactory.class);
+        exporter.setTarget(proxy);
+        exporter.setInterfaces(new Class<?>[]{ServiceFactory.class});
+        String beanName = "boo";
+        exporter.setTargetBeanName(beanName);
 
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.isPrototype(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), proxy);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), proxy.getClass());
-		beanFactoryControl.replay();
+        expect(beanFactory.isSingleton(beanName)).andReturn(true);
+        expect(beanFactory.isPrototype(beanName)).andReturn(false);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(proxy);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) ServiceFactory.class);
+        beanFactoryControl.replay();
 
-		exporter.afterPropertiesSet();
-		assertSame(reg, exporter.registerService(clazz, props));
-	}
+        exporter.afterPropertiesSet();
+        assertSame(reg, exporter.registerService(clazz, props));
+    }
 
-	public void testUnregisterWithNullServiceReg() throws Exception {
-		exporter.unregisterService(null);
-	}
+    public void testUnregisterWithNullServiceReg() throws Exception {
+        exporter.unregisterService(null);
+    }
 
-	public void testUnregisterService() throws Exception {
-		MockControl ctrl = MockControl.createControl(ServiceRegistration.class);
-		ServiceRegistration reg = (ServiceRegistration) ctrl.getMock();
+    public void testUnregisterService() throws Exception {
+        ServiceRegistration reg = createMock(ServiceRegistration.class);
 
-		reg.unregister();
-		ctrl.replay();
-		exporter.unregisterService(reg);
-		ctrl.verify();
-	}
+        reg.unregister();
+        expectLastCall();
+        replay(reg);
+        exporter.unregisterService(reg);
+        verify(reg);
+    }
+
+    public void testUnregisterServiceAlreadyUnregistered() throws Exception {
+        ServiceRegistration reg = createMock(ServiceRegistration.class);
+
+        reg.unregister();
+        expectLastCall().andThrow(new IllegalStateException());
+        replay(reg);
+        exporter.unregisterService(reg);
+        verify(reg);
+    }
+
+    public void testLazyBeanServiceWithUsualBean() throws Exception {
+        final ServiceRegistration reg = new MockServiceRegistration();
+        final ServiceFactory[] factory = new ServiceFactory[1];
+
+        Object service = new Object();
+
+        BundleContext ctx = new MockBundleContext() {
+
+            public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
+                assertTrue(service instanceof ServiceFactory);
+                factory[0] = (ServiceFactory) service;
+                return reg;
+            }
+        };
+
+        exporter.setBundleContext(ctx);
+
+        String beanName = "fooBar";
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{service.getClass()});
+        expect(beanFactory.isSingleton(beanName)).andReturn(true);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(service);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) service.getClass());
+        beanFactoryControl.replay();
+
+        exporter.afterPropertiesSet();
+        exporter.registerService(new Class<?>[]{service.getClass()}, new Properties());
+
+        assertSame(service, factory[0].getService(null, null));
+        beanFactoryControl.verify();
+    }
 
-	public void testUnregisterServiceAlreadyUnregistered() throws Exception {
-		MockControl ctrl = MockControl.createControl(ServiceRegistration.class);
-		ServiceRegistration reg = (ServiceRegistration) ctrl.getMock();
+    public void testLazyBeanServiceWithServiceFactoryBean() throws Exception {
+        final ServiceRegistration reg = new MockServiceRegistration();
+        final ServiceFactory[] factory = new ServiceFactory[1];
 
-		reg.unregister();
-		ctrl.setDefaultThrowable(new IllegalStateException());
-		ctrl.replay();
-		exporter.unregisterService(reg);
-		ctrl.verify();
-	}
+        final Object actualService = new Object();
+        Object service = new MockServiceFactory() {
+            public Object getService(Bundle arg0, ServiceRegistration arg1) {
+                return actualService;
+            }
+        };
 
-	public void testLazyBeanServiceWithUsualBean() throws Exception {
-		final ServiceRegistration reg = new MockServiceRegistration();
-		final ServiceFactory[] factory = new ServiceFactory[1];
+        BundleContext ctx = new MockBundleContext() {
 
-		Object service = new Object();
+            public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
+                assertTrue(service instanceof ServiceFactory);
+                factory[0] = (ServiceFactory) service;
+                return reg;
+            }
+        };
 
-		BundleContext ctx = new MockBundleContext() {
+        String beanName = "fooBar";
+        expect(beanFactory.isSingleton(beanName)).andReturn(true);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(service);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) service.getClass());
+        beanFactoryControl.replay();
 
-			public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
-				assertTrue(service instanceof ServiceFactory);
-				factory[0] = (ServiceFactory) service;
-				return reg;
-			}
-		};
+        exporter.setBundleContext(ctx);
+        exporter.setBeanFactory(beanFactory);
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{service.getClass()});
 
-		exporter.setBundleContext(ctx);
+        exporter.afterPropertiesSet();
+        exporter.registerService(new Class<?>[]{actualService.getClass()}, new Properties());
+        assertSame(actualService, factory[0].getService(null, null));
+        beanFactoryControl.verify();
+    }
 
-		String beanName = "fooBar";
-		exporter.setTargetBeanName(beanName);
-		exporter.setInterfaces(new Class<?>[] { service.getClass() });
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), service);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), service.getClass());
-		beanFactoryControl.replay();
-		exporter.afterPropertiesSet();
-		exporter.registerService(new Class<?>[] { service.getClass() }, new Properties());
+    public void testLazyBeanServiceWithTargetObjectSet() throws Exception {
+        final ServiceRegistration reg = new MockServiceRegistration();
+        final ServiceFactory[] factory = new ServiceFactory[1];
 
-		assertSame(service, factory[0].getService(null, null));
-		beanFactoryControl.verify();
-	}
+        Object service = new Object();
 
-	public void testLazyBeanServiceWithServiceFactoryBean() throws Exception {
-		final ServiceRegistration reg = new MockServiceRegistration();
-		final ServiceFactory[] factory = new ServiceFactory[1];
+        BundleContext ctx = new MockBundleContext() {
 
-		final Object actualService = new Object();
-		Object service = new MockServiceFactory() {
-			public Object getService(Bundle arg0, ServiceRegistration arg1) {
-				return actualService;
-			}
-		};
+            public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
+                assertTrue(service instanceof ServiceFactory);
+                factory[0] = (ServiceFactory) service;
+                return reg;
+            }
+        };
 
-		BundleContext ctx = new MockBundleContext() {
+        exporter.setBundleContext(ctx);
+        exporter.setBeanFactory(beanFactory);
 
-			public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
-				assertTrue(service instanceof ServiceFactory);
-				factory[0] = (ServiceFactory) service;
-				return reg;
-			}
-		};
+        // give an actual target object not a target reference
+        exporter.setTarget(service);
+        exporter.setInterfaces(new Class<?>[]{service.getClass()});
 
-		String beanName = "fooBar";
+        beanFactoryControl.replay();
+        exporter.afterPropertiesSet();
+        exporter.registerService(new Class<?>[]{service.getClass()}, new Properties());
 
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		// beanFactoryControl.expectAndReturn(beanFactory.isPrototype(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), service);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), service.getClass());
-		beanFactoryControl.replay();
+        assertSame(service, factory[0].getService(null, null));
+        beanFactoryControl.verify();
+    }
 
-		exporter.setBundleContext(ctx);
-		exporter.setBeanFactory(beanFactory);
-		exporter.setTargetBeanName(beanName);
-		exporter.setInterfaces(new Class<?>[] { service.getClass() });
+    private boolean compareArrays(Object[] a, Object[] b) {
+        if (a.length != b.length)
+            return false;
 
-		exporter.afterPropertiesSet();
-		exporter.registerService(new Class<?>[] { actualService.getClass() }, new Properties());
-		assertSame(actualService, factory[0].getService(null, null));
-		beanFactoryControl.verify();
-	}
+        for (Object anA : a) {
+            boolean found = false;
+            for (Object aB : b) {
+                if (anA.equals(aB)) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found)
+                return false;
+        }
+        return true;
+    }
 
-	public void testLazyBeanServiceWithTargetObjectSet() throws Exception {
-		final ServiceRegistration reg = new MockServiceRegistration();
-		final ServiceFactory[] factory = new ServiceFactory[1];
+    public void testServiceFactory() throws Exception {
+        ServiceFactory factory = new MockServiceFactory();
 
-		Object service = new Object();
+        ctx = new MockBundleContext();
+        exporter.setBundleContext(ctx);
+        exporter.setBeanFactory(beanFactory);
+        exporter.setInterfaces(new Class<?>[]{Serializable.class, Cloneable.class});
+        exporter.setTarget(factory);
+        beanFactoryControl.replay();
+        exporter.afterPropertiesSet();
+    }
 
-		BundleContext ctx = new MockBundleContext() {
+    public void testUpdateableProperties() throws Exception {
+        UpdateableProperties properties = new UpdateableProperties();
+        properties.setProperty("steve", "vai");
 
-			public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
-				assertTrue(service instanceof ServiceFactory);
-				factory[0] = (ServiceFactory) service;
-				return reg;
-			}
-		};
+        exporter.setServiceProperties(properties);
+        exporter.setTarget("string");
+        exporter.setBeanName("string");
+        exporter.setInterfaces(new Class<?>[]{Serializable.class});
+        beanFactoryControl.replay();
+        exporter.afterPropertiesSet();
 
-		exporter.setBundleContext(ctx);
-		exporter.setBeanFactory(beanFactory);
+        ServiceRegistration reg = exporter.getObject();
+        assertEquals("vai", reg.getReference().getProperty("steve"));
+        assertNull(reg.getReference().getProperty("updated"));
 
-		// give an actual target object not a target reference
-		exporter.setTarget(service);
-		exporter.setInterfaces(new Class<?>[] { service.getClass() });
+        properties.setProperty("steve", "jobs");
+        properties.setProperty("updated", "true");
+        properties.update();
 
-		beanFactoryControl.replay();
-		exporter.afterPropertiesSet();
-		exporter.registerService(new Class<?>[] { service.getClass() }, new Properties());
+        assertEquals("jobs", reg.getReference().getProperty("steve"));
+        assertNotNull(reg.getReference().getProperty("updated"));
+    }
 
-		assertSame(service, factory[0].getService(null, null));
-		beanFactoryControl.verify();
-	}
+    public void testPrototypeServiceFactory() throws Exception {
+        ServiceFactory factory = new MockServiceFactory();
+        String beanName = "prototype-sf";
+        expect(beanFactory.isSingleton(beanName)).andReturn(false);
+        expect(beanFactory.isPrototype(beanName)).andReturn(true);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(factory);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) factory.getClass());
 
-	private boolean compareArrays(Object[] a, Object[] b) {
-		if (a.length != b.length)
-			return false;
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{Serializable.class});
+        beanFactoryControl.replay();
+        exporter.afterPropertiesSet();
+    }
 
-		for (int i = 0; i < a.length; i++) {
-			boolean found = false;
-			for (int j = 0; j < b.length; j++) {
-				if (a[i].equals(b[j])) {
-					found = true;
-					break;
-				}
-			}
-			if (!found)
-				return false;
-		}
-		return true;
-	}
+    public void testPrototypeServiceFactoryDestruction() throws Exception {
+        ServiceFactory factory = new MockServiceFactory();
+        String beanName = "prototype-sf";
 
-	public void testServiceFactory() throws Exception {
-		ServiceFactory factory = new MockServiceFactory();
+        expect(beanFactory.isSingleton(beanName)).andReturn(false).times(2);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.isPrototype(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(factory);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) factory.getClass());
 
-		ctx = new MockBundleContext();
-		exporter.setBundleContext(ctx);
-		exporter.setBeanFactory(beanFactory);
-		exporter.setInterfaces(new Class<?>[] { Serializable.class, Cloneable.class });
-		exporter.setTarget(factory);
-		beanFactoryControl.replay();
-		exporter.afterPropertiesSet();
-	}
 
-	public void testUpdateableProperties() throws Exception {
-		UpdateableProperties properties = new UpdateableProperties();
-		properties.setProperty("steve", "vai");
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{Serializable.class});
+        beanFactoryControl.replay();
+        exporter.afterPropertiesSet();
+        exporter.destroy();
+    }
 
-		exporter.setServiceProperties(properties);
-		exporter.setTarget("string");
-		exporter.setBeanName("string");
-		exporter.setInterfaces(new Class<?>[] { Serializable.class });
-		beanFactoryControl.replay();
-		exporter.afterPropertiesSet();
+    public void testNonSingletonServiceFactoryRegistration() throws Exception {
+        TestRegistrationListener listener = new TestRegistrationListener();
 
-		ServiceRegistration reg = exporter.getObject();
-		assertEquals("vai", reg.getReference().getProperty("steve"));
-		assertNull(reg.getReference().getProperty("updated"));
+        ServiceFactory factory = new MockServiceFactory();
+        String beanName = "prototype-sf";
+        expect(beanFactory.isSingleton(beanName)).andReturn(false).times(3);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.isPrototype(beanName)).andReturn(false);
+        expect(beanFactory.getBean(beanName)).andReturn(factory);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) factory.getClass());
 
-		properties.setProperty("steve", "jobs");
-		properties.setProperty("updated", "true");
-		properties.update();
 
-		assertEquals("jobs", reg.getReference().getProperty("steve"));
-		assertNotNull(reg.getReference().getProperty("updated"));
-	}
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{Serializable.class});
+        exporter.setListeners(new OsgiServiceRegistrationListener[]{listener});
 
-	public void testPrototypeServiceFactory() throws Exception {
-		ServiceFactory factory = new MockServiceFactory();
-		String beanName = "prototype-sf";
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.isPrototype(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), factory);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), factory.getClass());
-		exporter.setTargetBeanName(beanName);
-		exporter.setInterfaces(new Class<?>[] { Serializable.class });
-		beanFactoryControl.replay();
-		exporter.afterPropertiesSet();
-	}
-

-	public void testPrototypeServiceFactoryDestruction() throws Exception {

-        ServiceFactory factory = new MockServiceFactory();

-        String beanName = "prototype-sf";

-        beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);

-        beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);

-        beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);

-        beanFactoryControl.expectAndReturn(beanFactory.isPrototype(beanName), true);

-        beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), factory);

-        beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), factory.getClass());

-        exporter.setTargetBeanName(beanName);

-        exporter.setInterfaces(new Class<?>[] { Serializable.class });

-        beanFactoryControl.replay();

-        exporter.afterPropertiesSet();

-        exporter.destroy();

-    }

-	
-	public void testNonSingletonServiceFactoryRegistration() throws Exception {
-		TestRegistrationListener listener = new TestRegistrationListener();
+        beanFactoryControl.replay();
+        assertEquals(0, listener.registered.size());
+        assertEquals(0, listener.unregistered.size());
 
-		ServiceFactory factory = new MockServiceFactory();
-		String beanName = "prototype-sf";
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.isPrototype(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), factory);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), factory.getClass());
-		exporter.setTargetBeanName(beanName);
-		exporter.setInterfaces(new Class<?>[] { Serializable.class });
-		exporter.setListeners(new OsgiServiceRegistrationListener[] { listener });
+        exporter.afterPropertiesSet();
 
-		beanFactoryControl.replay();
-		assertEquals(0, listener.registered.size());
-		assertEquals(0, listener.unregistered.size());
+        assertEquals(1, listener.registered.size());
+        assertEquals(0, listener.unregistered.size());
 
-		exporter.afterPropertiesSet();
+        assertNull(listener.registered.keySet().iterator().next());
+        exporter.destroy();
+        assertEquals(1, listener.unregistered.size());
+        assertNull(listener.unregistered.keySet().iterator().next());
+    }
 
-		assertEquals(1, listener.registered.size());
-		assertEquals(0, listener.unregistered.size());
+    public void testNonSingletonNonServiceFactoryRegistration() throws Exception {
+        TestRegistrationListener listener = new TestRegistrationListener();
 
-		assertNull(listener.registered.keySet().iterator().next());
-		exporter.destroy();
-		assertEquals(1, listener.unregistered.size());
-		assertNull(listener.unregistered.keySet().iterator().next());
-	}
+        Object obj = new Object();
+        String beanName = "prototype-non-sf";
 
-	public void testNonSingletonNonServiceFactoryRegistration() throws Exception {
-		TestRegistrationListener listener = new TestRegistrationListener();
+        expect(beanFactory.isSingleton(beanName)).andReturn(false).times(3);
+        expect(beanFactory.containsBean(beanName)).andReturn(true);
+        expect(beanFactory.getBean(beanName)).andReturn(obj);
+        expect(beanFactory.getType(beanName)).andStubReturn((Class) Object.class);
 
-		Object obj = new Object();
-		String beanName = "prototype-non-sf";
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.isSingleton(beanName), false);
-		beanFactoryControl.expectAndReturn(beanFactory.containsBean(beanName), true);
-		beanFactoryControl.expectAndReturn(beanFactory.getBean(beanName), obj);
-		beanFactoryControl.expectAndReturn(beanFactory.getType(beanName), obj.getClass());
-		exporter.setTargetBeanName(beanName);
-		exporter.setInterfaces(new Class<?>[] { Object.class });
-		exporter.setListeners(new OsgiServiceRegistrationListener[] { listener });
+        exporter.setTargetBeanName(beanName);
+        exporter.setInterfaces(new Class<?>[]{Object.class});
+        exporter.setListeners(new OsgiServiceRegistrationListener[]{listener});
 
-		beanFactoryControl.replay();
-		assertEquals(listener.registered.size(), 0);
-		assertEquals(listener.unregistered.size(), 0);
+        beanFactoryControl.replay();
+        assertEquals(listener.registered.size(), 0);
+        assertEquals(listener.unregistered.size(), 0);
 
-		exporter.afterPropertiesSet();
-		assertEquals(listener.registered.size(), 1);
-		assertEquals(listener.unregistered.size(), 0);
+        exporter.afterPropertiesSet();
+        assertEquals(listener.registered.size(), 1);
+        assertEquals(listener.unregistered.size(), 0);
 
-		assertNull(listener.registered.keySet().iterator().next());
-		exporter.destroy();
-		assertEquals(listener.unregistered.size(), 1);
-		assertNull(listener.unregistered.keySet().iterator().next());
-	}
+        assertNull(listener.registered.keySet().iterator().next());
+        exporter.destroy();
+        assertEquals(listener.unregistered.size(), 1);
+        assertNull(listener.unregistered.keySet().iterator().next());
+    }
 }
\ No newline at end of file
diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationWrapperTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationWrapperTest.java
index b82b56c..1fb00bc 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationWrapperTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/exporter/support/internal/support/ServiceRegistrationWrapperTest.java
@@ -20,11 +20,9 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.service.exporter.OsgiServiceRegistrationListener;

 import org.eclipse.gemini.blueprint.service.exporter.SimpleOsgiServiceRegistrationListener;

-import org.eclipse.gemini.blueprint.service.exporter.support.internal.support.ListenerNotifier;

-import org.eclipse.gemini.blueprint.service.exporter.support.internal.support.ServiceRegistrationDecorator;

 import org.osgi.framework.ServiceReference;

 import org.osgi.framework.ServiceRegistration;

 import org.eclipse.gemini.blueprint.mock.MockServiceReference;

@@ -35,11 +33,8 @@
 

 	private ServiceRegistration actualRegistration;

 

-	private MockControl mc;

-

 	protected void setUp() throws Exception {

-		mc = MockControl.createControl(ServiceRegistration.class);

-		actualRegistration = (ServiceRegistration) mc.getMock();

+		actualRegistration = createMock(ServiceRegistration.class);

 

 		final ListenerNotifier notifier =

 				new ListenerNotifier(

@@ -60,14 +55,14 @@
 	}

 

 	protected void tearDown() throws Exception {

-		mc.verify();

+		verify(actualRegistration);

 		registration = null;

 	}

 

 	public void testGetReference() {

 		ServiceReference reference = new MockServiceReference();

-		mc.expectAndReturn(actualRegistration.getReference(), reference);

-		mc.replay();

+		expect(actualRegistration.getReference()).andReturn(reference);

+		replay(actualRegistration);

 

 		assertSame(reference, registration.getReference());

 	}

@@ -75,16 +70,17 @@
 	public void testSetProperties() {

 		Dictionary props = new Hashtable();

 		actualRegistration.setProperties(props);

-		mc.replay();

+        expectLastCall();

+		replay(actualRegistration);

 

 		registration.setProperties(props);

 	}

 

 	public void testUnregister() {

 		ServiceReference reference = new MockServiceReference();

-		mc.expectAndReturn(actualRegistration.getReference(), reference);

+		expect(actualRegistration.getReference()).andReturn(reference);

 		actualRegistration.unregister();

-		mc.replay();

+		replay(actualRegistration);

 

 		registration.unregister();

 	}

@@ -93,9 +89,10 @@
 		assertEquals(0, SimpleOsgiServiceRegistrationListener.UNREGISTERED);

 

 		ServiceReference reference = new MockServiceReference();

-		mc.expectAndReturn(actualRegistration.getReference(), reference);

+		expect(actualRegistration.getReference()).andReturn(reference);

 		actualRegistration.unregister();

-		mc.replay();

+        expectLastCall();

+		replay(actualRegistration);

 

 		registration.unregister();

 

@@ -105,9 +102,9 @@
 	public void testExceptionProperlyPropagates() {

 		assertEquals(0, SimpleOsgiServiceRegistrationListener.UNREGISTERED);

 		IllegalStateException excep = new IllegalStateException();

-		mc.expectAndThrow(actualRegistration.getReference(), excep);

+		expect(actualRegistration.getReference()).andThrow(excep);

 

-		mc.replay();

+		replay(actualRegistration);

 		try {

 			registration.unregister();

 		} catch (IllegalStateException ise) {

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiServiceCollectionProxyFactoryBeanTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiServiceCollectionProxyFactoryBeanTest.java
index 76b924f..dce13b7 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiServiceCollectionProxyFactoryBeanTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiServiceCollectionProxyFactoryBeanTest.java
@@ -20,7 +20,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.TestUtils;

 import org.eclipse.gemini.blueprint.service.ServiceUnavailableException;

 import org.eclipse.gemini.blueprint.service.importer.OsgiServiceLifecycleListener;

@@ -80,9 +80,7 @@
 	public void testListenersSetOnCollection() throws Exception {

 		serviceFactoryBean.setAvailability(Availability.OPTIONAL);

 

-		OsgiServiceLifecycleListener[] listeners =

-				{ (OsgiServiceLifecycleListener) MockControl.createControl(OsgiServiceLifecycleListener.class)

-						.getMock() };

+		OsgiServiceLifecycleListener[] listeners = { createMock(OsgiServiceLifecycleListener.class) };

 		serviceFactoryBean.setListeners(listeners);

 		serviceFactoryBean.afterPropertiesSet();

 

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiSingleServiceProxyFactoryBeanTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiSingleServiceProxyFactoryBeanTest.java
index f502ed0..3e3bc88 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiSingleServiceProxyFactoryBeanTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/service/importer/OsgiSingleServiceProxyFactoryBeanTest.java
@@ -21,7 +21,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.service.importer.ImportedOsgiServiceProxy;

 import org.eclipse.gemini.blueprint.service.importer.support.ImportContextClassLoaderEnum;

 import org.eclipse.gemini.blueprint.service.importer.support.OsgiServiceProxyFactoryBean;

@@ -43,16 +43,13 @@
 

 	private OsgiServiceProxyFactoryBean serviceFactoryBean;

 

-	private MockControl mockControl;

-

 	private BundleContext bundleContext;

 

 	protected void setUp() throws Exception {

 		super.setUp();

 		this.serviceFactoryBean = new OsgiServiceProxyFactoryBean();

 		this.serviceFactoryBean.setBeanClassLoader(getClass().getClassLoader());

-		this.mockControl = MockControl.createControl(BundleContext.class);

-		this.bundleContext = (BundleContext) this.mockControl.getMock();

+		this.bundleContext = createMock(BundleContext.class);

 	}

 

 	public void testAfterPropertiesSetNoBundle() throws Exception {

diff --git a/core/src/test/java/org/eclipse/gemini/blueprint/util/BundleDelegatingClassLoaderTest.java b/core/src/test/java/org/eclipse/gemini/blueprint/util/BundleDelegatingClassLoaderTest.java
index b277531..b323cc1 100644
--- a/core/src/test/java/org/eclipse/gemini/blueprint/util/BundleDelegatingClassLoaderTest.java
+++ b/core/src/test/java/org/eclipse/gemini/blueprint/util/BundleDelegatingClassLoaderTest.java
@@ -15,7 +15,7 @@
 package org.eclipse.gemini.blueprint.util;

 

 import junit.framework.TestCase;

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.osgi.framework.Bundle;

 import org.springframework.aop.framework.ProxyFactory;

 

@@ -33,30 +33,24 @@
 

 	private BundleDelegatingClassLoader classLoader;

 

-	private MockControl bundleCtrl;

-

 	private Bundle bundle;

 

     private ClassLoader bridge;

 

 	protected void setUp() throws Exception {

-		bundleCtrl = MockControl.createStrictControl(Bundle.class);

-		bundle = (Bundle) bundleCtrl.getMock();

+		bundle = createMock(Bundle.class);

 		classLoader = createBundleClassLoaderFor(bundle, ProxyFactory.class.getClassLoader());

         bridge = getClass().getClassLoader();

-

-		bundleCtrl.reset();

 	}

 

 	protected void tearDown() throws Exception {

-		bundleCtrl.verify();

+		verify(bundle);

 		classLoader = null;

-		bundleCtrl = null;

 		bundle = null;

 	}

 

 	public void tstEquals() {

-		bundleCtrl.replay();

+		replay(bundle);

 

 		assertFalse(classLoader.equals(new Object()));

 		assertEquals(classLoader, classLoader);

@@ -69,11 +63,11 @@
 	public void testFindClass() throws Exception {

 		String className = "foo.bar";

 		String anotherClassName = "bar.foo";

-		bundleCtrl.expectAndReturn(bundle.loadClass(className), Object.class);

-		bundleCtrl.expectAndThrow(bundle.loadClass(anotherClassName), new ClassNotFoundException());

-		bundleCtrl.expectAndReturn(bundle.getSymbolicName(), "Test Bundle Symbolic Name");

-		//bundleCtrl.expectAndReturn(bundle.getHeaders(), new Properties());

-		bundleCtrl.replay();

+		expect(bundle.loadClass(className)).andReturn(Object.class);

+        

+		expect(bundle.loadClass(anotherClassName)).andThrow(new ClassNotFoundException());

+	    expect(bundle.getSymbolicName()).andReturn("Test Bundle Symbolic Name");

+		replay(bundle);

 

 		assertSame(Object.class, classLoader.findClass(className));

 

@@ -88,19 +82,18 @@
 		String resource = "file://bla-bla";

 		URL url = new URL(resource);

 

-		bundleCtrl.expectAndReturn(bundle.getResource(resource), url);

-		bundleCtrl.replay();

+		expect(bundle.getResource(resource)).andReturn(url);

+		replay(bundle);

 

 		assertSame(url, classLoader.findResource(resource));

 	}

 

 	public void testFindResources() throws Exception {

 		String resource = "bla-bla";

-		MockControl enumCtrl = MockControl.createStrictControl(Enumeration.class);

-		Enumeration enumeration = (Enumeration) enumCtrl.getMock();

+        Enumeration enumeration = createMock(Enumeration.class);

 

-		bundleCtrl.expectAndReturn(bundle.getResources(resource), enumeration);

-		bundleCtrl.replay();

+		expect(bundle.getResources(resource)).andReturn(enumeration);

+		replay(bundle);

 

 		assertSame(enumeration, classLoader.findResources(resource));

 	}

@@ -109,15 +102,14 @@
         final String resourceName = "org/eclipse/gemini/blueprint/util/internal/resource.txt";

         final URL bundleURL = new URL("file://bundle/resourceName");

 

-        MockControl bundleResourcesControl = MockControl.createStrictControl(Enumeration.class);

-        Enumeration bundleResources = (Enumeration) bundleResourcesControl.getMock();

-        bundleResourcesControl.expectAndReturn(bundleResources.hasMoreElements(), true, 2);

-        bundleResourcesControl.expectAndReturn(bundleResources.nextElement(), bundleURL);

-        bundleResourcesControl.expectAndReturn(bundleResources.hasMoreElements(), false, 2);

-        bundleResourcesControl.replay();

-

-        bundleCtrl.expectAndReturn(bundle.getResources(resourceName), bundleResources);

-        bundleCtrl.replay();

+        Enumeration bundleResources = createMock(Enumeration.class);

+        

+        expect(bundle.getResources(resourceName)).andReturn(bundleResources);

+        expect(bundleResources.hasMoreElements()).andReturn(true).times(2);

+        expect(bundleResources.nextElement()).andReturn(bundleURL);

+        expect(bundleResources.hasMoreElements()).andReturn(false).times(2);

+        

+        replay(bundleResources, bundle);

 

         Enumeration<URL> resources = createBundleClassLoaderFor(bundle, bridge).getResources(resourceName);

 

@@ -134,15 +126,14 @@
         final String resourceName = "org/eclipse/gemini/blueprint/util/internal/resource.txt";

         final URL bundleURL = new URL("file://bundle/resourceName");

 

-        MockControl bundleResourcesControl = MockControl.createStrictControl(Enumeration.class);

-        Enumeration bundleResources = (Enumeration) bundleResourcesControl.getMock();

-        bundleResourcesControl.expectAndReturn(bundleResources.hasMoreElements(), true);

-        bundleResourcesControl.expectAndReturn(bundleResources.nextElement(), bundleURL);

-        bundleResourcesControl.expectAndReturn(bundleResources.hasMoreElements(), false);

-        bundleResourcesControl.replay();

+        Enumeration bundleResources = createMock(Enumeration.class);

 

-        bundleCtrl.expectAndReturn(bundle.getResources(resourceName), bundleResources);

-        bundleCtrl.replay();

+        expect(bundle.getResources(resourceName)).andReturn( bundleResources);

+        expect(bundleResources.hasMoreElements()).andReturn(true);

+        expect(bundleResources.nextElement()).andReturn( bundleURL);

+        expect(bundleResources.hasMoreElements()).andReturn( false);

+

+        replay(bundleResources, bundle);

 

         Enumeration<URL> resources = createBundleClassLoaderFor(bundle, null).getResources(resourceName);

 

@@ -154,8 +145,8 @@
     public void testGetResourcesFromBridgeOnly() throws Exception {

         final String resourceName = "org/eclipse/gemini/blueprint/util/internal/resource.txt";

 

-        bundleCtrl.expectAndReturn(bundle.getResources(resourceName), null);

-        bundleCtrl.replay();

+        expect(bundle.getResources(resourceName)).andReturn(null);

+        replay(bundle);

 

         Enumeration<URL> resources = createBundleClassLoaderFor(bundle, bridge).getResources(resourceName);

         assertTrue(resources.hasMoreElements());

@@ -168,8 +159,8 @@
     public void testGetResourcesIsNullSafe() throws IOException {

         final String resourceName = "org/eclipse/gemini/blueprint/util/internal/resource.txt";

 

-        bundleCtrl.expectAndReturn(bundle.getResources(resourceName), null);

-        bundleCtrl.replay();

+        expect(bundle.getResources(resourceName)).andReturn(null);

+        replay(bundle);

 

         Enumeration<URL> resources = createBundleClassLoaderFor(bundle, null).getResources(resourceName);

 

diff --git a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java
index cc3acbf..1f2cbae 100644
--- a/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java
+++ b/extender/src/test/java/org/eclipse/gemini/blueprint/extender/internal/ContextLoaderListenerTest.java
@@ -20,7 +20,7 @@
 
 import junit.framework.TestCase;
 
-import org.easymock.MockControl;
+import static org.easymock.EasyMock.*;
 import org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener;
 import org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration;
 import org.eclipse.gemini.blueprint.extender.internal.support.TestTaskExecutor;
@@ -51,44 +51,32 @@
 	}
 
 	public void testStart() throws Exception {
-		MockControl bundleContextControl = MockControl.createControl(BundleContext.class);
-		BundleContext context = (BundleContext) bundleContextControl.getMock();
+		BundleContext context = createMock(BundleContext.class);
 		// platform determination
 
 		// extracting bundle id from bundle
-		bundleContextControl.expectAndReturn(context.getBundle(), new MockBundle());
+		expect(context.getBundle()).andReturn(new MockBundle());
 
 		// look for existing resolved bundles
-		bundleContextControl.expectAndReturn(context.getBundles(), new Bundle[0], 2);
-
-		// register namespace and entity resolving service
-		// context.registerService((String[]) null, null, null);
-		// bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
-		// bundleContextControl.setReturnValue(null);
+		expect(context.getBundles()).andReturn(new Bundle[0]).times(2);
 
 		// register context service
-		context.registerService((String[]) null, null, null);
-		bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
-		bundleContextControl.setReturnValue(null, MockControl.ONE_OR_MORE);
+		expect(context.registerService((String[]) null, null, null)).andReturn(null).atLeastOnce();
 
 		// create task executor
 		EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
 		aBundle.setEntryReturnOnNextCallToGetEntry(null);
-		bundleContextControl.expectAndReturn(context.getBundle(), aBundle, MockControl.ONE_OR_MORE);
+		expect(context.getBundle()).andReturn(aBundle).atLeastOnce();
 
 		// listen for bundle events
 		context.addBundleListener(null);
-		bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
-		bundleContextControl.setVoidCallable(2);
+        expectLastCall().times(2);
 
-		bundleContextControl.expectAndReturn(context.registerService(new String[0], null, new Properties()),
-			new MockServiceRegistration(), MockControl.ONE_OR_MORE);
-		bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
-
-		bundleContextControl.replay();
+		expect(context.registerService(new String[0], null, new Properties())).andReturn(new MockServiceRegistration()).atLeastOnce();
+		replay(context);
 
 		this.listener.start(context);
-		bundleContextControl.verify();
+		verify(context);
 	}
 
 	public void tstTaskExecutor() throws Exception {
diff --git a/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceLoaderTest.java b/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceLoaderTest.java
index 831297b..cb47aab 100644
--- a/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceLoaderTest.java
+++ b/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceLoaderTest.java
@@ -18,7 +18,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.mock.ArrayEnumerator;

 import org.osgi.framework.Bundle;

 import org.springframework.core.io.Resource;

@@ -31,20 +31,16 @@
 

 	OsgiBundleResourceLoader loader;

 

-	MockControl control;

-

 	Bundle bundle;

 

 	protected void setUp() throws Exception {

-		control = MockControl.createStrictControl(Bundle.class);

-		bundle = (Bundle) control.getMock();

+		bundle = createMock(Bundle.class);

 		loader = new OsgiBundleResourceLoader(bundle);

 	}

 

 	protected void tearDown() throws Exception {

 		loader = null;

 		bundle = null;

-		control = null;

 	}

 

 	/**

@@ -54,47 +50,47 @@
 	public void testGetClasspathResource() throws Exception {

 		String res = "foo.txt";

 		URL expected = new URL("file://" + res);

-		control.expectAndReturn(bundle.getResource(res), expected);

-		control.replay();

+		expect(bundle.getResource(res)).andReturn(expected);

+		replay(bundle);

 

 		Resource resource = loader.getResource("classpath:" + res);

 		assertNotNull(resource);

 		assertSame(expected, resource.getURL());

-		control.verify();

+		verify(bundle);

 	}

 

 	public void testGetBundleResource() throws Exception {

 		String res = "foo.txt";

 		URL url = new URL("file:/" + res);

-		control.expectAndReturn(bundle.findEntries("/", res, false), new ArrayEnumerator(new URL[] {url}));

-		control.replay();

+		expect(bundle.findEntries("/", res, false)).andReturn(new ArrayEnumerator(new URL[] {url}));

+		replay(bundle);

 

 		Resource resource = loader.getResource("osgibundle:/" + res);

 		assertNotNull(resource);

 		assertSame(url, resource.getURL());

-		control.verify();

+		verify(bundle);

 	}

 

 	public void testGetRelativeResource() throws Exception {

 		String res = "foo.txt";

 		URL expected = new URL("file:/" + res);

-		control.replay();

+		replay(bundle);

 

 		Resource resource = loader.getResource("file:/" + res);

 		assertNotNull(resource);

 		assertEquals(expected, resource.getURL());

-		control.verify();

+		verify(bundle);

 	}

 

 	public void testGetFallbackResource() throws Exception {

 		String res = "foo.txt";

 		URL expected = new URL("http:/" + res);

-		control.replay();

+		replay(bundle);

 

 		Resource resource = loader.getResource("http:/" + res);

 		assertNotNull(resource);

 		assertEquals(expected, resource.getURL());

-		control.verify();

+		verify(bundle);

 	}

 

 	public void testGetResourceByPath() throws Exception {

diff --git a/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceTest.java b/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceTest.java
index 37190c9..c6e6baa 100644
--- a/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceTest.java
+++ b/io/src/test/java/org/eclipse/gemini/blueprint/io/OsgiBundleResourceTest.java
@@ -20,7 +20,7 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.mock.ArrayEnumerator;

 import org.eclipse.gemini.blueprint.mock.MockBundle;

 import org.osgi.framework.Bundle;

@@ -170,19 +170,18 @@
 	 * {@link org.eclipse.gemini.blueprint.io.OsgiBundleResource#getResourceFromBundleSpace(java.lang.String)}.

 	 */

 	public void testGetResourceFromBundle() throws Exception {

-		MockControl control = MockControl.createControl(Bundle.class);

-		Bundle mock = (Bundle) control.getMock();

+		Bundle mock = createMock(Bundle.class);

 

 		String location = "foo";

 		URL result = new URL("file:/" + location);

 

-		control.expectAndReturn(mock.findEntries("/", "foo", false), new ArrayEnumerator(new URL[] { result }));

-		control.replay();

+		expect(mock.findEntries("/", "foo", false)).andReturn(new ArrayEnumerator(new URL[] { result }));

+		replay(mock);

 

 		resource = new OsgiBundleResource(mock, location);

 

 		assertEquals(result, resource.getResourceFromBundleSpace(location).getURL());

-		control.verify();

+		verify(mock);

 	}

 

 	/**

@@ -190,19 +189,18 @@
 	 * {@link org.eclipse.gemini.blueprint.io.OsgiBundleResource#getResourceFromBundleClasspath(java.lang.String)}.

 	 */

 	public void testGetResourceFromBundleClasspath() throws Exception {

-		MockControl control = MockControl.createControl(Bundle.class);

-		Bundle mock = (Bundle) control.getMock();

+		Bundle mock = createMock(Bundle.class);

 

 		String location = "file://foo";

 		URL result = new URL(location);

 

-		control.expectAndReturn(mock.getResource(location), result);

-		control.replay();

+		expect(mock.getResource(location)).andReturn(result);

+		replay(mock);

 

 		resource = new OsgiBundleResource(mock, location);

 

 		assertSame(result, resource.getResourceFromBundleClasspath(location));

-		control.verify();

+		verify(mock);

 	}

 

 	/**

diff --git a/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistrationTest.java b/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistrationTest.java
index 79f62ea..4ce397e 100644
--- a/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistrationTest.java
+++ b/mock/src/test/java/org/eclipse/gemini/blueprint/mock/MockServiceRegistrationTest.java
@@ -19,11 +19,10 @@
 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

-import org.eclipse.gemini.blueprint.mock.MockServiceReference;

-import org.eclipse.gemini.blueprint.mock.MockServiceRegistration;

 import org.osgi.framework.ServiceReference;

 

+import static org.easymock.EasyMock.*;

+

 /**

  * @author Costin Leau

  * 

@@ -95,7 +94,7 @@
 		assertNull(mock.getReference().getProperty(key));

 		mock.setProperties(props);

 		assertSame(value, mock.getReference().getProperty(key));

-		mock.setReference((ServiceReference) MockControl.createNiceControl(ServiceReference.class).getMock());

+		mock.setReference(createMock(ServiceReference.class));

 

 		try {

 			mock.setProperties(props);

diff --git a/pom.xml b/pom.xml
index 9e99ffb..2dd3c90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
         <equinox.ver>3.6.2.R36x_v20110210</equinox.ver>
         <!-- Knopflerfish 3.5 -->
         <kf.ver>5.3.3</kf.ver>
-        <felix.ver>2.0.5</felix.ver>
+        <felix.ver>3.2.2</felix.ver>
 
         <!-- javadoc configuration -->
         <javadoc.loc>${basedir}/docs/src/javadoc</javadoc.loc>
@@ -327,10 +327,16 @@
         </dependency>
 
         <dependency>
-            <groupId>easymock</groupId>
+            <groupId>org.easymock</groupId>
             <artifactId>easymock</artifactId>
-            <version>1.2_Java1.3</version>
+            <version>3.2</version>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>cglib</groupId>
+                    <artifactId>cglib-nodep</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -367,33 +373,6 @@
             <artifactId>logback-classic</artifactId>
             <version>${logback.version}</version>
         </dependency>
-
-        <!--<dependency>-->
-            <!--<groupId>org.slf4j</groupId>-->
-            <!--<artifactId>slf4j-log4j12</artifactId>-->
-            <!--<version>${slf4j.version}</version>-->
-            <!--<scope>provided</scope>-->
-            <!--<exclusions>-->
-                <!--<exclusion>-->
-                    <!--<groupId>log4j</groupId>-->
-                    <!--<artifactId>log4j</artifactId>-->
-                <!--</exclusion>-->
-            <!--</exclusions>-->
-        <!--</dependency>-->
-
-        <!--<dependency>-->
-            <!--<groupId>org.apache.log4j</groupId>-->
-            <!--<artifactId>com.springsource.org.apache.log4j</artifactId>-->
-            <!--<version>1.2.16</version>-->
-        <!--</dependency>-->
-
-        <!--<dependency>-->
-            <!--<groupId>log4j</groupId>-->
-            <!--<artifactId>log4j</artifactId>-->
-            <!--<version>1.2.16</version>-->
-            <!--<scope>test</scope>-->
-        <!--</dependency>-->
-
     </dependencies>
 
     <build>
@@ -593,8 +572,9 @@
                             <Bundle-SymbolicName>${spring.osgi.symbolic.name}.source</Bundle-SymbolicName>
                             <Bundle-Vendor>Eclipse Foundation</Bundle-Vendor>
                             <Bundle-DocURL>http://www.eclipse.org/gemini/blueprint/</Bundle-DocURL>
-                            <!--<Bundle-Description>${bundle.description}</Bundle-Description>-->
-                            <Bundle-License>http://www.opensource.org/licenses/eclipse-1.0.php, http://www.opensource.org/licenses/apache2.0.php</Bundle-License>
+                            <Bundle-License>http://www.opensource.org/licenses/eclipse-1.0.php,
+                                http://www.opensource.org/licenses/apache2.0.php
+                            </Bundle-License>
                             <Implementation-Title>Eclipse Gemini Blueprint</Implementation-Title>
                             <Implementation-Version>${project.version}</Implementation-Version>
                             <Implementation-Vendor>Eclipse Foundation</Implementation-Vendor>
@@ -602,7 +582,8 @@
                             <Gemini-Blueprint-Version>${project.version}</Gemini-Blueprint-Version>
                             <Spring-Version>${spring.maven.artifact.version}</Spring-Version>
                             <Git-Revision>${git.commit.id.describe}</Git-Revision>
-                            <Eclipse-SourceBundle>${spring.osgi.symbolic.name};version="${project.version}";roots:="."</Eclipse-SourceBundle>
+                            <Eclipse-SourceBundle>${spring.osgi.symbolic.name};version="${project.version}";roots:="."
+                            </Eclipse-SourceBundle>
                         </manifestEntries>
                     </archive>
                 </configuration>
@@ -869,7 +850,6 @@
             </dependencies>
             <properties>
                 <osgi.test.platform>org.eclipse.gemini.blueprint.test.platform.EquinoxPlatform</osgi.test.platform>
-                <log4j.ignoreTCL>true</log4j.ignoreTCL>
             </properties>
         </profile>
 
@@ -886,7 +866,6 @@
             </dependencies>
             <properties>
                 <osgi.test.platform>org.eclipse.gemini.blueprint.test.platform.KnopflerfishPlatform</osgi.test.platform>
-                <log4j.ignoreTCL>true</log4j.ignoreTCL>
                 <org.knopflerfish.osgi.setcontextclassloader>true</org.knopflerfish.osgi.setcontextclassloader>
             </properties>
         </profile>
@@ -907,30 +886,23 @@
                             <artifactId>org.apache.felix.framework</artifactId>
                         </exclusion>
                         <!--<exclusion>-->
-                            <!--<groupId>org.apache.felix</groupId>-->
-                            <!--<artifactId>org.apache.felix.shell</artifactId>-->
+                        <!--<groupId>org.apache.felix</groupId>-->
+                        <!--<artifactId>org.apache.felix.shell</artifactId>-->
                         <!--</exclusion>-->
                         <!--<exclusion>-->
-                            <!--<groupId>org.apache.felix</groupId>-->
-                            <!--<artifactId>org.apache.felix.shell.tui</artifactId>-->
+                        <!--<groupId>org.apache.felix</groupId>-->
+                        <!--<artifactId>org.apache.felix.shell.tui</artifactId>-->
                         <!--</exclusion>-->
                         <!--<exclusion>-->
-                            <!--<groupId>org.apache.felix</groupId>-->
-                            <!--<artifactId>org.apache.felix.bundlerepository</artifactId>-->
+                        <!--<groupId>org.apache.felix</groupId>-->
+                        <!--<artifactId>org.apache.felix.bundlerepository</artifactId>-->
                         <!--</exclusion>-->
                     </exclusions>
                 </dependency>
-                <!-- include the OSGi jar to allow PermissionAdmin API to be used -->
-                <dependency>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>org.osgi.core</artifactId>
-                    <version>1.0.1</version>
-                    <scope>test</scope>
-                </dependency>
             </dependencies>
             <properties>
                 <osgi.test.platform>org.eclipse.gemini.blueprint.test.platform.FelixPlatform</osgi.test.platform>
-                <log4j.ignoreTCL>true</log4j.ignoreTCL>
+                <!-- <log4j.ignoreTCL>true</log4j.ignoreTCL> -->
             </properties>
         </profile>
 
@@ -1055,6 +1027,12 @@
 
     <repositories>
         <repository>
+            <id>maven-repo</id>
+            <name>maven repo</name>
+            <url>http://repo1.maven.org/maven2/</url>
+        </repository>
+
+        <repository>
             <id>com.springsource.repository.bundles.release</id>
             <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
             <url>http://repository.springsource.com/maven/bundles/release/</url>
diff --git a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/JUnitTestActivatorTest.java b/test-support/src/test/java/org/eclipse/gemini/blueprint/test/JUnitTestActivatorTest.java
index 58984f1..75e9230 100644
--- a/test-support/src/test/java/org/eclipse/gemini/blueprint/test/JUnitTestActivatorTest.java
+++ b/test-support/src/test/java/org/eclipse/gemini/blueprint/test/JUnitTestActivatorTest.java
@@ -15,10 +15,11 @@
 package org.eclipse.gemini.blueprint.test;

 

 import java.lang.reflect.Field;

+import java.util.Dictionary;

 

 import junit.framework.TestCase;

 

-import org.easymock.MockControl;

+import static org.easymock.EasyMock.*;

 import org.eclipse.gemini.blueprint.mock.MockBundleContext;

 import org.eclipse.gemini.blueprint.mock.MockServiceReference;

 import org.eclipse.gemini.blueprint.test.internal.OsgiJUnitTest;

@@ -33,10 +34,6 @@
 

 	private JUnitTestActivator activator;

 

-

-	// private ServiceRegistration registration;

-	// private ServiceReference reference;

-

 	public static class TestExample extends TestCase implements OsgiJUnitTest {

 

 		private static BundleContext context;

@@ -79,65 +76,46 @@
 

 	protected void setUp() throws Exception {

 		activator = new JUnitTestActivator();

-		// reference = new MockServiceReference();

-		// registration = new MockServiceRegistration();

-	}

-

-	protected void tearDown() throws Exception {

-

 	}

 

 	public void testStart() throws Exception {

-		MockControl ctxCtrl = MockControl.createControl(BundleContext.class);

-		BundleContext ctx = (BundleContext) ctxCtrl.getMock();

+		BundleContext ctx = createMock(BundleContext.class);

 

-		MockControl servCtrl = MockControl.createControl(TestRunnerService.class);

-		TestRunnerService runner = (TestRunnerService) servCtrl.getMock();

+		TestRunnerService runner = createMock(TestRunnerService.class);

 

 		ServiceReference ref = new MockServiceReference();

 

-		ctxCtrl.expectAndReturn(ctx.getServiceReference(TestRunnerService.class.getName()), ref);

-		ctxCtrl.expectAndReturn(ctx.getService(ref), runner);

+		expect(ctx.getServiceReference(TestRunnerService.class.getName())).andReturn(ref);

+		expect(ctx.getService(ref)).andReturn(runner);

+		expect(ctx.registerService(anyString(), anyObject(), anyObject(Dictionary.class))).andReturn(null);

 

-		ctx.registerService((String) null, null, null);

-		ctxCtrl.setMatcher(MockControl.ALWAYS_MATCHER);

-		ctxCtrl.setReturnValue(null);

-

-		ctxCtrl.replay();

-		servCtrl.replay();

-

+		replay(ctx, runner);

 		activator.start(ctx);

-

-		ctxCtrl.verify();

+		verify(ctx, runner);

 	}

 

 	public void testStop() throws Exception {

 		ServiceReference ref = new MockServiceReference();

-		MockControl regCtrl = MockControl.createControl(ServiceRegistration.class);

-		ServiceRegistration reg = (ServiceRegistration) regCtrl.getMock();

+		ServiceRegistration reg = createMock(ServiceRegistration.class);

 

-		MockControl ctxCtrl = MockControl.createControl(BundleContext.class);

-		BundleContext ctx = (BundleContext) ctxCtrl.getMock();

+		BundleContext ctx = createMock(BundleContext.class);

 

 		reg.unregister();

+        expectLastCall();

 

-		ctxCtrl.replay();

-		regCtrl.replay();

+		replay(ctx, reg);

 

 		setActivatorField("reference", ref);

 		setActivatorField("registration", reg);

 

 		activator.stop(ctx);

 

-		regCtrl.verify();

-		ctxCtrl.verify();

+		verify(ctx, reg);

 	}

 

 	public void testLoadTest() throws Exception {

 		BundleContext ctx = new MockBundleContext();

-

-		MockControl servCtrl = MockControl.createControl(TestRunnerService.class);

-		TestRunnerService runner = (TestRunnerService) servCtrl.getMock();

+		TestRunnerService runner = createMock(TestRunnerService.class);

 

 		try {

 			activator.executeTest();

@@ -148,22 +126,21 @@
 		}

 

 		setActivatorField("service", runner);

-		runner.runTest(null);

-		servCtrl.setMatcher(MockControl.ALWAYS_MATCHER);

-		servCtrl.replay();

+		runner.runTest(anyObject(OsgiJUnitTest.class));

+        expectLastCall();

+		replay(runner);

 

 		setActivatorField("context", ctx);

 		OsgiTestInfoHolder.INSTANCE.setTestClassName(TestExample.class.getName());

 

 		activator.executeTest();

 		assertSame(ctx, TestExample.context);

-		servCtrl.verify();

+		verify(runner);

 	}

 

 	private void setActivatorField(String fieldName, Object value) throws Exception {

 		Field field = JUnitTestActivator.class.getDeclaredField(fieldName);

 		field.setAccessible(true);

 		field.set(activator, value);

-

 	}

 }