From 69486db2214f497c8857e7b544869bad3e63eedd Mon Sep 17 00:00:00 2001 From: slewis Date: Fri, 28 Mar 2014 07:24:26 -0700 Subject: Added NoRegistryContainerFactoryTest Change-Id: I6c61a6fbe4ab018c15ab1d1d8c8b16b7d3fb5e48 --- .../tests/core/NoRegistryContainerFactoryTest.java | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/NoRegistryContainerFactoryTest.java (limited to 'tests') diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/NoRegistryContainerFactoryTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/NoRegistryContainerFactoryTest.java new file mode 100644 index 000000000..ca5eb6e6b --- /dev/null +++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/NoRegistryContainerFactoryTest.java @@ -0,0 +1,65 @@ +package org.eclipse.ecf.tests.core; + +import junit.framework.TestCase; + +import org.eclipse.ecf.core.BaseContainer; +import org.eclipse.ecf.core.ContainerCreateException; +import org.eclipse.ecf.core.ContainerTypeDescription; +import org.eclipse.ecf.core.IContainer; +import org.eclipse.ecf.core.IContainerFactory; +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.core.provider.IContainerInstantiator; +import org.eclipse.ecf.internal.tests.core.Activator; +import org.osgi.framework.ServiceRegistration; + +public class NoRegistryContainerFactoryTest extends TestCase { + + static class TestContainer extends BaseContainer { + public TestContainer(ID id) { + super(id); + } + } + protected ContainerTypeDescription createContainerTypeDescription() { + return new ContainerTypeDescription(getClass().getName(),new IContainerInstantiator() { + + public IContainer createInstance( + ContainerTypeDescription description, Object[] parameters) + throws ContainerCreateException { + return new TestContainer(IDFactory.getDefault().createGUID()); + } + + public String[] getSupportedAdapterTypes( + ContainerTypeDescription description) { + return null; + } + + public Class[][] getSupportedParameterTypes( + ContainerTypeDescription description) { + return null; + } + + public String[] getSupportedIntents( + ContainerTypeDescription description) { + return null; + }}); + } + + private ServiceRegistration r; + + protected void setUp() throws Exception { + super.setUp(); + r = Activator.getContext().registerService(ContainerTypeDescription.class, createContainerTypeDescription(), null); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if (r != null) r.unregister(); + } + + public void testCreateContainer() throws Exception { + IContainerFactory f = Activator.getDefault().getContainerFactory(); + IContainer c = f.createContainer(getClass().getName()); + assertNotNull(c); + } +} -- cgit v1.2.3