http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/annotations/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/annotations/package-info.java b/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/annotations/package-info.java deleted file mode 100644 index 6a89454..0000000 --- a/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/annotations/package-info.java +++ /dev/null @@ -1,24 +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. - */ -/** - * Miscellaneous annotations on other parts of the component engine. - * - * @author Donal Fellows - */ -package io.github.taverna_extras.component.registry.standard.annotations; \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/package-info.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/package-info.java b/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/package-info.java deleted file mode 100644 index 89df01a..0000000 --- a/taverna-component-activity/src/main/java/org/apache/taverna/component/registry/standard/package-info.java +++ /dev/null @@ -1,23 +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. - */ -/** - * This is the new interface to the myExperiment registry, a.k.a. μExperiment. - * @author Donal Fellows - */ -package io.github.taverna_extras.component.registry.standard; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/AnnotationUtils.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/AnnotationUtils.java b/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/AnnotationUtils.java deleted file mode 100644 index a3ac463..0000000 --- a/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/AnnotationUtils.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.github.taverna_extras.component.utils; -/* - * 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. - */ - -import java.io.IOException; -import java.io.StringReader; -import java.util.WeakHashMap; - -import org.apache.taverna.scufl2.api.annotation.Annotation; -import org.apache.taverna.scufl2.api.common.Child; -import org.apache.taverna.scufl2.api.common.Scufl2Tools; -import org.apache.taverna.scufl2.api.common.URITools; -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.ucfpackage.UCFPackage.ResourceEntry; - -import org.apache.jena.rdf.model.Model; -import org.apache.jena.rdf.model.ModelFactory; -import org.apache.jena.rdf.model.Property; -import org.apache.jena.rdf.model.Statement; - -public class AnnotationUtils { - private static final String TITLE_ANNOTATION = "http://purl.org/dc/terms/title"; - private static final String DESCRIPTION_ANNOTATION = "http://purl.org/dc/terms/description"; - private Scufl2Tools tools = new Scufl2Tools(); - private URITools uris = new URITools(); - - public Model getAnnotationModel(Child<WorkflowBundle> subject) throws IOException { - return ModelFactory.createDefaultModel().add(getModel(subject)); - } - - private WeakHashMap<Child<?>, Model> cache = new WeakHashMap<>(); - - private static void readParse(Model model, WorkflowBundle bundle, String path) - throws IOException { - model.read( - new StringReader(bundle.getResources() - .getResourceAsString(path)), bundle.getGlobalBaseURI() - .resolve(path).toString(), "TTL"); - } - - public Model getModel(Child<WorkflowBundle> subject) throws IOException { - WorkflowBundle bundle = subject.getParent(); - Model m = cache.get(subject); - if (m == null) { - m = ModelFactory.createDefaultModel(); - long initialSize = m.size(); - for (Annotation a : tools.annotationsFor(subject, - subject.getParent())) - if (!a.getBody().isAbsolute()) - readParse(m, bundle, a.getBody().getPath()); - if (m.size() == initialSize) - for (ResourceEntry o : bundle.getResources() - .listResources("annotation").values()) - readParse(m, bundle, o.getPath()); - cache.put(subject, m); - } - return m; - } - - public Statement getAnnotation(Child<WorkflowBundle> subject, - String uriForAnnotation) throws IOException { - Model m = getModel(subject); - Property p = m.getProperty(uriForAnnotation); - return m.getResource(uris.uriForBean(subject).toString()).getProperty( - p); - } - - /** Get the title of the main workflow in a workflow bundle. */ - public String getTitle(WorkflowBundle bundle, String defaultTitle) { - try { - Statement s = getAnnotation(bundle.getMainWorkflow(), - TITLE_ANNOTATION); - if (s != null && s.getObject().isLiteral()) - return s.getObject().asLiteral().getString(); - } catch (IOException e) { - // TODO log this error? - } - return defaultTitle; - } - - /** Get the description of the main workflow in a workflow bundle. */ - public String getDescription(WorkflowBundle bundle, String defaultDescription) { - try { - Statement s = getAnnotation(bundle.getMainWorkflow(), - DESCRIPTION_ANNOTATION); - if (s != null && s.getObject().isLiteral()) - return s.getObject().asLiteral().getString(); - } catch (IOException e) { - // TODO log this error? - } - return defaultDescription; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/SystemUtils.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/SystemUtils.java b/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/SystemUtils.java deleted file mode 100644 index 9a57122..0000000 --- a/taverna-component-activity/src/main/java/org/apache/taverna/component/utils/SystemUtils.java +++ /dev/null @@ -1,135 +0,0 @@ -package io.github.taverna_extras.component.utils; -/* - * 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. - */ - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBElement; - -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.registry.api.Description; -import org.apache.taverna.configuration.app.ApplicationConfiguration; -import org.apache.taverna.platform.execution.api.InvalidWorkflowException; -import org.apache.taverna.platform.execution.api.WorkflowCompiler; -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; -import org.apache.taverna.workflowmodel.Dataflow; - -public class SystemUtils { - private static final String T2FLOW_TYPE = "application/vnd.taverna.t2flow+xml"; - private static final String SCUFL2_TYPE = "application/vnd.taverna.scufl2.workflow-bundle"; - private ApplicationConfiguration appConfig; - private WorkflowBundleIO workflowBundleIO; - private List<WorkflowCompiler> compilers; - - public byte[] serializeBundle(WorkflowBundle bundle) throws ComponentException { - try { - ByteArrayOutputStream dataflowStream = new ByteArrayOutputStream(); - workflowBundleIO.writeBundle(bundle, dataflowStream, SCUFL2_TYPE); - return dataflowStream.toByteArray(); - } catch (Exception e) { - throw new ComponentException( - "failed to serialize component implementation", e); - } - } - - private String determineMediaTypeForFilename(File file) { - String[] pieces = file.getName().split("\\."); - switch (pieces[pieces.length - 1]) { - case "t2flow": - return T2FLOW_TYPE; - default: - return SCUFL2_TYPE; - } - } - - public void saveBundle(WorkflowBundle bundle, File file) throws Exception { - workflowBundleIO.writeBundle(bundle, file, - determineMediaTypeForFilename(file)); - } - - public WorkflowBundle getBundleFromUri(String uri) throws Exception { - return workflowBundleIO.readBundle(new URL(uri), null); - } - - public WorkflowBundle getBundle(File file) throws Exception { - return workflowBundleIO.readBundle(file, null); - } - - public static JAXBElement<?> getElement(Description d, String name) - throws ComponentException { - for (Object o : d.getContent()) - if (o instanceof JAXBElement) { - JAXBElement<?> el = (JAXBElement<?>) o; - if (el.getName().getLocalPart().equals(name)) - return el; - } - throw new ComponentException("no " + name + " element"); - } - - public static String getElementString(Description d, String name) - throws ComponentException { - return getElement(d, name).getValue().toString().trim(); - } - - public static String getValue(Description d) { - StringBuilder sb = new StringBuilder(); - for (Object o : d.getContent()) - if (!(o instanceof JAXBElement)) - sb.append(o); - return sb.toString(); - } - - public File getApplicationHomeDir() { - return appConfig.getApplicationHomeDir().toFile(); - } - - public void setAppConfig(ApplicationConfiguration appConfig) { - this.appConfig = appConfig; - } - - public void setWorkflowBundler(WorkflowBundleIO workflowBundler) { - this.workflowBundleIO = workflowBundler; - } - - public void setCompilers(List<WorkflowCompiler> compilers) { - this.compilers = compilers; - } - - public Dataflow compile(WorkflowBundle implementation) - throws InvalidWorkflowException { - InvalidWorkflowException exn = null; - if (compilers != null) - for (WorkflowCompiler c : new ArrayList<>(compilers)) - try { - return c.getDataflow(implementation); - } catch (InvalidWorkflowException e) { - if (exn == null) - exn = e; - continue; - } - if (exn != null) - throw exn; - throw new InvalidWorkflowException("no compiler available"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/AnnotationTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/AnnotationTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/AnnotationTest.java new file mode 100644 index 0000000..6b885c3 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/AnnotationTest.java @@ -0,0 +1,48 @@ +package io.github.taverna_extras.component; +/* + * 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. + */ + +import static org.junit.Assert.*; + +import java.io.IOException; + +import io.github.taverna_extras.component.utils.AnnotationUtils; +import org.junit.Test; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.io.ReaderException; +import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; + +public class AnnotationTest { + //org.apache.taverna.scufl2.annotation.AnnotationTools anntoo; + @Test + public void test() throws ReaderException, IOException { + AnnotationUtils au = new AnnotationUtils(); + WorkflowBundleIO b = new WorkflowBundleIO(); + final String WORKFLOW_FILE = "/hello_anyone.wfbundle"; + final String TITLE = "Hello Anyone"; + final String DESC = "An extension to helloworld.t2flow - this workflow takes a workflow input \"name\" which is combined with the string constant \"Hello, \" using the local worker \"Concatenate two strings\", and outputs the produced string to the workflow output \"greeting\"."; + + WorkflowBundle bdl = b.readBundle( + getClass().getResource(WORKFLOW_FILE), null); + assertEquals(TITLE, au.getTitle(bdl, "---NOT---GIVEN---")); + assertEquals(DESC, au.getDescription(bdl, "---NOT---GIVEN---")); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/ComponentActivityTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/ComponentActivityTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/ComponentActivityTest.java new file mode 100644 index 0000000..63ce804 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/ComponentActivityTest.java @@ -0,0 +1,125 @@ +package io.github.taverna_extras.component; +/* + * 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. + */ + +import io.github.taverna_extras.component.activity.ComponentActivity; +import io.github.taverna_extras.component.activity.ComponentActivityConfigurationBean; +import io.github.taverna_extras.component.activity.ComponentActivityFactory; + + +public class ComponentActivityTest { + + @SuppressWarnings("unused") + private ComponentActivityConfigurationBean configBean; + + @SuppressWarnings("unused") + private ComponentActivity activity = new ComponentActivityFactory().createActivity(); // FIXME + +/* @Before + public void makeConfigBean() throws Exception { + configBean = new ComponentActivityConfigurationBean(); + configBean.setExampleString("something"); + configBean + .setExampleUri(URI.create("http://localhost:8080/myEndPoint")); + } + + @Test(expected = ActivityConfigurationException.class) + public void invalidConfiguration() throws ActivityConfigurationException { + ComponentActivityConfigurationBean invalidBean = new ComponentActivityConfigurationBean(); + invalidBean.setExampleString("invalidExample"); + // Should throw ActivityConfigurationException + activity.configure(invalidBean); + } + + @Test + public void executeAsynch() throws Exception { + activity.configure(configBean); + + Map<String, Object> inputs = new HashMap<String, Object>(); + inputs.put("firstInput", "hello"); + + Map<String, Class<?>> expectedOutputTypes = new HashMap<String, Class<?>>(); + expectedOutputTypes.put("simpleOutput", String.class); + expectedOutputTypes.put("moreOutputs", String.class); + + Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity( + activity, inputs, expectedOutputTypes); + + assertEquals("Unexpected outputs", 2, outputs.size()); + assertEquals("simple", outputs.get("simpleOutput")); + assertEquals(Arrays.asList("Value 1", "Value 2"), outputs + .get("moreOutputs")); + + } + + @Test + public void reConfiguredActivity() throws Exception { + assertEquals("Unexpected inputs", 0, activity.getInputPorts().size()); + assertEquals("Unexpected outputs", 0, activity.getOutputPorts().size()); + + activity.configure(configBean); + assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); + assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); + + activity.configure(configBean); + // Should not change on reconfigure + assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); + assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); + } + + @Test + public void reConfiguredSpecialPorts() throws Exception { + activity.configure(configBean); + + ComponentActivityConfigurationBean specialBean = new ComponentActivityConfigurationBean(); + specialBean.setExampleString("specialCase"); + specialBean.setExampleUri(URI + .create("http://localhost:8080/myEndPoint")); + activity.configure(specialBean); + // Should now have added the optional ports + assertEquals("Unexpected inputs", 2, activity.getInputPorts().size()); + assertEquals("Unexpected outputs", 3, activity.getOutputPorts().size()); + } + + @Test + public void configureActivity() throws Exception { + Set<String> expectedInputs = new HashSet<String>(); + expectedInputs.add("firstInput"); + + Set<String> expectedOutputs = new HashSet<String>(); + expectedOutputs.add("simpleOutput"); + expectedOutputs.add("moreOutputs"); + + activity.configure(configBean); + + Set<ActivityInputPort> inputPorts = activity.getInputPorts(); + assertEquals(expectedInputs.size(), inputPorts.size()); + for (ActivityInputPort inputPort : inputPorts) { + assertTrue("Wrong input : " + inputPort.getName(), expectedInputs + .remove(inputPort.getName())); + } + + Set<OutputPort> outputPorts = activity.getOutputPorts(); + assertEquals(expectedOutputs.size(), outputPorts.size()); + for (OutputPort outputPort : outputPorts) { + assertTrue("Wrong output : " + outputPort.getName(), + expectedOutputs.remove(outputPort.getName())); + } + }*/ +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentFamilyTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentFamilyTest.java new file mode 100644 index 0000000..29e4473 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentFamilyTest.java @@ -0,0 +1,122 @@ +package io.github.taverna_extras.component.registry; +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.net.URL; + +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.api.profile.Profile; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; + +/** + * + * + * @author David Withers + */ +@Ignore +public class ComponentFamilyTest extends Harness { + private Family componentFamily; + private Profile componentProfile; + private WorkflowBundle bundle; + + @Before + public void setup() throws Exception { + URL componentProfileUrl = getClass().getClassLoader().getResource( + "ValidationComponent.xml"); + assertNotNull(componentProfileUrl); + componentProfile = util.getProfile(componentProfileUrl); + componentRegistry.addComponentProfile(componentProfile, null, null); + URL dataflowUrl = getClass().getClassLoader().getResource( + "beanshell_test.t2flow"); + assertNotNull(dataflowUrl); + bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); + componentFamily = componentRegistry.createComponentFamily( + "Test Component Family", componentProfile, "Some description", + null, null); + } + + @After + public void tearDown() throws Exception { + componentRegistry.removeComponentFamily(componentFamily); + } + + @Test + public void testGetComponentRegistry() throws Exception { + assertEquals(componentRegistry, componentFamily.getComponentRegistry()); + } + + @Test + public void testGetName() throws Exception { + assertEquals("Test Component Family", componentFamily.getName()); + assertEquals("Test Component Family", componentFamily.getName()); + } + + @Test + public void testGetComponentProfile() throws Exception { + Profile componentProfile2 = componentFamily.getComponentProfile(); + assertNotNull(componentProfile2); + String id = componentProfile.getId(); + String id2 = componentProfile2.getId(); + assertEquals(id, id2); + } + + @Test + public void testGetComponents() throws Exception { + assertEquals(0, componentFamily.getComponents().size()); + assertEquals(0, componentFamily.getComponents().size()); + Version componentVersion = componentFamily.createComponentBasedOn( + "Test Component", "Some description", bundle); + assertEquals(1, componentFamily.getComponents().size()); + assertTrue(componentFamily.getComponents().contains( + componentVersion.getComponent())); + // componentFamily.removeComponent(componentVersion.getComponent()); + // assertEquals(0, componentFamily.getComponents().size()); + } + + @Test + public void testCreateComponentBasedOn() throws Exception { + Version componentVersion = componentFamily.createComponentBasedOn( + "Test Component", "Some description", bundle); + assertEquals("Test Component", componentVersion.getComponent() + .getName()); + } + + @Test + public void testGetComponent() throws Exception { + assertNull(componentFamily.getComponent("Test Component")); + Version componentVersion = componentFamily.createComponentBasedOn( + "Test Component", "Some description", bundle); + assertNotNull(componentFamily.getComponent("Test Component")); + assertEquals(componentVersion.getComponent(), + componentFamily.getComponent("Test Component")); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentRegistryTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentRegistryTest.java new file mode 100644 index 0000000..f5328cc --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentRegistryTest.java @@ -0,0 +1,181 @@ +package io.github.taverna_extras.component.registry; +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.net.URL; +import java.util.List; + +import io.github.taverna_extras.component.api.ComponentException; +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.profile.Profile; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * + * @author David Withers + */ +@Ignore +public abstract class ComponentRegistryTest extends Harness { + private Profile componentProfile; + + @Before + public void setup() throws Exception { + URL componentProfileUrl = getClass().getClassLoader().getResource( + "ValidationComponent.xml"); + assertNotNull(componentProfileUrl); + componentProfile = util.getProfile(componentProfileUrl); + } + + @After + public void tearDown() throws Exception { + for (Family componentFamily : componentRegistry.getComponentFamilies()) { + componentRegistry.removeComponentFamily(componentFamily); + } + } + + @Test + public void testGetComponentFamilies() throws Exception { + assertEquals(0, componentRegistry.getComponentFamilies().size()); + assertEquals(0, componentRegistry.getComponentFamilies().size()); + Family componentFamily = componentRegistry.createComponentFamily( + "TestComponentFamily", componentProfile, "Some description", + null, null); + assertEquals(1, componentRegistry.getComponentFamilies().size()); + assertTrue(componentRegistry.getComponentFamilies().contains( + componentFamily)); + componentRegistry.removeComponentFamily(componentFamily); + assertEquals(0, componentRegistry.getComponentFamilies().size()); + } + + @Test + public void testGetComponentFamily() throws Exception { + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + Family componentFamily = componentRegistry.createComponentFamily( + "TestComponentFamily", componentProfile, "Some description", + null, null); + assertNotNull(componentRegistry + .getComponentFamily("TestComponentFamily")); + assertNotNull(componentRegistry + .getComponentFamily("TestComponentFamily")); + assertEquals(componentFamily, + componentRegistry.getComponentFamily("TestComponentFamily")); + componentRegistry.removeComponentFamily(componentFamily); + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + } + + @Test + public void testCreateComponentFamily() throws Exception { + assertEquals(0, componentRegistry.getComponentFamilies().size()); + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + Family componentFamily = componentRegistry.createComponentFamily( + "TestComponentFamily", componentProfile, "Some description", + null, null); + assertEquals("TestComponentFamily", componentFamily.getName()); + assertEquals(componentRegistry, componentFamily.getComponentRegistry()); + assertEquals(0, componentFamily.getComponents().size()); + // assertEquals(componentProfile, + // componentFamily.getComponentProfile()); + assertEquals(1, componentRegistry.getComponentFamilies().size()); + assertNotNull(componentRegistry + .getComponentFamily("TestComponentFamily")); + assertEquals(componentFamily, + componentRegistry.getComponentFamily("TestComponentFamily")); + } + + @Test(expected = ComponentException.class) + public void testCreateComponentFamilyDuplicate() throws Exception { + componentRegistry.createComponentFamily("TestComponentFamily", + componentProfile, "Some description", null, null); + componentRegistry.createComponentFamily("TestComponentFamily", + componentProfile, "Some description", null, null); + } + + @Test(expected = ComponentException.class) + public void testCreateComponentFamilyNullProfile() throws Exception { + componentRegistry.createComponentFamily("TestComponentFamily", null, + "Some description", null, null); + } + + @Test(expected = ComponentException.class) + public void testCreateComponentFamilyNullName() throws Exception { + componentRegistry.createComponentFamily(null, componentProfile, + "Some description", null, null); + } + + @Test + public void testRemoveComponentFamily() throws Exception { + assertEquals(0, componentRegistry.getComponentFamilies().size()); + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + Family componentFamily = componentRegistry.createComponentFamily( + "TestComponentFamily", componentProfile, "Some description", + null, null); + assertEquals(1, componentRegistry.getComponentFamilies().size()); + assertNotNull(componentRegistry + .getComponentFamily("TestComponentFamily")); + assertEquals(componentFamily, + componentRegistry.getComponentFamily("TestComponentFamily")); + componentRegistry.removeComponentFamily(componentFamily); + assertEquals(0, componentRegistry.getComponentFamilies().size()); + assertNull(componentRegistry.getComponentFamily("TestComponentFamily")); + } + + @Test + public void testGetResistryBase() throws Exception { + assertEquals(componentRegistryUrl, componentRegistry.getRegistryBase()); + } + + @Test + public void testGetComponentProfiles() throws Exception { + assertNotNull(componentRegistry.getComponentProfiles()); + } + + @Test + public void testAddComponentProfile() throws Exception { + List<Profile> componentProfiles = componentRegistry + .getComponentProfiles(); + boolean contained = false; + for (Profile p : componentProfiles) { + if (p.getId().equals(componentProfile.getId())) { + contained = true; + } + } + assertFalse(contained); + int componentProfileCount = componentProfiles.size(); + componentRegistry.addComponentProfile(componentProfile, null, null); + int newSize = componentRegistry.getComponentProfiles().size(); + assertEquals(componentProfileCount + 1, newSize); + } + + @Test(expected = ComponentException.class) + public void testAddComponentProfileNullProfile() throws Exception { + componentRegistry.addComponentProfile(null, null, null); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentTest.java new file mode 100644 index 0000000..0ced0c8 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentTest.java @@ -0,0 +1,111 @@ +package io.github.taverna_extras.component.registry; +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.net.URL; + +import io.github.taverna_extras.component.api.Component; +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.api.profile.Profile; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; + +/** + * + * + * @author David Withers + */ +@Ignore +public class ComponentTest extends Harness { + private Family componentFamily; + private Component component; + private WorkflowBundle bundle; + + @Before + public void setUp() throws Exception { + URL dataflowUrl = getClass().getClassLoader().getResource( + "beanshell_test.t2flow"); + assertNotNull(dataflowUrl); + bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); + URL componentProfileUrl = getClass().getClassLoader().getResource( + "ValidationComponent.xml"); + assertNotNull(componentProfileUrl); + Profile componentProfile = util + .getProfile(componentProfileUrl); + componentFamily = componentRegistry.createComponentFamily( + "Test Component Family", componentProfile, "Some description", + null, null); + component = componentFamily.createComponentBasedOn("Test Component", + "Some description", bundle).getComponent(); + } + + @After + public void tearDown() throws Exception { + componentRegistry.removeComponentFamily(componentFamily); + } + + @Test + public void testGetName() throws Exception { + assertEquals("Test Component", component.getName()); + assertEquals("Test Component", component.getName()); + } + + @Test + public void testGetComponentVersionMap() throws Exception { + assertNotNull(component.getComponentVersionMap()); + assertEquals(1, component.getComponentVersionMap().size()); + assertEquals(component, component.getComponentVersionMap().get(1) + .getComponent()); + } + + @Test + public void testGetComponentVersion() throws Exception { + assertNotNull(component.getComponentVersion(1)); + assertNull(component.getComponentVersion(2)); + } + + @Test + public void testAddVersionBasedOn() throws Exception { + assertNotNull(component.getComponentVersion(1)); + assertNull(component.getComponentVersion(2)); + Version componentVersion = component.addVersionBasedOn(bundle, + "Some description"); + assertNotNull(componentVersion); + assertEquals(component, componentVersion.getComponent()); + assertEquals(2, componentVersion.getVersionNumber().intValue()); + assertEquals(bundle.getIdentifier(), componentVersion.getImplementation() + .getIdentifier()); + } + + @Test + public void testGetComponentURL() throws Exception { + assertNotNull(component.getComponentURL()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentVersionTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentVersionTest.java new file mode 100644 index 0000000..48b320b --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/ComponentVersionTest.java @@ -0,0 +1,94 @@ +package io.github.taverna_extras.component.registry; +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.net.URL; + +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.api.profile.Profile; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; + +/** + * + * + * @author David Withers + */ +@Ignore +public class ComponentVersionTest extends Harness { + private Family componentFamily; + private WorkflowBundle bundle; + private Version componentVersion; + + @Before + public void setUp() throws Exception { + URL dataflowUrl = getClass().getClassLoader().getResource( + "beanshell_test.t2flow"); + assertNotNull(dataflowUrl); + bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); + URL componentProfileUrl = getClass().getClassLoader().getResource( + "ValidationComponent.xml"); + assertNotNull(componentProfileUrl); + Profile componentProfile = util.getProfile(componentProfileUrl); + componentFamily = componentRegistry.createComponentFamily( + "Test Component Family", componentProfile, "Some description", + null, null); + componentVersion = componentFamily.createComponentBasedOn( + "Test Component", "Some description", bundle); + } + + @After + public void tearDown() throws Exception { + componentRegistry.removeComponentFamily(componentFamily); + } + + @Test + public void testGetVersionNumber() throws Exception { + assertNotNull(componentVersion.getVersionNumber()); + assertEquals(componentVersion.getVersionNumber(), + componentVersion.getVersionNumber()); + } + + @Test + public void testGetDescription() throws Exception { + assertNotNull(componentVersion.getDescription()); + } + + @Test + public void testGetDataflow() throws Exception { + assertNotNull(componentVersion.getImplementation()); + assertEquals(bundle.getIdentifier(), componentVersion.getImplementation() + .getIdentifier()); + } + + @Test + public void testGetComponent() throws Exception { + assertNotNull(componentVersion.getComponent()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/Harness.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/Harness.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/Harness.java new file mode 100644 index 0000000..663704c --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/Harness.java @@ -0,0 +1,30 @@ +package io.github.taverna_extras.component.registry; +/* + * 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. + */ + +import java.net.URL; + +import io.github.taverna_extras.component.api.Registry; +import io.github.taverna_extras.component.registry.ComponentUtil; + +public class Harness { + public static URL componentRegistryUrl; + public static Registry componentRegistry; + public static ComponentUtil util; +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentFamilyTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentFamilyTest.java new file mode 100644 index 0000000..b5791e8 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentFamilyTest.java @@ -0,0 +1,40 @@ +package io.github.taverna_extras.component.registry.local; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentFamilyTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * + * + * @author David Withers + */ +public class LocalComponentFamilyTest extends ComponentFamilyTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentRegistryTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentRegistryTest.java new file mode 100644 index 0000000..2a57e1c --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentRegistryTest.java @@ -0,0 +1,59 @@ +package io.github.taverna_extras.component.registry.local; +/* + * 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. + */ + +import static org.junit.Assert.assertSame; + +import io.github.taverna_extras.component.api.Registry; +import io.github.taverna_extras.component.registry.ComponentRegistryTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * + * @author David Withers + */ +public class LocalComponentRegistryTest extends ComponentRegistryTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } + + @Test + public void testGetComponentRegistry() throws Exception { + Registry getAgain = RegistrySupport.factory + .getComponentRegistry(componentRegistryUrl); + assertSame(componentRegistry, getAgain); + } + + @Test + @Ignore("broken") + @Override + public void testAddComponentProfile() throws Exception { + super.testAddComponentProfile(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentTest.java new file mode 100644 index 0000000..f82e591 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentTest.java @@ -0,0 +1,40 @@ +package io.github.taverna_extras.component.registry.local; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * + * + * @author David Withers + */ +public class LocalComponentTest extends ComponentTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentVersionTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentVersionTest.java new file mode 100644 index 0000000..f08425e --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/LocalComponentVersionTest.java @@ -0,0 +1,40 @@ +package io.github.taverna_extras.component.registry.local; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentVersionTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** + * + * + * @author David Withers + */ +public class LocalComponentVersionTest extends ComponentVersionTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/RegistrySupport.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/RegistrySupport.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/RegistrySupport.java new file mode 100644 index 0000000..cac3eff --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/local/RegistrySupport.java @@ -0,0 +1,44 @@ +package io.github.taverna_extras.component.registry.local; +/* + * 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. + */ + +import static java.lang.System.getProperty; +import static org.apache.commons.io.FileUtils.deleteDirectory; +import static io.github.taverna_extras.component.registry.Harness.componentRegistry; +import static io.github.taverna_extras.component.registry.Harness.componentRegistryUrl; + +import java.io.File; + +import io.github.taverna_extras.component.registry.local.LocalComponentRegistryFactory; + +class RegistrySupport { + private static File testRegistry; + final static LocalComponentRegistryFactory factory = new LocalComponentRegistryFactory(); + + public static void pre() throws Exception { + testRegistry = new File(getProperty("java.io.tmpdir"), "TestRegistry"); + testRegistry.mkdir(); + componentRegistryUrl = testRegistry.toURI().toURL(); + componentRegistry = factory.getComponentRegistry(componentRegistryUrl); + } + + public static void post() throws Exception { + deleteDirectory(testRegistry); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentFamilyTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentFamilyTest.java new file mode 100644 index 0000000..bb06af5 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentFamilyTest.java @@ -0,0 +1,42 @@ +package io.github.taverna_extras.component.registry.standard; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentFamilyTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; + +/** + * + * + * @author David Withers + */ +@Ignore +public class NewComponentFamilyTest extends ComponentFamilyTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentRegistryTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentRegistryTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentRegistryTest.java new file mode 100644 index 0000000..86417d5 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentRegistryTest.java @@ -0,0 +1,75 @@ +package io.github.taverna_extras.component.registry.standard; +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +import java.net.URL; + +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.registry.ComponentRegistryTest; +import io.github.taverna_extras.component.registry.standard.NewComponent; +import io.github.taverna_extras.component.registry.standard.NewComponentRegistry; +import io.github.taverna_extras.component.registry.standard.Policy; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; + +/** + * + * + * @author David Withers + */ +@Ignore("affects remote service") +public class NewComponentRegistryTest extends ComponentRegistryTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } + + @Test + public void testGetComponentRegistry() throws Exception { + assertSame(componentRegistry, + RegistrySupport.factory.getComponentRegistry(componentRegistryUrl)); + } + + @Test + public void testUploadWorkflow() throws Exception { + URL dataflowUrl = getClass().getClassLoader().getResource( + "beanshell_test.t2flow"); + WorkflowBundle bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); + + NewComponentRegistry registry = (NewComponentRegistry) RegistrySupport.factory.getComponentRegistry(componentRegistryUrl); + Version v = registry.createComponentFrom(null, "Test Workflow", + "test description", bundle, null, Policy.PRIVATE); + assertEquals("test description", v.getDescription()); + registry.deleteComponent((NewComponent) v.getComponent()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentTest.java new file mode 100644 index 0000000..2281cb0 --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentTest.java @@ -0,0 +1,42 @@ +package io.github.taverna_extras.component.registry.standard; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; + +/** + * + * + * @author David Withers + */ +@Ignore +public class NewComponentTest extends ComponentTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentVersionTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentVersionTest.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentVersionTest.java new file mode 100644 index 0000000..cad04eb --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/NewComponentVersionTest.java @@ -0,0 +1,42 @@ +package io.github.taverna_extras.component.registry.standard; +/* + * 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. + */ + +import io.github.taverna_extras.component.registry.ComponentVersionTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Ignore; + +/** + * + * + * @author David Withers + */ +@Ignore +public class NewComponentVersionTest extends ComponentVersionTest { + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RegistrySupport.pre(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + RegistrySupport.post(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/RegistrySupport.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/RegistrySupport.java b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/RegistrySupport.java new file mode 100644 index 0000000..a1d0fef --- /dev/null +++ b/taverna-component-activity/src/test/java/io/github/taverna_extras/component/registry/standard/RegistrySupport.java @@ -0,0 +1,55 @@ +package io.github.taverna_extras.component.registry.standard; +/* + * 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. + */ + +import static io.github.taverna_extras.component.registry.Harness.componentRegistry; +import static io.github.taverna_extras.component.registry.Harness.componentRegistryUrl; + +import java.net.URL; + +import io.github.taverna_extras.component.api.Component; +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.profile.Profile; +import io.github.taverna_extras.component.registry.standard.NewComponent; +import io.github.taverna_extras.component.registry.standard.NewComponentFamily; +import io.github.taverna_extras.component.registry.standard.NewComponentRegistry; +import io.github.taverna_extras.component.registry.standard.NewComponentRegistryFactory; + +class RegistrySupport { + static final String DEPLOYMENT = "http://aeon.cs.man.ac.uk:3006"; + static final NewComponentRegistryFactory factory = new NewComponentRegistryFactory();// FIXME + + public static void pre() throws Exception { + componentRegistryUrl = new URL(DEPLOYMENT); + componentRegistry = factory.getComponentRegistry(componentRegistryUrl); + } + + public static void post() throws Exception { + NewComponentRegistry registry = (NewComponentRegistry) factory + .getComponentRegistry(componentRegistryUrl); + for (Profile p : registry.getComponentProfiles()) + registry.client.delete("/file.xml", "id=" + p.getId()); + for (Family f : registry.getComponentFamilies()) { + for (Component c : f.getComponents()) + registry.deleteComponent((NewComponent) c); + registry.client.delete("/pack.xml", "id=" + + ((NewComponentFamily) f).getId()); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/AnnotationTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/AnnotationTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/AnnotationTest.java deleted file mode 100644 index 6b885c3..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/AnnotationTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.github.taverna_extras.component; -/* - * 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. - */ - -import static org.junit.Assert.*; - -import java.io.IOException; - -import io.github.taverna_extras.component.utils.AnnotationUtils; -import org.junit.Test; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.ReaderException; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; - -public class AnnotationTest { - //org.apache.taverna.scufl2.annotation.AnnotationTools anntoo; - @Test - public void test() throws ReaderException, IOException { - AnnotationUtils au = new AnnotationUtils(); - WorkflowBundleIO b = new WorkflowBundleIO(); - final String WORKFLOW_FILE = "/hello_anyone.wfbundle"; - final String TITLE = "Hello Anyone"; - final String DESC = "An extension to helloworld.t2flow - this workflow takes a workflow input \"name\" which is combined with the string constant \"Hello, \" using the local worker \"Concatenate two strings\", and outputs the produced string to the workflow output \"greeting\"."; - - WorkflowBundle bdl = b.readBundle( - getClass().getResource(WORKFLOW_FILE), null); - assertEquals(TITLE, au.getTitle(bdl, "---NOT---GIVEN---")); - assertEquals(DESC, au.getDescription(bdl, "---NOT---GIVEN---")); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/ComponentActivityTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/ComponentActivityTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/ComponentActivityTest.java deleted file mode 100644 index 63ce804..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/ComponentActivityTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package io.github.taverna_extras.component; -/* - * 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. - */ - -import io.github.taverna_extras.component.activity.ComponentActivity; -import io.github.taverna_extras.component.activity.ComponentActivityConfigurationBean; -import io.github.taverna_extras.component.activity.ComponentActivityFactory; - - -public class ComponentActivityTest { - - @SuppressWarnings("unused") - private ComponentActivityConfigurationBean configBean; - - @SuppressWarnings("unused") - private ComponentActivity activity = new ComponentActivityFactory().createActivity(); // FIXME - -/* @Before - public void makeConfigBean() throws Exception { - configBean = new ComponentActivityConfigurationBean(); - configBean.setExampleString("something"); - configBean - .setExampleUri(URI.create("http://localhost:8080/myEndPoint")); - } - - @Test(expected = ActivityConfigurationException.class) - public void invalidConfiguration() throws ActivityConfigurationException { - ComponentActivityConfigurationBean invalidBean = new ComponentActivityConfigurationBean(); - invalidBean.setExampleString("invalidExample"); - // Should throw ActivityConfigurationException - activity.configure(invalidBean); - } - - @Test - public void executeAsynch() throws Exception { - activity.configure(configBean); - - Map<String, Object> inputs = new HashMap<String, Object>(); - inputs.put("firstInput", "hello"); - - Map<String, Class<?>> expectedOutputTypes = new HashMap<String, Class<?>>(); - expectedOutputTypes.put("simpleOutput", String.class); - expectedOutputTypes.put("moreOutputs", String.class); - - Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity( - activity, inputs, expectedOutputTypes); - - assertEquals("Unexpected outputs", 2, outputs.size()); - assertEquals("simple", outputs.get("simpleOutput")); - assertEquals(Arrays.asList("Value 1", "Value 2"), outputs - .get("moreOutputs")); - - } - - @Test - public void reConfiguredActivity() throws Exception { - assertEquals("Unexpected inputs", 0, activity.getInputPorts().size()); - assertEquals("Unexpected outputs", 0, activity.getOutputPorts().size()); - - activity.configure(configBean); - assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); - assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); - - activity.configure(configBean); - // Should not change on reconfigure - assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); - assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); - } - - @Test - public void reConfiguredSpecialPorts() throws Exception { - activity.configure(configBean); - - ComponentActivityConfigurationBean specialBean = new ComponentActivityConfigurationBean(); - specialBean.setExampleString("specialCase"); - specialBean.setExampleUri(URI - .create("http://localhost:8080/myEndPoint")); - activity.configure(specialBean); - // Should now have added the optional ports - assertEquals("Unexpected inputs", 2, activity.getInputPorts().size()); - assertEquals("Unexpected outputs", 3, activity.getOutputPorts().size()); - } - - @Test - public void configureActivity() throws Exception { - Set<String> expectedInputs = new HashSet<String>(); - expectedInputs.add("firstInput"); - - Set<String> expectedOutputs = new HashSet<String>(); - expectedOutputs.add("simpleOutput"); - expectedOutputs.add("moreOutputs"); - - activity.configure(configBean); - - Set<ActivityInputPort> inputPorts = activity.getInputPorts(); - assertEquals(expectedInputs.size(), inputPorts.size()); - for (ActivityInputPort inputPort : inputPorts) { - assertTrue("Wrong input : " + inputPort.getName(), expectedInputs - .remove(inputPort.getName())); - } - - Set<OutputPort> outputPorts = activity.getOutputPorts(); - assertEquals(expectedOutputs.size(), outputPorts.size()); - for (OutputPort outputPort : outputPorts) { - assertTrue("Wrong output : " + outputPort.getName(), - expectedOutputs.remove(outputPort.getName())); - } - }*/ -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentFamilyTest.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentFamilyTest.java b/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentFamilyTest.java deleted file mode 100644 index 29e4473..0000000 --- a/taverna-component-activity/src/test/java/org/apache/taverna/component/registry/ComponentFamilyTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package io.github.taverna_extras.component.registry; -/* - * 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. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.net.URL; - -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.api.profile.Profile; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; - -/** - * - * - * @author David Withers - */ -@Ignore -public class ComponentFamilyTest extends Harness { - private Family componentFamily; - private Profile componentProfile; - private WorkflowBundle bundle; - - @Before - public void setup() throws Exception { - URL componentProfileUrl = getClass().getClassLoader().getResource( - "ValidationComponent.xml"); - assertNotNull(componentProfileUrl); - componentProfile = util.getProfile(componentProfileUrl); - componentRegistry.addComponentProfile(componentProfile, null, null); - URL dataflowUrl = getClass().getClassLoader().getResource( - "beanshell_test.t2flow"); - assertNotNull(dataflowUrl); - bundle = new WorkflowBundleIO().readBundle(dataflowUrl, null); - componentFamily = componentRegistry.createComponentFamily( - "Test Component Family", componentProfile, "Some description", - null, null); - } - - @After - public void tearDown() throws Exception { - componentRegistry.removeComponentFamily(componentFamily); - } - - @Test - public void testGetComponentRegistry() throws Exception { - assertEquals(componentRegistry, componentFamily.getComponentRegistry()); - } - - @Test - public void testGetName() throws Exception { - assertEquals("Test Component Family", componentFamily.getName()); - assertEquals("Test Component Family", componentFamily.getName()); - } - - @Test - public void testGetComponentProfile() throws Exception { - Profile componentProfile2 = componentFamily.getComponentProfile(); - assertNotNull(componentProfile2); - String id = componentProfile.getId(); - String id2 = componentProfile2.getId(); - assertEquals(id, id2); - } - - @Test - public void testGetComponents() throws Exception { - assertEquals(0, componentFamily.getComponents().size()); - assertEquals(0, componentFamily.getComponents().size()); - Version componentVersion = componentFamily.createComponentBasedOn( - "Test Component", "Some description", bundle); - assertEquals(1, componentFamily.getComponents().size()); - assertTrue(componentFamily.getComponents().contains( - componentVersion.getComponent())); - // componentFamily.removeComponent(componentVersion.getComponent()); - // assertEquals(0, componentFamily.getComponents().size()); - } - - @Test - public void testCreateComponentBasedOn() throws Exception { - Version componentVersion = componentFamily.createComponentBasedOn( - "Test Component", "Some description", bundle); - assertEquals("Test Component", componentVersion.getComponent() - .getName()); - } - - @Test - public void testGetComponent() throws Exception { - assertNull(componentFamily.getComponent("Test Component")); - Version componentVersion = componentFamily.createComponentBasedOn( - "Test Component", "Some description", bundle); - assertNotNull(componentFamily.getComponent("Test Component")); - assertEquals(componentVersion.getComponent(), - componentFamily.getComponent("Test Component")); - } - -}
