diff options
Diffstat (limited to '')
4 files changed, 0 insertions, 396 deletions
diff --git a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java deleted file mode 100644 index 14b6b956da..0000000000 --- a/branches/sca-equinox/modules/contribution-impl/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 junit.framework.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<M1> { - 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<M1> getModelType() { - return M1.class; - } - } - - private static class FileNameArtifactProcessor implements URLArtifactProcessor<M2> { - 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<M2> getModelType() { - return M2.class; - } - } - -} diff --git a/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java deleted file mode 100644 index f5b04f503c..0000000000 --- a/branches/sca-equinox/modules/contribution-impl/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 junit.framework.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/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java deleted file mode 100644 index e4082b3b85..0000000000 --- a/branches/sca-equinox/modules/contribution-impl/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 junit.framework.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/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java b/branches/sca-equinox/modules/contribution-impl/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java deleted file mode 100644 index cd586d3b2c..0000000000 --- a/branches/sca-equinox/modules/contribution-impl/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<Object, Object> map = new HashMap<Object, Object>(); - - public TestModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) { - } - - public <T> T resolveModel(Class<T> 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); - } - -} |