From 62dfafcd597b775154b63ecf5e7edad35ca3a9b8 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 19 Mar 2009 10:31:17 +0000 Subject: delete test tag git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@755899 13f79535-47bb-0310-9956-ffa450edef68 --- ...URLartifactProcessorExtensionPointTestCase.java | 113 ----------------- .../resolver/DefaultModelResolverTestCase.java | 91 -------------- .../resolver/ExtensibleModelResolverTestCase.java | 134 --------------------- .../contribution/resolver/TestModelResolver.java | 58 --------- 4 files changed, 396 deletions(-) delete mode 100644 sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java delete mode 100644 sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java delete mode 100644 sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java delete mode 100644 sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java (limited to 'sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany') diff --git a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java b/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java deleted file mode 100644 index 3b99cc0312..0000000000 --- a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.processor; - -import static org.junit.Assert.assertNotNull; - -import java.net.URI; -import java.net.URL; - -import org.apache.tuscany.sca.contribution.resolver.ModelResolver; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * URL Artifact Processor Extension Point test case - * Verifies the right registration and lookup for processors that handle filename and file types - * - * @version $Rev$ $Date$ - */ -public class URLartifactProcessorExtensionPointTestCase { - - private static URLArtifactProcessorExtensionPoint artifactProcessors; - - @BeforeClass - public static void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - artifactProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints); - artifactProcessors.addArtifactProcessor(new FileTypeArtifactProcessor()); - artifactProcessors.addArtifactProcessor(new FileNameArtifactProcessor()); - } - - @Test - public final void testFileTypeProcessor() { - assertNotNull(artifactProcessors.getProcessor(".m1")); - } - - @Test - public final void testFileNameProcessor() { - assertNotNull(artifactProcessors.getProcessor("file.m2")); - - } - - /** - * Internal mock classes - * - */ - - private class M1 { - } - - private class M2 { - } - - private static class FileTypeArtifactProcessor implements URLArtifactProcessor { - public FileTypeArtifactProcessor() { - } - - public M1 read(URL contributionURL, URI uri, URL url) throws ContributionReadException { - return null; - } - - public void resolve(M1 m1, ModelResolver resolver) throws ContributionResolveException { - } - - public String getArtifactType() { - return ".m1"; - } - - public Class getModelType() { - return M1.class; - } - } - - private static class FileNameArtifactProcessor implements URLArtifactProcessor { - public FileNameArtifactProcessor() { - } - - public M2 read(URL contributionURL, URI uri, URL url) throws ContributionReadException { - return null; - } - - public void resolve(M2 m2, ModelResolver resolver) throws ContributionResolveException { - } - - public String getArtifactType() { - return "file.m2"; - } - - public Class getModelType() { - return M2.class; - } - } - -} diff --git a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java b/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java deleted file mode 100644 index b778167217..0000000000 --- a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.resolver; - -import static org.junit.Assert.assertTrue; - -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.junit.Before; -import org.junit.Test; - -/** - * Test the default model resolver implementation. - * - * @version $Rev$ $Date$ - */ -public class DefaultModelResolverTestCase { - - private ModelResolver resolver; - private ContributionFactory factory; - - @Before - public void setUp() throws Exception { - resolver = new DefaultModelResolver(); - factory = new DefaultContributionFactory(); - } - - @Test - public void testResolved() { - Model a = new Model("a"); - resolver.addModel(a); - Model x = new Model("a"); - x = resolver.resolveModel(Model.class, x); - assertTrue(x == a); - } - - @Test - public void testUnresolved() { - Model x = new Model("a"); - Model y = resolver.resolveModel(Model.class, x); - assertTrue(x == y); - } - - @Test - public void testResolvedArtifact() { - Artifact artifact = factory.createArtifact(); - artifact.setURI("foo/bar"); - resolver.addModel(artifact); - Artifact x = factory.createArtifact(); - x.setURI("foo/bar"); - x = resolver.resolveModel(Artifact.class, x); - assertTrue(x == artifact); - } - - class Model { - private String name; - - Model(String name) { - this.name = name; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return name.equals(((Model)obj).name); - } - } - -} diff --git a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java deleted file mode 100644 index 2422c8fb94..0000000000 --- a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java +++ /dev/null @@ -1,134 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ - -package org.apache.tuscany.sca.contribution.resolver; - -import static org.junit.Assert.assertTrue; - -import org.apache.tuscany.sca.contribution.Artifact; -import org.apache.tuscany.sca.contribution.ContributionFactory; -import org.apache.tuscany.sca.contribution.DefaultContributionFactory; -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.junit.Before; -import org.junit.Test; - -/** - * Test DefaultArtifactResolver. - * - * @version $Rev$ $Date$ - */ -public class ExtensibleModelResolverTestCase { - private ExtensibleModelResolver resolver; - - private ContributionFactory factory; - - @Before - public void setUp() throws Exception { - - ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint(); - resolvers.addResolver(Model.class, TestModelResolver.class); - - FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); - - resolver = new ExtensibleModelResolver(null, resolvers, factories, null); - - factory = new DefaultContributionFactory(); - } - - @Test - public void testResolvedDefault() { - OtherModel a = new OtherModel("a"); - resolver.addModel(a); - OtherModel x = new OtherModel("a"); - x = resolver.resolveModel(OtherModel.class, x); - assertTrue(x == a); - } - - @Test - public void testResolvedRegisteredClass() { - Model a = new Model("a"); - resolver.addModel(a); - Model x = new Model("a"); - x = resolver.resolveModel(Model.class, x); - assertTrue(x == a); - } - - @Test - public void testUnresolvedDefault() { - OtherModel x = new OtherModel("a"); - OtherModel y = resolver.resolveModel(OtherModel.class, x); - assertTrue(x == y); - } - - @Test - public void testUnresolved() { - Model x = new Model("a"); - Model y = resolver.resolveModel(Model.class, x); - assertTrue(x == y); - } - - @Test - public void testResolvedArtifact() { - Artifact artifact = factory.createArtifact(); - artifact.setURI("foo/bar"); - resolver.addModel(artifact); - Artifact x = factory.createArtifact(); - x.setURI("foo/bar"); - x = resolver.resolveModel(Artifact.class, x); - assertTrue(x == artifact); - } - - private class Model { - private String name; - - Model(String name) { - this.name = name; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return name.equals(((Model)obj).name); - } - } - - private class OtherModel { - private String name; - - OtherModel(String name) { - this.name = name; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return name.equals(((OtherModel)obj).name); - } - } -} diff --git a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java b/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java deleted file mode 100644 index cd586d3b2c..0000000000 --- a/sandbox/ant/sca/tags/2.0-M2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.contribution.resolver; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sca.contribution.Contribution; -import org.apache.tuscany.sca.core.FactoryExtensionPoint; - -/** - * A test implementation of a model resolver, based on a map. - * - * @version $Rev$ $Date$ - */ -public class TestModelResolver implements ModelResolver { - - private Map map = new HashMap(); - - public TestModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) { - } - - public T resolveModel(Class modelClass, T unresolved) { - Object resolved = map.get(unresolved); - if (resolved != null) { - // Return the resolved object - return modelClass.cast(resolved); - } - // Return the unresolved object - return unresolved; - } - - public void addModel(Object resolved) { - map.put(resolved, resolved); - } - - public Object removeModel(Object resolved) { - return map.remove(resolved); - } - -} -- cgit v1.2.3