Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-02-08 00:13:37 -0500
committerslewis2014-02-08 00:13:37 -0500
commit59f17aa21059ca57c8c02d7bdded3258f14bd3c9 (patch)
tree3ed0d64bc1c19b63189dc2732b6ffbb759e3ec3a
parent8d181086f316af76249dd28a584b1b378312ae03 (diff)
downloadorg.eclipse.ecf-59f17aa21059ca57c8c02d7bdded3258f14bd3c9.tar.gz
org.eclipse.ecf-59f17aa21059ca57c8c02d7bdded3258f14bd3c9.tar.xz
org.eclipse.ecf-59f17aa21059ca57c8c02d7bdded3258f14bd3c9.zip
Added org.eclipse.ecf.tests.core test plugin
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/.classpath7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/.gitignore1
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/.project28
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.pde.core.prefs3
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/META-INF/MANIFEST.MF17
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/build.properties4
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/org.eclipse.ecf.tests.core.launch44
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java100
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java81
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java278
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java91
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java81
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java268
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java91
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java199
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java88
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java116
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java50
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java27
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java27
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java78
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java133
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java126
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java126
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java99
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/Base64Test.java38
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java65
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java45
29 files changed, 2322 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/.classpath b/tests/bundles/org.eclipse.ecf.tests.core/.classpath
new file mode 100644
index 000000000..2fbb7a23e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/.gitignore b/tests/bundles/org.eclipse.ecf.tests.core/.gitignore
new file mode 100644
index 000000000..5e56e040e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/.project b/tests/bundles/org.eclipse.ecf.tests.core/.project
new file mode 100644
index 000000000..4cb233043
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.jdt.core.prefs b/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..356841523
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.pde.core.prefs b/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..f29e940a0
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.core/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..798aa9e7e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Core Tests
+Bundle-SymbolicName: org.eclipse.ecf.tests.core
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.ecf.internal.tests.core.Activator
+Bundle-Vendor: Eclipse.org - ECF
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Import-Package: org.osgi.framework;version="1.3.0",
+ org.osgi.util.tracker;version="1.5.1"
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.ecf;bundle-version="3.3.0",
+ org.junit;bundle-version="4.11.0",
+ org.eclipse.equinox.common;bundle-version="3.6.200",
+ org.eclipse.ecf.tests;bundle-version="2.1.0"
+Export-Package: org.eclipse.ecf.tests.core.identity;x-internal:=true,
+ org.eclipse.ecf.tests.core.util;x-internal:=true
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/build.properties b/tests/bundles/org.eclipse.ecf.tests.core/build.properties
new file mode 100644
index 000000000..34d2e4d2d
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/org.eclipse.ecf.tests.core.launch b/tests/bundles/org.eclipse.ecf.tests.core/org.eclipse.ecf.tests.core.launch
new file mode 100644
index 000000000..124ab5065
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/org.eclipse.ecf.tests.core.launch
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="true"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.ecf.tests.core"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.ecf.tests.core"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.tests.core"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx512m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="false"/>
+</launchConfiguration>
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
new file mode 100644
index 000000000..1f0265e51
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/internal/tests/core/Activator.java
@@ -0,0 +1,100 @@
+package org.eclipse.ecf.internal.tests.core;
+
+import org.eclipse.ecf.core.IContainerFactory;
+import org.eclipse.ecf.core.IContainerManager;
+import org.eclipse.ecf.core.identity.IIDFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.ecf.tests.core";
+
+ // The shared instance
+ private static Activator plugin;
+
+ private static ServiceTracker idFactoryServiceTracker;
+ private static IIDFactory idFactory;
+
+ private static ServiceTracker containerFactoryServiceTracker;
+ private static IContainerFactory containerFactory;
+
+ private static ServiceTracker containerManagerServiceTracker;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ plugin = this;
+ idFactoryServiceTracker = new ServiceTracker(context,
+ IIDFactory.class.getName(), null);
+ idFactoryServiceTracker.open();
+ idFactory = (IIDFactory) idFactoryServiceTracker.getService();
+ containerFactoryServiceTracker = new ServiceTracker(context,
+ IContainerFactory.class.getName(), null);
+ containerFactoryServiceTracker.open();
+ containerFactory = (IContainerFactory) containerFactoryServiceTracker
+ .getService();
+ containerManagerServiceTracker = new ServiceTracker(context,
+ IContainerManager.class.getName(), null);
+ containerManagerServiceTracker.open();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ if (idFactoryServiceTracker != null) {
+ idFactoryServiceTracker.close();
+ idFactoryServiceTracker = null;
+ }
+ if (containerFactoryServiceTracker != null) {
+ containerFactoryServiceTracker.close();
+ containerFactoryServiceTracker = null;
+ }
+ if (containerManagerServiceTracker != null) {
+ containerManagerServiceTracker.close();
+ containerManagerServiceTracker = null;
+ }
+ plugin = null;
+ idFactory = null;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public IIDFactory getIDFactory() {
+ return idFactory;
+ }
+
+ public IContainerFactory getContainerFactory() {
+ return containerFactory;
+ }
+
+ /**
+ * @return container manager.
+ */
+ public IContainerManager getContainerManager() {
+ return (IContainerManager) containerManagerServiceTracker.getService();
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java
new file mode 100644
index 000000000..27ffd1ab0
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerFactory;
+import org.eclipse.ecf.core.provider.IContainerInstantiator;
+
+public abstract class ContainerFactoryAbstractTestCase extends TestCase {
+
+ protected static final String DESCRIPTION = "description";
+
+ private IContainerFactory fixture;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = ContainerFactory.getDefault();
+ assertNotNull(fixture);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fixture = null;
+ }
+
+ protected IContainerFactory getFixture() {
+ return fixture;
+ }
+
+ protected ContainerTypeDescription createContainerTypeDescription() {
+ return new ContainerTypeDescription(this.getClass().getName(),
+ new IContainerInstantiator() {
+ public IContainer createInstance(
+ ContainerTypeDescription description,
+ Object[] parameters)
+ throws ContainerCreateException {
+ throw new ContainerCreateException();
+ }
+
+ public String[] getSupportedAdapterTypes(
+ ContainerTypeDescription description) {
+ return null;
+ }
+
+ public Class[][] getSupportedParameterTypes(
+ ContainerTypeDescription description) {
+ return null;
+ }
+
+ public String[] getSupportedIntents(
+ ContainerTypeDescription description) {
+ return null;
+ }
+ }, DESCRIPTION);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java
new file mode 100644
index 000000000..0aca3c40a
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java
@@ -0,0 +1,278 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import java.util.Arrays;
+
+import org.eclipse.ecf.core.AbstractContainer;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.provider.IContainerInstantiator;
+import org.eclipse.ecf.core.security.IConnectContext;
+
+public class ContainerFactoryCreateTest extends
+ ContainerFactoryAbstractTestCase {
+
+ private static final String INTENTTWO = "intenttwo";
+
+ private static final String INTENTONE = "intentone";
+
+ protected static final String CONTAINER_TYPE_NAME = ContainerFactoryCreateTest.class
+ .getName();
+
+ protected static final String BASE_CONTAINER_TYPE_NAME = "ecf.base";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ getFixture().addDescription(createContainerTypeDescription());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ getFixture().removeDescription(createContainerTypeDescription());
+ super.tearDown();
+ }
+
+ protected ContainerTypeDescription createContainerTypeDescription() {
+ return new ContainerTypeDescription(CONTAINER_TYPE_NAME,
+ new IContainerInstantiator() {
+ public IContainer createInstance(
+ ContainerTypeDescription description,
+ Object[] parameters)
+ throws ContainerCreateException {
+ return new AbstractContainer() {
+ public void connect(ID targetID,
+ IConnectContext connectContext)
+ throws ContainerConnectException {
+ }
+
+ public void disconnect() {
+ }
+
+ public Namespace getConnectNamespace() {
+ return null;
+ }
+
+ public ID getConnectedID() {
+ return null;
+ }
+
+ public ID getID() {
+ return null;
+ }
+
+ };
+ }
+
+ public String[] getSupportedAdapterTypes(
+ ContainerTypeDescription description) {
+ return new String[] { "one" };
+ }
+
+ public Class[][] getSupportedParameterTypes(
+ ContainerTypeDescription description) {
+ return new Class[][] { { String.class, Class.class } };
+ }
+
+ public String[] getSupportedIntents(
+ ContainerTypeDescription description) {
+ return new String[] { INTENTONE, INTENTTWO };
+ }
+ }, DESCRIPTION);
+ }
+
+ public void testCreateContainer1() throws Exception {
+ try {
+ ContainerFactory.getDefault().createContainer("bogus");
+ fail();
+ } catch (Exception e) {
+
+ }
+ }
+
+ public void testCreateContainer2() throws Exception {
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(CONTAINER_TYPE_NAME);
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer3() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(desc);
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer4() throws Exception {
+ try {
+ ContainerFactory.getDefault().createContainer((String) null,
+ (Object[]) null);
+ fail();
+ } catch (final ContainerCreateException e) {
+ }
+ }
+
+ public void testCreateContainer5() throws Exception {
+ try {
+ ContainerFactory.getDefault().createContainer(
+ (ContainerTypeDescription) null);
+ fail();
+ } catch (final ContainerCreateException e) {
+ }
+ }
+
+ public void testCreateContainer6() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(desc, IDFactory.getDefault().createGUID());
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer7() throws Exception {
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(CONTAINER_TYPE_NAME,
+ IDFactory.getDefault().createGUID());
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer8() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(desc, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer9() throws Exception {
+ final IContainer container = ContainerFactory.getDefault()
+ .createContainer(CONTAINER_TYPE_NAME,
+ IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(container);
+ }
+
+ public void testCreateBadContainer() throws Exception {
+ try {
+ ContainerFactory.getDefault().createContainer(
+ "asdfasdfasdfsadfsadf");
+ fail();
+ } catch (ContainerCreateException e) {
+ }
+ }
+
+ public void testCreateBaseContainer0() throws Exception {
+ final IContainer base = ContainerFactory.getDefault().createContainer();
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer1() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ desc, IDFactory.getDefault().createGUID());
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer2() throws Exception {
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ BASE_CONTAINER_TYPE_NAME, IDFactory.getDefault().createGUID());
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer3() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ desc,
+ new Object[] { IDFactory.getDefault().createGUID().getName() });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer4() throws Exception {
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ BASE_CONTAINER_TYPE_NAME,
+ new Object[] { IDFactory.getDefault().createGUID() });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer5() throws Exception {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ desc, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer6() throws Exception {
+ final IContainer base = ContainerFactory.getDefault().createContainer(
+ BASE_CONTAINER_TYPE_NAME, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(base);
+ }
+
+ public void testContainerTypeDescriptionGetName() {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertTrue(desc.getName().equals(CONTAINER_TYPE_NAME));
+ }
+
+ public void testContainerTypeDescriptionGetDescription() {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertTrue(desc.getDescription().equals(DESCRIPTION));
+ }
+
+ public void testContainerTypeDescriptionGetSupportedAdapterTypes() {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ final String[] adapterTypes = desc.getSupportedAdapterTypes();
+ assertTrue(adapterTypes.length > 0);
+ assertTrue(Arrays.asList(adapterTypes).contains("one"));
+ }
+
+ public void testContainerTypeDescriptionGetSupportedParemeterTypes() {
+ final ContainerTypeDescription desc = ContainerFactory.getDefault()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ final Class[][] parameterTypes = desc.getSupportedParameterTypes();
+ assertTrue(parameterTypes.length == 1);
+ assertTrue(parameterTypes[0].length == 2);
+ assertTrue(parameterTypes[0][0].equals(String.class));
+ assertTrue(parameterTypes[0][1].equals(Class.class));
+
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java
new file mode 100644
index 000000000..7a4e8fbbc
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import java.util.List;
+
+import org.eclipse.ecf.core.ContainerTypeDescription;
+
+public class ContainerFactoryDescriptionsTest extends
+ ContainerFactoryAbstractTestCase {
+
+ private ContainerTypeDescription description;
+
+ protected ContainerTypeDescription getDescription() {
+ return description;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ addDescription();
+ }
+
+ protected void addDescription() {
+ description = createContainerTypeDescription();
+ ContainerTypeDescription add = getFixture().addDescription(description);
+ assertNull(add);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ removeDescription();
+ super.tearDown();
+ }
+
+ protected void removeDescription() {
+ ContainerTypeDescription remove = getFixture().removeDescription(
+ getDescription());
+ assertNotNull(remove);
+ }
+
+ public void testGetDescriptions() {
+ List d = getFixture().getDescriptions();
+ assertNotNull(d);
+ }
+
+ public void testAddNullDescription() {
+ int prevSize = getFixture().getDescriptions().size();
+ ContainerTypeDescription add = getFixture().addDescription(null);
+ assertNull(add);
+ assertTrue(getFixture().getDescriptions().size() == prevSize);
+ }
+
+ public void testContainsDescription() {
+ assertTrue(getFixture().containsDescription(getDescription()));
+ }
+
+ public void testGetDescriptionByName() {
+ ContainerTypeDescription desc = getFixture().getDescriptionByName(
+ getDescription().getName());
+ assertNotNull(desc);
+ }
+
+ public void testCreateContainer() {
+ try {
+ getFixture().createContainer(getDescription().getName());
+ fail();
+ } catch (Exception e) {
+
+ }
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java
new file mode 100644
index 000000000..c51e6a3db
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import junit.framework.TestCase;
+
+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.provider.IContainerInstantiator;
+import org.eclipse.ecf.internal.tests.core.Activator;
+
+public abstract class ContainerFactoryServiceAbstractTestCase extends TestCase {
+
+ protected static final String DESCRIPTION = "description";
+
+ private IContainerFactory fixture;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = Activator.getDefault().getContainerFactory();
+ assertNotNull(fixture);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fixture = null;
+ }
+
+ protected IContainerFactory getFixture() {
+ return fixture;
+ }
+
+ protected ContainerTypeDescription createContainerTypeDescription() {
+ return new ContainerTypeDescription(this.getClass().getName(),
+ new IContainerInstantiator() {
+ public IContainer createInstance(
+ ContainerTypeDescription description,
+ Object[] parameters)
+ throws ContainerCreateException {
+ throw new ContainerCreateException();
+ }
+
+ public String[] getSupportedAdapterTypes(
+ ContainerTypeDescription description) {
+ return null;
+ }
+
+ public Class[][] getSupportedParameterTypes(
+ ContainerTypeDescription description) {
+ return null;
+ }
+
+ public String[] getSupportedIntents(
+ ContainerTypeDescription description) {
+ return null;
+ }
+ }, DESCRIPTION);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java
new file mode 100644
index 000000000..85333f356
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java
@@ -0,0 +1,268 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import java.util.Arrays;
+
+import org.eclipse.ecf.core.AbstractContainer;
+import org.eclipse.ecf.core.ContainerConnectException;
+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.identity.Namespace;
+import org.eclipse.ecf.core.provider.IContainerInstantiator;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.internal.tests.core.Activator;
+
+public class ContainerFactoryServiceCreateTest extends
+ ContainerFactoryServiceAbstractTestCase {
+
+ protected static final String CONTAINER_TYPE_NAME = ContainerFactoryServiceCreateTest.class
+ .getName();
+
+ protected static final String BASE_CONTAINER_TYPE_NAME = "ecf.base";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ getFixture().addDescription(createContainerTypeDescription());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ getFixture().removeDescription(createContainerTypeDescription());
+ super.tearDown();
+ }
+
+ protected IContainerFactory getContainerFactoryService() {
+ return Activator.getDefault().getContainerFactory();
+ }
+
+ protected ContainerTypeDescription createContainerTypeDescription() {
+ return new ContainerTypeDescription(CONTAINER_TYPE_NAME,
+ new IContainerInstantiator() {
+ public IContainer createInstance(
+ ContainerTypeDescription description,
+ Object[] parameters)
+ throws ContainerCreateException {
+ return new AbstractContainer() {
+ public void connect(ID targetID,
+ IConnectContext connectContext)
+ throws ContainerConnectException {
+ }
+
+ public void disconnect() {
+ }
+
+ public Namespace getConnectNamespace() {
+ return null;
+ }
+
+ public ID getConnectedID() {
+ return null;
+ }
+
+ public ID getID() {
+ return null;
+ }
+
+ };
+ }
+
+ public String[] getSupportedAdapterTypes(
+ ContainerTypeDescription description) {
+ return new String[] { "one" };
+ }
+
+ public Class[][] getSupportedParameterTypes(
+ ContainerTypeDescription description) {
+ return new Class[][] { { String.class, Class.class } };
+ }
+
+ public String[] getSupportedIntents(
+ ContainerTypeDescription description) {
+ return null;
+ }
+ }, DESCRIPTION);
+ }
+
+ public void testCreateContainer1() throws Exception {
+ final IContainer container = getContainerFactoryService()
+ .createContainer(CONTAINER_TYPE_NAME);
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer2() throws Exception {
+ final IContainer container = getContainerFactoryService()
+ .createContainer(CONTAINER_TYPE_NAME);
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer3() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = getContainerFactoryService()
+ .createContainer(desc);
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer4() throws Exception {
+ try {
+ getContainerFactoryService().createContainer((String) null,
+ (Object[]) null);
+ fail();
+ } catch (final ContainerCreateException e) {
+ }
+ }
+
+ public void testCreateContainer5() throws Exception {
+ try {
+ getContainerFactoryService().createContainer(
+ (ContainerTypeDescription) null);
+ fail();
+ } catch (final ContainerCreateException e) {
+ }
+ }
+
+ public void testCreateContainer6() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = getContainerFactoryService()
+ .createContainer(desc, IDFactory.getDefault().createGUID());
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer7() throws Exception {
+ final IContainer container = getContainerFactoryService()
+ .createContainer(CONTAINER_TYPE_NAME,
+ IDFactory.getDefault().createGUID());
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer8() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer container = getContainerFactoryService()
+ .createContainer(desc, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(container);
+ }
+
+ public void testCreateContainer9() throws Exception {
+ final IContainer container = getContainerFactoryService()
+ .createContainer(CONTAINER_TYPE_NAME,
+ IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(container);
+ }
+
+ public void testCreateBaseContainer0() throws Exception {
+ final IContainer base = getContainerFactoryService().createContainer();
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer1() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = getContainerFactoryService().createContainer(
+ desc, IDFactory.getDefault().createGUID());
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer2() throws Exception {
+ final IContainer base = getContainerFactoryService().createContainer(
+ BASE_CONTAINER_TYPE_NAME, IDFactory.getDefault().createGUID());
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer3() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = getContainerFactoryService().createContainer(
+ desc,
+ new Object[] { IDFactory.getDefault().createGUID().getName() });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer4() throws Exception {
+ final IContainer base = getContainerFactoryService().createContainer(
+ BASE_CONTAINER_TYPE_NAME,
+ new Object[] { IDFactory.getDefault().createGUID() });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer5() throws Exception {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(BASE_CONTAINER_TYPE_NAME);
+ assertNotNull(desc);
+ final IContainer base = getContainerFactoryService().createContainer(
+ desc, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(base);
+ }
+
+ public void testCreateBaseContainer6() throws Exception {
+ final IContainer base = getContainerFactoryService().createContainer(
+ BASE_CONTAINER_TYPE_NAME, IDFactory.getDefault().createGUID(),
+ new Object[] { "param" });
+ assertNotNull(base);
+ }
+
+ public void testContainerTypeDescriptionGetName() {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertTrue(desc.getName().equals(CONTAINER_TYPE_NAME));
+ }
+
+ public void testContainerTypeDescriptionGetDescription() {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ assertTrue(desc.getDescription().equals(DESCRIPTION));
+ }
+
+ public void testContainerTypeDescriptionGetSupportedAdapterTypes() {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ final String[] adapterTypes = desc.getSupportedAdapterTypes();
+ assertTrue(adapterTypes.length > 0);
+ assertTrue(Arrays.asList(adapterTypes).contains("one"));
+ }
+
+ public void testContainerTypeDescriptionGetSupportedParemeterTypes() {
+ final ContainerTypeDescription desc = getContainerFactoryService()
+ .getDescriptionByName(CONTAINER_TYPE_NAME);
+ final Class[][] parameterTypes = desc.getSupportedParameterTypes();
+ assertTrue(parameterTypes.length == 1);
+ assertTrue(parameterTypes[0].length == 2);
+ assertTrue(parameterTypes[0][0].equals(String.class));
+ assertTrue(parameterTypes[0][1].equals(Class.class));
+
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java
new file mode 100644
index 000000000..474507b58
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import java.util.List;
+
+import org.eclipse.ecf.core.ContainerTypeDescription;
+
+public class ContainerFactoryServiceDescriptionsTest extends
+ ContainerFactoryServiceAbstractTestCase {
+
+ private ContainerTypeDescription description;
+
+ protected ContainerTypeDescription getDescription() {
+ return description;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ addDescription();
+ }
+
+ protected void addDescription() {
+ description = createContainerTypeDescription();
+ ContainerTypeDescription add = getFixture().addDescription(description);
+ assertNull(add);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ removeDescription();
+ super.tearDown();
+ }
+
+ protected void removeDescription() {
+ ContainerTypeDescription remove = getFixture().removeDescription(
+ getDescription());
+ assertNotNull(remove);
+ }
+
+ public void testGetDescriptions() {
+ List d = getFixture().getDescriptions();
+ assertNotNull(d);
+ }
+
+ public void testAddNullDescription() {
+ int prevSize = getFixture().getDescriptions().size();
+ ContainerTypeDescription add = getFixture().addDescription(null);
+ assertNull(add);
+ assertTrue(getFixture().getDescriptions().size() == prevSize);
+ }
+
+ public void testContainsDescription() {
+ assertTrue(getFixture().containsDescription(getDescription()));
+ }
+
+ public void testGetDescriptionByName() {
+ ContainerTypeDescription desc = getFixture().getDescriptionByName(
+ getDescription().getName());
+ assertNotNull(desc);
+ }
+
+ public void testCreateContainer() {
+ try {
+ getFixture().createContainer(getDescription().getName());
+ fail();
+ } catch (Exception e) {
+
+ }
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java
new file mode 100644
index 000000000..0a69c634f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java
@@ -0,0 +1,199 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core;
+
+import org.eclipse.ecf.core.AbstractContainer;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerManager;
+import org.eclipse.ecf.core.IContainerManagerListener;
+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.core.provider.IContainerInstantiator;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.internal.tests.core.Activator;
+
+public class ContainerManagerServiceTest extends
+ ContainerFactoryServiceAbstractTestCase {
+
+ protected static final String CONTAINER_TYPE_NAME = ContainerManagerServiceTest.class
+ .getName();
+
+ private IContainerManager containerManager = null;
+
+ private IContainerManagerListener containerManagerListener = new IContainerManagerListener() {
+
+ public void containerAdded(IContainer container) {
+ System.out.println("containerAdded(" + container + ")");
+ }
+
+ public void containerRemoved(IContainer container) {
+ System.out.println("containerRemoved(" + container + ")");
+ }
+ };
+
+ protected IContainer[] createContainers(int length) throws Exception {
+ IContainer[] result = new IContainer[length];
+ for (int i = 0; i < length; i++) {
+ result[i] = Activator.getDefault().getContainerFactory()
+ .createContainer();
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ getFixture().addDescription(createContainerTypeDescription());
+ containerManager = Activator.getDefault().getContainerManager();
+ containerManager.addListener(containerManagerListener);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ecf.tests.core.ContainerFactoryAbstractTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ getFixture().removeDescription(createContainerTypeDescription());
+ containerManager.removeListener(containerManagerListener);
+ containerManager = null;
+ super.tearDown();
+ }
+
+ protected ContainerTypeDescription createContainerTypeDescription() {
+ return new ContainerTypeDescription(CONTAINER_TYPE_NAME,
+ new IContainerInstantiator() {
+ public IContainer createInstance(
+ ContainerTypeDescription description,
+ Object[] parameters)
+ throws ContainerCreateException {
+ return new AbstractContainer() {
+
+ protected ID id = null;
+
+ public void connect(ID targetID,
+ IConnectContext connectContext)
+ throws ContainerConnectException {
+ }
+
+ public void disconnect() {
+ }
+
+ public Namespace getConnectNamespace() {
+ return null;
+ }
+
+ public ID getConnectedID() {
+ return null;
+ }
+
+ public ID getID() {
+ if (id == null) {
+ try {
+ id = IDFactory.getDefault()
+ .createGUID();
+ } catch (IDCreateException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return id;
+ }
+
+ };
+ }
+
+ public String[] getSupportedAdapterTypes(
+ ContainerTypeDescription description) {
+ return new String[] { "one" };
+ }
+
+ public Class[][] getSupportedParameterTypes(
+ ContainerTypeDescription description) {
+ return new Class[][] { { String.class, Class.class } };
+ }
+
+ public String[] getSupportedIntents(
+ ContainerTypeDescription description) {
+ return null;
+ }
+ }, DESCRIPTION);
+ }
+
+ public void testGetContainerManager() throws Exception {
+ assertNotNull(containerManager);
+ }
+
+ public void testGetContainersOne() throws Exception {
+ IContainer[] c = createContainers(1);
+ assertNotNull(c);
+ IContainer[] containers = containerManager.getAllContainers();
+ assertNotNull(containers);
+ // assertTrue(containers.length == 1);
+ }
+
+ public void testGetContainerOne() throws Exception {
+ IContainer[] c = createContainers(1);
+ assertNotNull(c);
+ IContainer container = containerManager.getContainer(c[0].getID());
+ assertNotNull(container);
+ assertTrue(container.getID().equals(c[0].getID()));
+ }
+
+ public void testGetContainerN() throws Exception {
+ IContainer[] c = createContainers(10);
+ assertNotNull(c);
+ for (int i = 0; i < 10; i++) {
+ IContainer container = containerManager.getContainer(c[i].getID());
+ assertNotNull(container);
+ assertTrue(container.getID().equals(c[i].getID()));
+ }
+ }
+
+ public void testHasContainerN() throws Exception {
+ IContainer[] c = createContainers(10);
+ assertNotNull(c);
+ for (int i = 0; i < 10; i++) {
+ assertTrue(containerManager.hasContainer(c[i].getID()));
+ }
+ }
+
+ public void testGetContainerDescriptionN() throws Exception {
+ IContainer[] c = createContainers(10);
+ assertNotNull(c);
+ for (int i = 0; i < 10; i++) {
+ ContainerTypeDescription description = containerManager
+ .getContainerTypeDescription(c[i].getID());
+ assertNotNull(description);
+ }
+ }
+
+ public void testClearContainers() throws Exception {
+ IContainer[] c = createContainers(10);
+ assertNotNull(c);
+ containerManager.removeAllContainers();
+ IContainer[] cs = containerManager.getAllContainers();
+ assertTrue(cs != null);
+ assertTrue(cs.length == 0);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java
new file mode 100644
index 000000000..4d73f11ec
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java
@@ -0,0 +1,88 @@
+package org.eclipse.ecf.tests.core;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerFactory;
+import org.eclipse.ecf.tests.ContainerAbstractTestCase;
+
+public class GenericServerCreateTest extends ContainerAbstractTestCase {
+
+ private IContainerFactory containerFactory;
+ private IContainer container;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ containerFactory = ContainerFactory.getDefault();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (container != null) {
+ container.disconnect();
+ container.dispose();
+ removeFromContainerManager(container);
+ }
+ containerFactory = null;
+ }
+
+ public void testServerCreateParam1() throws Exception {
+ String id = getServerIdentity();
+ container = containerFactory.createContainer(getServerContainerName(),
+ new Object[] { id });
+ assertNotNull(container);
+ assertEquals(id, container.getID().getName());
+ }
+
+ public void testServerCreateParam2() throws Exception {
+ container = containerFactory.createContainer(getServerContainerName());
+ assertNotNull(container);
+ }
+
+ public void testServerCreateMapParam1() throws Exception {
+ String serverId = getServerIdentity();
+ Map map = new HashMap();
+ map.put("id", serverId);
+ container = containerFactory.createContainer(getServerContainerName(),
+ map);
+ assertNotNull(container);
+ }
+
+ public void testServerCreateMapParam2() throws Exception {
+ Map map = new HashMap();
+ map.put("hostname", "localhost");
+ map.put("port", "" + genericServerPort);
+ map.put("path", "/foo");
+ container = containerFactory.createContainer(getServerContainerName(),
+ map);
+ assertNotNull(container);
+ }
+
+ public void testServerCreateMapParam3() throws Exception {
+ String serverId = getServerIdentity();
+ Map map = new HashMap();
+ map.put("id", serverId);
+ map.put("bindAddress",
+ new InetSocketAddress((InetAddress) null, 0).getAddress());
+ container = containerFactory.createContainer(getServerContainerName(),
+ map);
+ assertNotNull(container);
+ }
+
+ public void testServerCreateMapParam1Fail() throws Exception {
+ Map map = new HashMap();
+ // bogus port
+ map.put("port", new Object());
+ try {
+ containerFactory.createContainer(getServerContainerName(), map);
+ fail("create with map=" + map + " succeeded");
+ } catch (ContainerCreateException e) {
+ // succeed
+ }
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java
new file mode 100644
index 000000000..c1a32a90c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.tests.core.identity;
+
+import java.io.ByteArrayOutputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+
+import org.eclipse.ecf.core.identity.GUID;
+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;
+
+public class GUIDTest extends IDAbstractTestCase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.IDTestCase#createID()
+ */
+ protected ID createID() throws IDCreateException {
+ return createGUID(GUID.DEFAULT_BYTE_LENGTH);
+ }
+
+ protected ID createGUID(int length) throws IDCreateException {
+ return IDFactory.getDefault().createGUID(length);
+ }
+
+ public void testCreate() throws Exception {
+ final ID newID = createID();
+ assertNotNull(newID);
+ }
+
+ public void testCreateLong() throws Exception {
+ final ID newID = createGUID(40);
+ assertNotNull(newID);
+ }
+
+ public void testGetName() throws Exception {
+ final ID id = createID();
+ assertNotNull(id.getName());
+ }
+
+ public void testToExternalForm() throws Exception {
+ final ID id = createID();
+ assertNotNull(id.toExternalForm());
+ }
+
+ public void testToString() throws Exception {
+ final ID id = createID();
+ assertNotNull(id.toString());
+ }
+
+ public void testNotEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertFalse(id1.equals(id2));
+ }
+
+ public void testHashCode() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.hashCode() != id2.hashCode());
+ }
+
+ public void testCompareToNotEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.compareTo(id2) != 0);
+ assertTrue(id2.compareTo(id1) != 0);
+ }
+
+ public void testGetNamespace() throws Exception {
+ final ID id = createID();
+ final Namespace ns = id.getNamespace();
+ assertNotNull(ns);
+ }
+
+ public void testEqualNamespaces() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ final Namespace ns1 = id1.getNamespace();
+ final Namespace ns2 = id2.getNamespace();
+ assertTrue(ns1.equals(ns2));
+ assertTrue(ns2.equals(ns2));
+ }
+
+ public void testSerializable() throws Exception {
+ final ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buf);
+ try {
+ out.writeObject(createID());
+ } catch (final NotSerializableException ex) {
+ fail(ex.getLocalizedMessage());
+ } finally {
+ out.close();
+ }
+ }
+
+ public void testCreateFromExternalForm() throws Exception {
+ final ID id1 = createID();
+ final String externalForm = id1.toExternalForm();
+ final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(),
+ externalForm);
+ assertTrue(id1.equals(id2));
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java
new file mode 100644
index 000000000..310c0ba12
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java
@@ -0,0 +1,50 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core.identity;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDCreateException;
+
+public abstract class IDAbstractTestCase extends TestCase {
+
+ private ID fixture;
+
+ protected abstract ID createID() throws IDCreateException;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = createID();
+ assertNotNull(fixture);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fixture = null;
+ }
+
+ protected ID getFixture() {
+ return fixture;
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java
new file mode 100644
index 000000000..bb5adb17f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java
@@ -0,0 +1,27 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core.identity;
+
+import org.eclipse.ecf.internal.tests.core.Activator;
+
+public class IDFactoryServiceTest extends IIDNamespaceTest {
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = Activator.getDefault().getIDFactory();
+ assertNotNull(fixture);
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java
new file mode 100644
index 000000000..1cd14455a
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java
@@ -0,0 +1,27 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core.identity;
+
+import org.eclipse.ecf.core.identity.IDFactory;
+
+public class IDFactoryTest extends IIDNamespaceTest {
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = IDFactory.getDefault();
+ assertNotNull(fixture);
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java
new file mode 100644
index 000000000..c24f3e21c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Markus Alexander Kuppe.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Alexander Kuppe (ecf-dev_eclipse.org <at> lemmster <dot> de) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.tests.core.identity;
+
+import java.util.List;
+
+import org.eclipse.ecf.core.identity.GUID;
+import org.eclipse.ecf.core.identity.IIDFactory;
+import org.eclipse.ecf.core.identity.LongID;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.identity.StringID;
+
+public abstract class IIDNamespaceTest extends NamespaceTest {
+
+ IIDFactory fixture = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fixture = null;
+ assertNull(fixture);
+ }
+
+ public void testIDFactoryGetNamespaces() {
+ List namespaces = fixture.getNamespaces();
+ assertNotNull(namespaces);
+ assertTrue(namespaces.size() > 0);
+ }
+
+ public void testIDFactoryGetStringIDNamespaceByName() {
+ Namespace namespace = fixture.getNamespaceByName(StringID.class
+ .getName());
+ assertNotNull(namespace);
+ }
+
+ public void testIDFactoryGetGUIDIDNamespaceByName() {
+ Namespace namespace = fixture.getNamespaceByName(GUID.class.getName());
+ assertNotNull(namespace);
+ }
+
+ public void testIDFactoryGetLongIDNamespaceByName() {
+ Namespace namespace = fixture
+ .getNamespaceByName(LongID.class.getName());
+ assertNotNull(namespace);
+ }
+
+ public void testIDFactoryAddNamespace() {
+ Namespace namespace = createNamespace();
+ int currentSize = fixture.getNamespaces().size();
+ Namespace ns = fixture.addNamespace(namespace);
+ assertNull(ns);
+ assertTrue(fixture.getNamespaces().size() == (currentSize + 1));
+ assertNotNull(fixture.removeNamespace(namespace));
+ }
+
+ public void testIDFactoryRemoveNamespace() {
+ Namespace namespace = fixture.getNamespaceByName(StringID.class
+ .getName());
+ int currentSize = fixture.getNamespaces().size();
+ Namespace removed = fixture.removeNamespace(namespace);
+ assertNotNull(removed);
+ assertTrue(fixture.getNamespaces().size() == (currentSize - 1));
+ // Put it back
+ fixture.addNamespace(removed);
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java
new file mode 100644
index 000000000..8836a251c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java
@@ -0,0 +1,133 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.tests.core.identity;
+
+import java.io.ByteArrayOutputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+
+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;
+
+public class LongIDTest extends IDAbstractTestCase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.IDTestCase#createID()
+ */
+ protected ID createID() throws IDCreateException {
+ return createLongID(Long.MAX_VALUE);
+ }
+
+ protected ID createLongID(long val) throws IDCreateException {
+ return IDFactory.getDefault().createLongID(val);
+ }
+
+ public void testCreate() throws Exception {
+ final ID newID = createID();
+ assertNotNull(newID);
+ }
+
+ public void testMinCreate() throws Exception {
+ final ID newID = createLongID(Long.MIN_VALUE);
+ assertNotNull(newID);
+ }
+
+ public void testMAXCreate() throws Exception {
+ final ID newID = createLongID(Long.MAX_VALUE);
+ assertNotNull(newID);
+ }
+
+ public void testZeroCreate() throws Exception {
+ final ID id = createLongID(0);
+ assertTrue(id.getName().equals(String.valueOf(0)));
+ }
+
+ public void testGetName() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.getName().equals(id2.getName()));
+ }
+
+ public void testToExternalForm() throws Exception {
+ final ID id = createID();
+ assertNotNull(id.toExternalForm());
+ }
+
+ public void testToString() throws Exception {
+ final ID id = createID();
+ assertNotNull(id.toString());
+ }
+
+ public void testIsEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.equals(id2));
+ }
+
+ public void testHashCode() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.hashCode() == id2.hashCode());
+ }
+
+ public void testCompareToEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.compareTo(id2) == 0);
+ assertTrue(id2.compareTo(id1) == 0);
+ }
+
+ public void testCompareToNotEqual() throws Exception {
+ final ID id1 = createLongID(0);
+ final ID id2 = createLongID(1);
+ assertTrue(id1.compareTo(id2) < 0);
+ assertTrue(id2.compareTo(id1) > 0);
+ }
+
+ public void testGetNamespace() throws Exception {
+ final ID id = createID();
+ final Namespace ns = id.getNamespace();
+ assertNotNull(ns);
+ }
+
+ public void testEqualNamespaces() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ final Namespace ns1 = id1.getNamespace();
+ final Namespace ns2 = id2.getNamespace();
+ assertTrue(ns1.equals(ns2));
+ assertTrue(ns2.equals(ns2));
+ }
+
+ public void testSerializable() throws Exception {
+ final ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buf);
+ try {
+ out.writeObject(createID());
+ } catch (final NotSerializableException ex) {
+ fail(ex.getLocalizedMessage());
+ } finally {
+ out.close();
+ }
+ }
+
+ public void testCreateFromExternalForm() throws Exception {
+ final ID id1 = createID();
+ final String externalForm = id1.toExternalForm();
+ final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(),
+ externalForm);
+ assertTrue(id1.equals(id2));
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java
new file mode 100644
index 000000000..75d8988bb
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core.identity;
+
+import java.io.ByteArrayOutputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+
+import junit.framework.TestCase;
+
+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.core.identity.StringID;
+
+public class NamespaceTest extends TestCase {
+
+ private static final String DESCRIPTION = "description";
+
+ private Namespace fixture;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ fixture = IDFactory.getDefault().getNamespaceByName(
+ StringID.class.getName());
+ assertNotNull(fixture);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ fixture = null;
+ }
+
+ protected Namespace createNamespace() {
+ Namespace namespace = new Namespace(this.getClass().getName(),
+ DESCRIPTION) {
+ private static final long serialVersionUID = 0L;
+
+ public ID createInstance(Object[] args) throws IDCreateException {
+ throw new IDCreateException("can't create instance");
+ }
+
+ public String getScheme() {
+ return NamespaceTest.this.getClass().getName();
+ }
+
+ public Class[][] getSupportedParameterTypes() {
+ return new Class[][] { { String.class } };
+ }
+ };
+ return namespace;
+ }
+
+ public void testNamespaceGetScheme() {
+ String scheme = fixture.getScheme();
+ assertNotNull(scheme);
+ }
+
+ public void testNamespaceGetName() {
+ String name = fixture.getName();
+ assertNotNull(name);
+ assertTrue(name.equals(StringID.class.getName()));
+ }
+
+ public void testNewNamespaceCreateInstance() {
+ Namespace ns = createNamespace();
+ try {
+ ns.createInstance(null);
+ fail("createInstance did not return null");
+ } catch (IDCreateException e) {
+
+ }
+ }
+
+ public void testNewNamespaceGetScheme() {
+ Namespace ns = createNamespace();
+ String scheme = ns.getScheme();
+ assertTrue(scheme.equals(this.getClass().getName()));
+ }
+
+ public void testNewNamespaceGetDescription() {
+ Namespace ns = createNamespace();
+ String desc = ns.getDescription();
+ assertTrue(desc.equals(DESCRIPTION));
+ }
+
+ public void testNewNamespaceGetSupportedParameterTypesForCreateInstance() {
+ Namespace ns = createNamespace();
+ Class[][] result = ns.getSupportedParameterTypes();
+ assertTrue(result.length == 1);
+ assertTrue(result[0][0].equals(String.class));
+ }
+
+ public final void testSerializable() throws Exception {
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(buf);
+ try {
+ out.writeObject(fixture);
+ } catch (NotSerializableException ex) {
+ fail(ex.getLocalizedMessage());
+ } finally {
+ out.close();
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java
new file mode 100644
index 000000000..9b62692c8
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.ecf.tests.core.identity;
+
+import java.io.ByteArrayOutputStream;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+
+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;
+
+public class StringIDTest extends IDAbstractTestCase {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.IDTestCase#createID()
+ */
+ protected ID createID() throws IDCreateException {
+ return createStringID(this.getClass().getName());
+ }
+
+ protected ID createStringID(String val) throws IDCreateException {
+ return IDFactory.getDefault().createStringID(val);
+ }
+
+ public void testCreate() throws Exception {
+ final ID newID = createID();
+ assertNotNull(newID);
+ }
+
+ public void testNullCreate() throws Exception {
+ try {
+ createStringID(null);
+ fail();
+ } catch (final IDCreateException e) {
+ // success
+ }
+ }
+
+ public void testGetName() throws Exception {
+ final ID id = createStringID(this.getClass().getName());
+ assertTrue(id.getName().equals(this.getClass().getName()));
+ }
+
+ public void testToExternalForm() throws Exception {
+ final ID id = createStringID(this.getClass().getName());
+ assertNotNull(id.toExternalForm());
+ }
+
+ public void testToString() throws Exception {
+ final ID id = createStringID(this.getClass().getName());
+ assertNotNull(id.toString());
+ }
+
+ public void testIsEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.equals(id2));
+ }
+
+ public void testHashCode() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.hashCode() == id2.hashCode());
+ }
+
+ public void testCompareToEqual() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ assertTrue(id1.compareTo(id2) == 0);
+ assertTrue(id2.compareTo(id1) == 0);
+ }
+
+ public void testCompareToNotEqual() throws Exception {
+ final ID id1 = createStringID("abcdefghijkl");
+ final ID id2 = createStringID("abcdefghijklm");
+ assertTrue(id1.compareTo(id2) < 0);
+ assertTrue(id2.compareTo(id1) > 0);
+ }
+
+ public void testGetNamespace() throws Exception {
+ final ID id = createID();
+ final Namespace ns = id.getNamespace();
+ assertNotNull(ns);
+ }
+
+ public void testEqualNamespaces() throws Exception {
+ final ID id1 = createID();
+ final ID id2 = createID();
+ final Namespace ns1 = id1.getNamespace();
+ final Namespace ns2 = id2.getNamespace();
+ assertTrue(ns1.equals(ns2));
+ assertTrue(ns2.equals(ns2));
+ }
+
+ public void testSerializable() throws Exception {
+ final ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ final ObjectOutputStream out = new ObjectOutputStream(buf);
+ try {
+ out.writeObject(createID());
+ } catch (final NotSerializableException ex) {
+ fail(ex.getLocalizedMessage());
+ } finally {
+ out.close();
+ }
+ }
+
+ public void testCreateFromExternalForm() throws Exception {
+ final ID id1 = createID();
+ final String externalForm = id1.toExternalForm();
+ final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(),
+ externalForm);
+ assertTrue(id1.equals(id2));
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java
new file mode 100644
index 000000000..950b301e8
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java
@@ -0,0 +1,99 @@
+/****************************************************************************
+ * Copyright (c) 2011 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+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.URIID;
+
+public class URIIDTest extends IDAbstractTestCase {
+
+ public static final String URIIDNAMESPACE = URIID.class.getName();
+ public static final String URI1 = "http://lala/lala/lala";
+ public static final String URI2 = "zooo:barbarbarbarbarbarbarbar";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.IDTestCase#createID()
+ */
+ protected ID createID() throws IDCreateException {
+ return createID(URI1);
+ }
+
+ protected ID createID(String val) throws IDCreateException {
+ // return IDFactory.getDefault().createID(URIIDNAMESPACE,val);
+ return IDFactory.getDefault().createStringID(val);
+ }
+
+ // The tests below are commented out because the Platform is using an older
+ // version of ECF
+ // core identity, and these tests are not supported in that older version
+ public void testCreate() throws Exception {
+ // final ID newID = createID();
+ // assertNotNull(newID);
+ }
+
+ /*
+ * public void testNullCreate() throws Exception { try { createID(null);
+ * fail(); } catch (final IDCreateException e) { // success } }
+ *
+ * public void testGetName() throws Exception { final ID id =
+ * createID(URI1); assertTrue(id.getName().equals(URI1)); }
+ *
+ * public void testToExternalForm() throws Exception { final ID id =
+ * createID(URI1); assertNotNull(id.toExternalForm()); }
+ *
+ * public void testToString() throws Exception { final ID id =
+ * createID(URI1); assertNotNull(id.toString()); }
+ *
+ * public void testIsEqual() throws Exception { final ID id1 = createID();
+ * final ID id2 = createID(); assertTrue(id1.equals(id2)); }
+ *
+ * public void testHashCode() throws Exception { final ID id1 = createID();
+ * final ID id2 = createID(); assertTrue(id1.hashCode() == id2.hashCode());
+ * }
+ *
+ * public void testCompareToEqual() throws Exception { final ID id1 =
+ * createID(); final ID id2 = createID(); assertTrue(id1.compareTo(id2) ==
+ * 0); assertTrue(id2.compareTo(id1) == 0); }
+ *
+ * public void testCompareToNotEqual() throws Exception { final ID id1 =
+ * createID(URI1); final ID id2 = createID(URI2);
+ * assertTrue(id1.compareTo(id2) < 0); assertTrue(id2.compareTo(id1) > 0); }
+ *
+ * public void testGetNamespace() throws Exception { final ID id =
+ * createID(); final Namespace ns = id.getNamespace(); assertNotNull(ns); }
+ *
+ * public void testEqualNamespaces() throws Exception { final ID id1 =
+ * createID(); final ID id2 = createID(); final Namespace ns1 =
+ * id1.getNamespace(); final Namespace ns2 = id2.getNamespace();
+ * assertTrue(ns1.equals(ns2)); assertTrue(ns2.equals(ns2)); }
+ *
+ * public void testSerializable() throws Exception { final
+ * ByteArrayOutputStream buf = new ByteArrayOutputStream(); final
+ * ObjectOutputStream out = new ObjectOutputStream(buf); try {
+ * out.writeObject(createID()); } catch (final NotSerializableException ex)
+ * { fail(ex.getLocalizedMessage()); } finally { out.close(); } }
+ *
+ * public void testCreateFromExternalForm() throws Exception { final ID id1
+ * = createID(); final String externalForm = id1.toExternalForm(); final ID
+ * id2 = IDFactory.getDefault().createID(id1.getNamespace(), externalForm);
+ * assertTrue(id1.equals(id2)); }
+ *
+ * public void testCreateFromURIForm() throws Exception { final ID id1 =
+ * IDFactory.getDefault().createID(URIIDNAMESPACE,new Object[] { new
+ * URI(URI1) }); final String externalForm = id1.toExternalForm(); final ID
+ * id2 = IDFactory.getDefault().createID(id1.getNamespace(), externalForm);
+ * assertTrue(id1.equals(id2)); }
+ */
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/Base64Test.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/Base64Test.java
new file mode 100644
index 000000000..cc12907d3
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/Base64Test.java
@@ -0,0 +1,38 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.core.util;
+
+import org.eclipse.ecf.core.util.Base64;
+
+import junit.framework.TestCase;
+
+public class Base64Test extends TestCase {
+
+ private static final String INPUT = "the quick brown fox jumped over the lazy dog";
+
+ protected String encode() {
+ return Base64.encode(INPUT.getBytes());
+ }
+
+ public void testEncode() {
+ String encoded = encode();
+ assertNotNull(encoded);
+ assertTrue(encoded.length() > 0);
+ }
+
+ public void testDecode() {
+ String encoded = encode();
+ byte[] bytes = Base64.decode(encoded);
+ assertNotNull(bytes);
+ assertTrue(INPUT.equals(new String(bytes)));
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java
new file mode 100644
index 000000000..07f4d7522
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java
@@ -0,0 +1,65 @@
+package org.eclipse.ecf.tests.core.util;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ecf.core.status.SerializableStatus;
+import org.eclipse.ecf.internal.tests.core.Activator;
+
+public class SerializableStatusTest extends TestCase {
+
+ protected IStatus createOKStatus() {
+ return SerializableStatus.OK_STATUS;
+ }
+
+ protected IStatus createErrorStatus() {
+ return new SerializableStatus(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, "error", new IllegalArgumentException(
+ "myexception"));
+ }
+
+ public static class MyNotSerializableException extends Exception {
+
+ private static final long serialVersionUID = -3836424516905729214L;
+ Object notSerializableObject = new Object();
+
+ public MyNotSerializableException(String message) {
+ super(message);
+ }
+ }
+
+ protected IStatus createNotSerializableExceptionStatus() {
+ return new SerializableStatus(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, "error", new MyNotSerializableException(
+ "myexception"));
+ }
+
+ public void testCreateStatus() throws Exception {
+ IStatus s = createOKStatus();
+ assertNotNull(s);
+ assertTrue(s.isOK());
+ assertTrue(s.getCode() == SerializableStatus.OK);
+ assertTrue(s.getMessage().equals("ok"));
+ assertTrue(s.getException() == null);
+ }
+
+ public void testCreateExceptionStatus() throws Exception {
+ IStatus s = createErrorStatus();
+ assertNotNull(s);
+ assertFalse(s.isOK());
+ assertTrue(s.getCode() == IStatus.ERROR);
+ assertFalse(s.getMessage().equals("ok"));
+ assertFalse(s.getException() == null);
+ }
+
+ public void testCreateNotSerializableExceptionStatus() throws Exception {
+ IStatus s = createNotSerializableExceptionStatus();
+ assertNotNull(s);
+ assertFalse(s.isOK());
+ assertTrue(s.getCode() == IStatus.ERROR);
+ assertFalse(s.getMessage().equals("ok"));
+ assertFalse(s.getException() == null);
+ Throwable t = s.getException();
+ assertFalse(t instanceof MyNotSerializableException);
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java
new file mode 100644
index 000000000..ab33a1444
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.core/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Markus Alexander Kuppe.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Alexander Kuppe (ecf-dev_eclipse.org <at> lemmster.de <dot> de) - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ecf.tests.core.util;
+
+import org.eclipse.ecf.core.util.StringUtils;
+
+import junit.framework.TestCase;
+
+public class StringUtilsTest extends TestCase {
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ecf.core.util.StringUtils#replaceFirst(java.lang.String, java.lang.String, java.lang.String)}
+ * .
+ */
+ public final void testReplaceFirstNoCase() {
+ String input = "barbar";
+ String toReplace = "bar";
+ String withReplace = "foo";
+ assertEquals("foobar",
+ StringUtils.replaceFirst(input, toReplace, withReplace));
+ }
+
+ /**
+ * Test method for
+ * {@link org.eclipse.ecf.core.util.StringUtils#replaceFirst(java.lang.String, java.lang.String, java.lang.String)}
+ * .
+ */
+ public final void testReplaceFirstWithCase() {
+ String input = "Barbarbar";
+ String toReplace = "bar";
+ String withReplace = "foo";
+ assertEquals("Barfoobar",
+ StringUtils.replaceFirst(input, toReplace, withReplace));
+ }
+}

Back to the top