diff options
author | slewis | 2014-02-08 05:16:56 +0000 |
---|---|---|
committer | slewis | 2014-02-08 05:16:56 +0000 |
commit | f723af09ae613a47007808f36462eb058ed3a3d9 (patch) | |
tree | 78b9e387a4c63e5ed2821238fb6536559db4138d /tests | |
parent | 324958a58f5ccf800799d744d6ba722a758a7596 (diff) | |
download | org.eclipse.ecf-f723af09ae613a47007808f36462eb058ed3a3d9.tar.gz org.eclipse.ecf-f723af09ae613a47007808f36462eb058ed3a3d9.tar.xz org.eclipse.ecf-f723af09ae613a47007808f36462eb058ed3a3d9.zip |
Moved appropriate test cases to org.eclipse.ecf.tests.core.
Change-Id: Iddb44d1ce4daea9cf24334243b62e85e55a97bea
Diffstat (limited to 'tests')
23 files changed, 0 insertions, 2171 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF index 3e7c4c286..5bb76b952 100755 --- a/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF +++ b/tests/bundles/org.eclipse.ecf.tests/META-INF/MANIFEST.MF @@ -13,9 +13,6 @@ Eclipse-LazyStart: true Export-Package: org.eclipse.ecf.internal.tests;x-internal:=true, org.eclipse.ecf.tests, org.eclipse.ecf.tests.connect, - org.eclipse.ecf.tests.core;x-internal:=true, - org.eclipse.ecf.tests.core.identity;x-internal:=true, - org.eclipse.ecf.tests.core.util;x-internal:=true, org.eclipse.ecf.tests.util Import-Package: org.eclipse.osgi.util;version="1.1.0", org.osgi.framework;version="1.4.0", diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java deleted file mode 100755 index 27ffd1ab0..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryAbstractTestCase.java +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** - * 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/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java deleted file mode 100755 index 73664f9c2..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryCreateTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/**************************************************************************** - * 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 testCreateDefaultClientContainer() throws Exception { - final IContainer client = ContainerFactory.getDefault() - .createContainer("ecf.generic.client"); - assertNotNull(client); - // dispose - client.dispose(); - } - - public void testCreateDefaultServerContainer() throws Exception { - final IContainer server = ContainerFactory.getDefault() - .createContainer("ecf.generic.server"); - assertNotNull(server); - // dispose - server.dispose(); - } - - public void testCreateDefaultServerContainer1() throws Exception { - final IContainer server = ContainerFactory.getDefault() - .createContainer( - "ecf.generic.server", - IDFactory.getDefault().createStringID( - "ecftcp://localhost:3282/server")); - assertNotNull(server); - // dispose - server.dispose(); - } - - public void testCreateDefaultServerContainer2() throws Exception { - final IContainer server = ContainerFactory.getDefault() - .createContainer("ecf.generic.server", - new Object[] { "ecftcp://localhost:3282/server" }); - assertNotNull(server); - // dispose - server.dispose(); - } - - 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/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java deleted file mode 100755 index 9984a023b..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryDescriptionsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** - * 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/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java deleted file mode 100755 index 8a7a76586..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceAbstractTestCase.java +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** - * 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.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/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java deleted file mode 100755 index f03fb5c55..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceCreateTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** -* 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.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/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java deleted file mode 100755 index 018af2f6f..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerFactoryServiceDescriptionsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** - * 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/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java deleted file mode 100755 index b310f76a4..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ContainerManagerServiceTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/**************************************************************************** -* 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.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/src/org/eclipse/ecf/tests/core/ECFStartTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ECFStartTest.java deleted file mode 100755 index b336d2cd3..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ECFStartTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** - * 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.IContainerManager; -import org.eclipse.ecf.internal.tests.Activator; - -import junit.framework.TestCase; - -/** - * - */ -public class ECFStartTest extends TestCase { - - IContainerManager containerManager = null; - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - containerManager = Activator.getDefault().getContainerManager(); - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - containerManager = null; - } - - public void testStarted() throws Exception { - assertNotNull(containerManager); - assertTrue(ECFStartup.isSet); - } -} diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ECFStartup.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ECFStartup.java deleted file mode 100755 index 9043cac8c..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/ECFStartup.java +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** - * 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.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.ecf.core.start.IECFStart; - -/** - * - */ -public class ECFStartup implements IECFStart { - - static boolean isSet = false; - - /* (non-Javadoc) - * @see org.eclipse.ecf.core.start.IECFStart#startup(org.eclipse.core.runtime.IProgressMonitor) - */ - public IStatus run(IProgressMonitor monitor) { - isSet = true; - return Status.OK_STATUS; - } - -} diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java deleted file mode 100644 index 43458777d..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/GenericServerCreateTest.java +++ /dev/null @@ -1,89 +0,0 @@ -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/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java deleted file mode 100755 index 3e766c743..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -* 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/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java deleted file mode 100755 index b2b77974c..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -* 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.ID; -import org.eclipse.ecf.core.identity.IDCreateException; -import org.eclipse.ecf.tests.ECFAbstractTestCase; - -public abstract class IDAbstractTestCase extends ECFAbstractTestCase { - - 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/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java deleted file mode 100755 index d87c4e22b..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDFactoryServiceTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** - * 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.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/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java deleted file mode 100644 index 58a4f4809..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDFactoryTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** - * 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/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java deleted file mode 100644 index 4fee5ae8c..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IIDNamespaceTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * 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/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java deleted file mode 100755 index 9266a1d8c..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -* 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/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java deleted file mode 100755 index e328f0e53..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/NamespaceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * 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; -import org.eclipse.ecf.core.identity.StringID; -import org.eclipse.ecf.tests.ECFAbstractTestCase; - -public class NamespaceTest extends ECFAbstractTestCase { - - 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/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java deleted file mode 100755 index 826944cdb..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -* 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/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java deleted file mode 100644 index 7509f5ce9..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/URIIDTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -* 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/src/org/eclipse/ecf/tests/core/util/Base64Test.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/Base64Test.java deleted file mode 100755 index b30e9dda7..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/Base64Test.java +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -* 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/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java deleted file mode 100644 index b199a4209..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/SerializableStatusTest.java +++ /dev/null @@ -1,61 +0,0 @@ -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.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 { - - 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/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java deleted file mode 100644 index 51761a13e..000000000 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/util/StringUtilsTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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)); - } -} |