diff options
author | slewis | 2014-03-31 21:40:59 +0000 |
---|---|---|
committer | slewis | 2014-03-31 21:40:59 +0000 |
commit | fe468456cfaab2707823d1587b2782d7086c2bc4 (patch) | |
tree | f98699305c284a2ac12a1c6dbe5e04809bfa6b78 /tests/bundles/org.eclipse.ecf.tests.core | |
parent | 27f62a65e46f9d1492a7ef0e31206b0465e89377 (diff) | |
parent | 8caf8c2de33df197a3416b48c7bb04efa71aa018 (diff) | |
download | org.eclipse.ecf-fe468456cfaab2707823d1587b2782d7086c2bc4.tar.gz org.eclipse.ecf-fe468456cfaab2707823d1587b2782d7086c2bc4.tar.xz org.eclipse.ecf-fe468456cfaab2707823d1587b2782d7086c2bc4.zip |
Merge remote-tracking branch 'origin/master' into rfc1.1
Conflicts:
examples/bundles/com.mycorp.examples.timeservice.consumer.filediscovery/launch/TimeServiceConsumer.launch
Change-Id: Ib83f0393403af7d629aa6cbffe731b5b251eaf3b
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests.core')
3 files changed, 121 insertions, 1 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java index 1f0265e51..259d32748 100644 --- a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java +++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java @@ -23,6 +23,11 @@ public class Activator implements BundleActivator { private static ServiceTracker containerManagerServiceTracker; + private static BundleContext context; + + public static BundleContext getContext() { + return context; + } /** * The constructor */ @@ -35,8 +40,9 @@ public class Activator implements BundleActivator { * @see * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ - public void start(BundleContext context) throws Exception { + public void start(BundleContext ctxt) throws Exception { plugin = this; + context = ctxt; idFactoryServiceTracker = new ServiceTracker(context, IIDFactory.class.getName(), null); idFactoryServiceTracker.open(); 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); + } +} diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NoRegistryNamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NoRegistryNamespaceTest.java new file mode 100644 index 000000000..9d6c9f117 --- /dev/null +++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NoRegistryNamespaceTest.java @@ -0,0 +1,49 @@ +package org.eclipse.ecf.tests.core.identity; + +import org.eclipse.ecf.core.identity.ID; +import org.eclipse.ecf.core.identity.IDCreateException; +import org.eclipse.ecf.core.identity.IDFactory; +import org.eclipse.ecf.core.identity.Namespace; +import org.eclipse.ecf.internal.tests.core.Activator; +import org.osgi.framework.ServiceRegistration; + +import junit.framework.TestCase; + +public class NoRegistryNamespaceTest extends TestCase { + + protected Namespace createNamespace() { + Namespace namespace = new Namespace(this.getClass().getName(), + null) { + private static final long serialVersionUID = -1223105025297785358L; + + public ID createInstance(Object[] args) throws IDCreateException { + throw new IDCreateException("can't create instance"); + } + public String getScheme() { + return getClass().getName(); + } + public Class[][] getSupportedParameterTypes() { + return new Class[][] { { String.class } }; + } + }; + return namespace; + } + + private ServiceRegistration r; + + protected void setUp() throws Exception { + super.setUp(); + r = Activator.getContext().registerService(Namespace.class, createNamespace(), null); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if (r != null) r.unregister(); + } + + public void testGetNamespace() throws Exception { + Namespace n = IDFactory.getDefault().getNamespaceByName(this.getClass().getName()); + assertNotNull(n); + assertTrue(n.getName().equals(getClass().getName())); + } +} |