You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:38:17 UTC
[33/51] [partial] incubator-taverna-engine git commit:
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
deleted file mode 100644
index fc445ae..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetServiceTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-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.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.ReferenceSetDao;
-import net.sf.taverna.t2.reference.WorkflowRunIdEntity;
-
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReferenceSetServiceTest {
-
- private List<ReferenceSetServiceImpl> serviceList = new ArrayList<ReferenceSetServiceImpl>();
-
- @Before
- public void setup() throws Exception {
-
- AppContextSetup.setup();
-
- ReferenceSetServiceImpl service = null;
-
- service = new ReferenceSetServiceImpl();
- service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(0).getBean("testDao")); // hibernate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- service = new ReferenceSetServiceImpl();
- service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(1).getBean("testDao")); // in memory
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- service = new ReferenceSetServiceImpl();
- service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(2).getBean("testDao")); // transactional hibernate
- service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
- serviceList.add(service);
-
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testDelete() throws Exception {
- ReferenceContextImpl invocationContext = new ReferenceContextImpl();
- invocationContext.addEntity(new WorkflowRunIdEntity("wfRunRefSetTest0"));
- for (ReferenceSetServiceImpl service : serviceList){
- ReferenceSet set = service.registerReferenceSet(new HashSet(), invocationContext);
- assertNotNull(service.getReferenceSet(set.getId()));
- assertTrue(service.delete(set.getId()));
- assertNull(service.getReferenceSet(set.getId()));
- assertFalse(service.delete(set.getId()));
- }
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testDeleteReferenceSetsForWFRun() throws Exception {
-
- for (ReferenceSetServiceImpl service : serviceList){
-
- String wfRunId1 = "wfRunRefSetTest1";
- ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
- invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
-
- String wfRunId2 = "wfRunRefSetTest2";
- ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
- invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
-
- ReferenceSet set1 = service.registerReferenceSet(new HashSet(), invocationContext1);
- ReferenceSet set2 = service.registerReferenceSet(new HashSet(), invocationContext1);
- ReferenceSet set3 = service.registerReferenceSet(new HashSet(), invocationContext2);
-
- assertNotNull(service.getReferenceSet(set1.getId()));
- assertNotNull(service.getReferenceSet(set2.getId()));
- assertNotNull(service.getReferenceSet(set3.getId()));
-
- service.deleteReferenceSetsForWorkflowRun(wfRunId1);
-
- assertNull(service.getReferenceSet(set1.getId()));
- assertNull(service.getReferenceSet(set2.getId()));
- assertNotNull(service.getReferenceSet(set3.getId()));
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
deleted file mode 100644
index 35d6f64..0000000
--- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/TranslationPathTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.sf.taverna.t2.reference.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2referencetest.DummyReferenceSet;
-import net.sf.taverna.t2referencetest.GreenBuilder;
-import net.sf.taverna.t2referencetest.GreenReference;
-import net.sf.taverna.t2referencetest.GreenToRed;
-import net.sf.taverna.t2referencetest.RedReference;
-
-import org.junit.Test;
-
-public class TranslationPathTest {
-
- protected TranslationPath path = new TranslationPath();
-
- @Test
- public void doTranslationWithTranslator() throws Exception {
- ReferenceContext context = new EmptyReferenceContext();
- ReferenceSet rs = new DummyReferenceSet(new GreenReference("green"));
- path.getTranslators().add(new GreenToRed());
- Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);
- assertEquals(1, set.size());
- assertTrue(set.iterator().next() instanceof RedReference);
- }
-
- @Test
- public void doTranslationByReadingStream() throws Exception {
- ReferenceContext context = new EmptyReferenceContext();
- path.setSourceReference(new RedReference("red"));
- ReferenceSet rs = new DummyReferenceSet(path.getSourceReference());
- path.setInitialBuilder(new GreenBuilder());
- //augmentor.path.translators.add(new DummyTranslator());
- Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);
- assertEquals(1, set.size());
- assertTrue(set.iterator().next() instanceof GreenReference);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
new file mode 100644
index 0000000..2432cbb
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/platform/spring/jdbc/TemporaryJDBCTest.java
@@ -0,0 +1,59 @@
+/*
+* 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.taverna.platform.spring.jdbc;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.Test;
+
+/**
+ * Test {@link TemporaryJDBC}
+ *
+ * @author Stian Soiland-Reyes
+ *
+ */
+public class TemporaryJDBCTest {
+
+ private static final String DB = ".db";
+ private static final String T2PLATFORM = "t2platform-";
+ private static final String CREATE_TRUE = ";create=true";
+ private static final String JDBC_DERBY = "jdbc:derby:";
+
+ @Test
+ public void getDerby() throws Exception {
+ TemporaryJDBC temporaryJDBC = new TemporaryJDBC();
+ String jdbcURL = temporaryJDBC.getTemporaryDerbyJDBC();
+ assertTrue("Not a Derby URL", jdbcURL.startsWith(JDBC_DERBY));
+ String url = jdbcURL.split(JDBC_DERBY)[1];
+ assertTrue("Did not end with " + CREATE_TRUE, url.endsWith(CREATE_TRUE));
+ String location = url.split(CREATE_TRUE)[0];
+ assertFalse("Location was an empty string", location.equals(""));
+ File locationFile = new File(location);
+ assertFalse("File already exists: " + locationFile, locationFile.exists());
+ File parentFile = locationFile.getParentFile();
+ assertTrue("Parent directory did not exist", parentFile.isDirectory());
+ assertTrue("Did not end with " + T2PLATFORM, parentFile.getName().startsWith(T2PLATFORM));
+ assertTrue("Did not start with " + DB , parentFile.getName().endsWith(DB));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
new file mode 100644
index 0000000..fb3d1f0
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/AppContextSetup.java
@@ -0,0 +1,50 @@
+/*
+* 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.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class AppContextSetup {
+ public static List<ApplicationContext> contextList;
+
+ public static void setup() throws Exception {
+ if (contextList == null){
+
+ contextList = new ArrayList<ApplicationContext>();
+ //Add all three contexts for storing referenced data
+ contextList = new ArrayList<ApplicationContext>();
+ ApplicationContext context = null;
+ context = new ClassPathXmlApplicationContext(
+ "vanillaHibernateAppContext.xml"); // hibernate context
+ contextList.add(context);
+ context = new ClassPathXmlApplicationContext(
+ "vanillaInMemoryAppContext.xml");
+ contextList.add(context); // in memory
+ context = new ClassPathXmlApplicationContext(
+ "vanillaHibernateTransactionalAppContext.xml");
+ contextList.add(context); // transactional hibernate context
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
new file mode 100644
index 0000000..265719c
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/DatabaseSetupTest.java
@@ -0,0 +1,139 @@
+/*
+* 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.taverna.reference.impl;
+
+import java.util.HashSet;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Tests initialization of the Derby database and Hibernate ORM system
+ *
+ * @author Tom Oinn
+ */
+public class DatabaseSetupTest {
+
+ @Before
+ public void setup() throws Exception {
+ AppContextSetup.setup();
+ }
+
+
+ @Test
+ public void testListStorage() {
+ ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
+ ListDao o = (ListDao) context.getBean("testListDao");
+ T2ReferenceImpl listReference = new T2ReferenceImpl();
+ listReference.setContainsErrors(false);
+ listReference.setDepth(1);
+ listReference.setLocalPart("list1");
+ listReference.setNamespacePart("testNamespace");
+ listReference.setReferenceType(T2ReferenceType.IdentifiedList);
+
+ T2ReferenceListImpl l = new T2ReferenceListImpl();
+
+ T2ReferenceImpl itemId1 = new T2ReferenceImpl();
+ itemId1.setNamespacePart("testNamespace");
+ itemId1.setLocalPart("item1");
+ T2ReferenceImpl itemId2 = new T2ReferenceImpl();
+ itemId2.setNamespacePart("testNamespace");
+ itemId2.setLocalPart("item2");
+
+ l.add(itemId1);
+ l.add(itemId2);
+
+ l.setTypedId(listReference);
+
+ System.out.println(l);
+
+ o.store(l);
+
+ T2ReferenceImpl listReference2 = new T2ReferenceImpl();
+ listReference2.setContainsErrors(false);
+ listReference2.setDepth(1);
+ listReference2.setLocalPart("list1");
+ listReference2.setNamespacePart("testNamespace");
+ listReference2.setReferenceType(T2ReferenceType.IdentifiedList);
+
+ System.out.println(o.get(listReference2));
+
+ }
+
+ @SuppressWarnings("serial")
+ @Test
+ public void testDatabaseReadWriteWithoutPlugins() {
+ ApplicationContext context = AppContextSetup.contextList.get(0); // Hibernate context
+ ReferenceSetDao o = (ReferenceSetDao) context
+ .getBean("testDao");
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setNamespacePart("testNamespace");
+ id.setLocalPart("testLocal");
+ ReferenceSetImpl rs = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id);
+ o.store(rs);
+
+
+ // Retrieve with a new instance of an anonymous subclass of
+ // ReferenceSetT2ReferenceImpl, just to check that hibernate can cope
+ // with this. It can, but this *must* be a subclass of the registered
+ // component type, which means we need to modify the component type to
+ // be the fully generic T2Reference with all fields accessed via
+ // properties.
+ T2Reference newReference = new T2ReferenceImpl() {
+
+ @Override
+ public boolean containsErrors() {
+ return false;
+ }
+
+ @Override
+ public int getDepth() {
+ return 0;
+ }
+
+ @Override
+ public String getLocalPart() {
+ return "testLocal";
+ }
+
+ @Override
+ public String getNamespacePart() {
+ return "testNamespace";
+ }
+
+ };
+
+
+ ReferenceSet returnedset = o.get(newReference);
+ Assert.assertNotNull(returnedset.getId());
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
new file mode 100644
index 0000000..107986d
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentDaoTest.java
@@ -0,0 +1,170 @@
+/*
+* 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.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ErrorDocumentDaoTest {
+
+ @Before
+ public void setup() throws Exception {
+ AppContextSetup.setup();
+ }
+
+ @Test
+ public void testStore() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+
+ ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+ ErrorDocumentImpl doc = new ErrorDocumentImpl();
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setReferenceType(T2ReferenceType.ErrorDocument);
+ id.setDepth(0);
+ id.setContainsErrors(true);
+ id.setNamespacePart("testNamespace0");
+ id.setLocalPart("testLocal0");
+
+ doc.setExceptionMessage("An exception");
+
+ T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+
+ doc.setTypedId(typedId);
+
+ dao.store(doc);
+ assertNotNull(dao.get(id));
+ }
+ }
+
+ /**
+ * Tests that .get returns null when its missing, rather than throw an exception
+ */
+ @Test
+ public void getMissingItemReturnsNull() {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+ ErrorDocumentImpl doc = new ErrorDocumentImpl();
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setReferenceType(T2ReferenceType.ErrorDocument);
+ id.setDepth(0);
+ id.setContainsErrors(true);
+ id.setNamespacePart("testNamespace1");
+ id.setLocalPart("testLocal1");
+
+ doc.setExceptionMessage("An exception");
+
+ T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+
+ doc.setTypedId(typedId);
+ assertNull(dao.get(id));
+ }
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+
+ ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+ ErrorDocumentImpl doc = new ErrorDocumentImpl();
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setReferenceType(T2ReferenceType.ErrorDocument);
+ id.setDepth(0);
+ id.setContainsErrors(true);
+ id.setNamespacePart("testNamespace2");
+ id.setLocalPart("testLocal2");
+
+ doc.setExceptionMessage("An exception");
+
+ T2ReferenceImpl typedId = T2ReferenceImpl.getAsImpl(id);
+
+ doc.setTypedId(typedId);
+
+ dao.store(doc);
+ assertNotNull(dao.get(id));
+
+ assertTrue(dao.delete(doc));
+ assertNull(dao.get(id));
+ }
+
+ }
+
+ @Test
+ public void testDeleteErrorDocumentsForWFRun() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+
+ ErrorDocumentDao dao = (ErrorDocumentDao) context.getBean("testErrorDao");
+
+ ErrorDocumentImpl doc1 = new ErrorDocumentImpl();
+ T2ReferenceImpl id1 = new T2ReferenceImpl();
+ id1.setReferenceType(T2ReferenceType.ErrorDocument);
+ id1.setDepth(0);
+ id1.setContainsErrors(true);
+ id1.setNamespacePart("wfRunErrorDocTest1");
+ id1.setLocalPart("testLocal1");
+ doc1.setExceptionMessage("An exception 1");
+ T2ReferenceImpl typedId1 = T2ReferenceImpl.getAsImpl(id1);
+ doc1.setTypedId(typedId1);
+ dao.store(doc1);
+ assertNotNull(dao.get(id1));
+
+ ErrorDocumentImpl doc2 = new ErrorDocumentImpl();
+ T2ReferenceImpl id2 = new T2ReferenceImpl();
+ id2.setReferenceType(T2ReferenceType.ErrorDocument);
+ id2.setDepth(0);
+ id2.setContainsErrors(true);
+ id2.setNamespacePart("wfRunErrorDocTest1");
+ id2.setLocalPart("testLocal2");
+ doc2.setExceptionMessage("An exception 2");
+ T2ReferenceImpl typedId2 = T2ReferenceImpl.getAsImpl(id2);
+ doc2.setTypedId(typedId2);
+ dao.store(doc2);
+ assertNotNull(dao.get(id2));
+
+ ErrorDocumentImpl doc3 = new ErrorDocumentImpl();
+ T2ReferenceImpl id3 = new T2ReferenceImpl();
+ id3.setReferenceType(T2ReferenceType.ErrorDocument);
+ id3.setDepth(0);
+ id3.setContainsErrors(true);
+ id3.setNamespacePart("wfRunErrorDocTest2");
+ id3.setLocalPart("testLocal3");
+ doc3.setExceptionMessage("An exception 3");
+ T2ReferenceImpl typedId3 = T2ReferenceImpl.getAsImpl(id3);
+ doc3.setTypedId(typedId3);
+ dao.store(doc3);
+ assertNotNull(dao.get(id3));
+
+ dao.deleteErrorDocumentsForWFRun("wfRunErrorDocTest1");
+
+ assertNull(dao.get(id1));
+ assertNull(dao.get(id2));
+ assertNotNull(dao.get(id3));
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
new file mode 100644
index 0000000..a7b8425
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ErrorDocumentServiceTest.java
@@ -0,0 +1,107 @@
+/*
+* 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.taverna.reference.impl;
+
+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.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.ErrorDocument;
+import org.apache.taverna.reference.ErrorDocumentDao;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ErrorDocumentServiceTest {
+
+ private List<ErrorDocumentServiceImpl> serviceList = new ArrayList<ErrorDocumentServiceImpl>();
+
+ @Before
+ public void setup() throws Exception {
+
+ AppContextSetup.setup();
+
+ ErrorDocumentServiceImpl service = null;
+
+ service = new ErrorDocumentServiceImpl();
+ service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(0).getBean("testErrorDao")); // hiberate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ service = new ErrorDocumentServiceImpl();
+ service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(1).getBean("testErrorDao")); // in memory
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ service = new ErrorDocumentServiceImpl();
+ service.setErrorDao((ErrorDocumentDao)AppContextSetup.contextList.get(2).getBean("testErrorDao")); // transactional hibernate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+ invocationContext.addEntity(new WorkflowRunIdEntity("wfRunErrorDocTest"));
+ for (ErrorDocumentServiceImpl service : serviceList){
+ ErrorDocument doc = service.registerError("Fred", 0, invocationContext);
+ assertNotNull(service.getError(doc.getId()));
+ assertTrue(service.delete(doc.getId()));
+ assertNull(service.getError(doc.getId()));
+ assertFalse(service.delete(doc.getId()));
+ }
+ }
+
+ @Test
+ public void testDeleteErrorDocumentsForWFRun() throws Exception {
+
+ for (ErrorDocumentServiceImpl service : serviceList){
+
+ String wfRunId1 = "wfRunErrorDocTest1";
+ ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+ invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+
+ String wfRunId2 = "wfRunErrorDocTest2";
+ ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+ invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+
+ ErrorDocument doc1 = service.registerError("Fred1", 0, invocationContext1);
+ ErrorDocument doc2 = service.registerError("Fred2", 0, invocationContext1);
+ ErrorDocument doc3 = service.registerError("Fred3", 0, invocationContext2);
+
+ assertNotNull(service.getError(doc1.getId()));
+ assertNotNull(service.getError(doc2.getId()));
+ assertNotNull(service.getError(doc3.getId()));
+
+ service.deleteErrorDocumentsForWorkflowRun(wfRunId1);
+
+ assertNull(service.getError(doc1.getId()));
+ assertNull(service.getError(doc2.getId()));
+ assertNotNull(service.getError(doc3.getId()));
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
new file mode 100644
index 0000000..6ae7496
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListDaoTest.java
@@ -0,0 +1,140 @@
+/*
+* 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.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2ReferenceType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ListDaoTest {
+
+ @Before
+ public void setup() throws Exception {
+ AppContextSetup.setup();
+ }
+
+ @Test
+ public void testStore() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ListDao dao = (ListDao)context.getBean("testListDao");
+ T2ReferenceImpl r = new T2ReferenceImpl();
+ r.setNamespacePart("testNamespace0");
+ r.setLocalPart("testLocal0");
+ r.setReferenceType(T2ReferenceType.IdentifiedList);
+ r.setDepth(0);
+ r.setContainsErrors(false);
+ T2ReferenceListImpl newList = new T2ReferenceListImpl();
+ newList.setTypedId(r);
+ dao.store(newList);
+ assertNotNull(dao.get(r));
+ }
+ }
+
+ /**
+ * Tests that .get returns null when its missing, rather than throw an exception
+ */
+ @Test
+ public void getMissingItemReturnsNull() {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ListDao dao = (ListDao)context.getBean("testListDao");
+ T2ReferenceImpl r = new T2ReferenceImpl();
+ r.setNamespacePart("testNamespace1");
+ r.setLocalPart("testLocal1");
+ r.setReferenceType(T2ReferenceType.IdentifiedList);
+ r.setDepth(0);
+ r.setContainsErrors(false);
+ T2ReferenceListImpl newList = new T2ReferenceListImpl();
+ newList.setTypedId(r);
+ assertNull(dao.get(r));
+ }
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ListDao dao = (ListDao)context.getBean("testListDao");
+ T2ReferenceImpl r = new T2ReferenceImpl();
+ r.setNamespacePart("testNamespace2");
+ r.setLocalPart("testLocal2");
+ r.setReferenceType(T2ReferenceType.IdentifiedList);
+ r.setDepth(0);
+ r.setContainsErrors(false);
+ T2ReferenceListImpl newList = new T2ReferenceListImpl();
+ newList.setTypedId(r);
+ dao.store(newList);
+ assertNotNull(dao.get(r));
+ assertTrue(dao.delete(newList));
+ assertNull(dao.get(r));
+ }
+ }
+
+ @Test
+ public void testIdentifiedListsForWFRun() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ListDao dao = (ListDao)context.getBean("testListDao");
+
+ T2ReferenceImpl r1 = new T2ReferenceImpl();
+ r1.setReferenceType(T2ReferenceType.IdentifiedList);
+ r1.setDepth(0);
+ r1.setContainsErrors(true);
+ r1.setNamespacePart("wfRunListsTest1");
+ r1.setLocalPart("testLocal1");
+ T2ReferenceListImpl list1 = new T2ReferenceListImpl();
+ list1.setTypedId(r1);
+ dao.store(list1);
+ assertNotNull(dao.get(r1));
+
+ T2ReferenceImpl r2 = new T2ReferenceImpl();
+ r2.setReferenceType(T2ReferenceType.IdentifiedList);
+ r2.setDepth(1);
+ r2.setContainsErrors(true);
+ r2.setNamespacePart("wfRunListsTest1");
+ r2.setLocalPart("testLocal2");
+ T2ReferenceListImpl list2 = new T2ReferenceListImpl();
+ list2.setTypedId(r2);
+ dao.store(list2);
+ assertNotNull(dao.get(r2));
+
+ T2ReferenceImpl r3 = new T2ReferenceImpl();
+ r3.setReferenceType(T2ReferenceType.IdentifiedList);
+ r3.setDepth(0);
+ r3.setContainsErrors(true);
+ r3.setNamespacePart("wfRunListsTest2");
+ r3.setLocalPart("testLocal3");
+ T2ReferenceListImpl list3 = new T2ReferenceListImpl();
+ list3.setTypedId(r3);
+ dao.store(list3);
+ assertNotNull(dao.get(r3));
+
+ dao.deleteIdentifiedListsForWFRun("wfRunListsTest1");
+
+ assertNull(dao.get(r1));
+ assertNull(dao.get(r2));
+ assertNotNull(dao.get(r3));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
new file mode 100644
index 0000000..1d40730
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ListServiceTest.java
@@ -0,0 +1,110 @@
+/*
+* 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.taverna.reference.impl;
+
+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.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.IdentifiedList;
+import org.apache.taverna.reference.ListDao;
+import org.apache.taverna.reference.T2Reference;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ListServiceTest {
+
+ private List<ListServiceImpl> serviceList = new ArrayList<ListServiceImpl>();
+
+ @Before
+ public void setup() throws Exception {
+
+ AppContextSetup.setup();
+
+ ListServiceImpl service = null;
+
+ service = new ListServiceImpl();
+ service.setListDao((ListDao)AppContextSetup.contextList.get(0).getBean("testListDao")); // hibernate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ service = new ListServiceImpl();
+ service.setListDao((ListDao)AppContextSetup.contextList.get(1).getBean("testListDao")); // in memory
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+
+ service = new ListServiceImpl();
+ service.setListDao((ListDao)AppContextSetup.contextList.get(2).getBean("testListDao")); // transactional hibernate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+ invocationContext.addEntity(new WorkflowRunIdEntity("wfRunListsTest"));
+ for (ListServiceImpl service : serviceList){
+ IdentifiedList<T2Reference> list =service.registerEmptyList(1, invocationContext);
+ assertNotNull(service.getList(list.getId()));
+ assertTrue(service.delete(list.getId()));
+ assertNull(service.getList(list.getId()));
+ assertFalse(service.delete(list.getId()));
+ }
+ }
+
+ @Test
+ public void testDeleteIdentifiedListsForWFRun() throws Exception {
+
+ for (ListServiceImpl service : serviceList){
+
+ String wfRunId1 = "wfRunListsTest1";
+ ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+ invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+
+ String wfRunId2 = "wfRunListsTest2";
+ ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+ invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+
+ IdentifiedList<T2Reference> list1 = service.registerEmptyList(2, invocationContext1);
+ IdentifiedList<T2Reference> list2 = service.registerEmptyList(1, invocationContext1);
+ IdentifiedList<T2Reference> list3 = service.registerEmptyList(1, invocationContext2);
+
+ assertNotNull(service.getList(list1.getId()));
+ assertNotNull(service.getList(list2.getId()));
+ assertNotNull(service.getList(list3.getId()));
+
+ service.deleteIdentifiedListsForWorkflowRun(wfRunId1);
+
+ assertNull(service.getList(list1.getId()));
+ assertNull(service.getList(list2.getId()));
+ assertNotNull(service.getList(list3.getId()));
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
new file mode 100644
index 0000000..557710c
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceContextImpl.java
@@ -0,0 +1,49 @@
+/*
+* 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.taverna.reference.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceContext;
+
+class ReferenceContextImpl implements ReferenceContext{
+ private List<Object> entities;
+
+ public ReferenceContextImpl(){
+ entities = new ArrayList<Object>();
+ }
+
+ @Override
+ public <T> List<T> getEntities(Class<T> entityType) {
+ List<T> entitiesOfType = new ArrayList<T>();
+ for (Object entity : entities){
+ if (entityType.isInstance(entity)){
+ entitiesOfType.add(entityType.cast(entity));
+ }
+ }
+ return entitiesOfType;
+ }
+
+ @Override
+ public void addEntity(Object entity){
+ entities.add(entity);
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
new file mode 100644
index 0000000..6409837
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetDaoTest.java
@@ -0,0 +1,124 @@
+/*
+* 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.taverna.reference.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSetDao;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+
+public class ReferenceSetDaoTest {
+
+ @Before
+ public void setup() throws Exception {
+
+ AppContextSetup.setup();
+ }
+
+ @Test
+ public void testStore() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setNamespacePart("testNamespace0");
+ id.setLocalPart("testLocal0");
+ ReferenceSetImpl rs = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id);
+ dao.store(rs);
+ assertNotNull(dao.get(id));
+ }
+ }
+
+ @Test
+ public void testDelete() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setNamespacePart("testNamespace1");
+ id.setLocalPart("testLocal1");
+ ReferenceSetImpl rs = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id);
+ dao.store(rs);
+ assertNotNull(dao.get(id));
+ assertTrue(dao.delete(rs));
+ assertNull(dao.get(id));
+ }
+ }
+
+ @Test
+ public void testDeleteRerefenceSetsForWFRun() throws Exception {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+
+ T2ReferenceImpl id1 = new T2ReferenceImpl();
+ id1.setNamespacePart("wfRunRefSetTest1");
+ id1.setLocalPart("testLocal1");
+ ReferenceSetImpl rs1 = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id1);
+ dao.store(rs1);
+ assertNotNull(dao.get(id1));
+
+ T2ReferenceImpl id2 = new T2ReferenceImpl();
+ id2.setNamespacePart("wfRunRefSetTest1");
+ id2.setLocalPart("testLocal2");
+ ReferenceSetImpl rs2 = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id2);
+ dao.store(rs2);
+ assertNotNull(dao.get(id2));
+
+ T2ReferenceImpl id3 = new T2ReferenceImpl();
+ id3.setNamespacePart("wfRunRefSetTest2");
+ id3.setLocalPart("testLocal3");
+ ReferenceSetImpl rs3 = new ReferenceSetImpl(
+ new HashSet<ExternalReferenceSPI>(), id3);
+ dao.store(rs3);
+ assertNotNull(dao.get(id3));
+
+ dao.deleteReferenceSetsForWFRun("wfRunRefSetTest1");
+
+ assertNull(dao.get(id1));
+ assertNull(dao.get(id2));
+ assertNotNull(dao.get(id3));
+ }
+ }
+
+ /**
+ * Tests that .get returns null when its missing, rather than throw an exception
+ */
+ @Test
+ public void getMissingItemReturnsNull() {
+ for (ApplicationContext context : AppContextSetup.contextList){
+ ReferenceSetDao dao = (ReferenceSetDao) context.getBean("testDao");
+ T2ReferenceImpl id = new T2ReferenceImpl();
+ id.setNamespacePart("testNamespace2");
+ id.setLocalPart("testLocal2");
+ assertNull(dao.get(id));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
new file mode 100644
index 0000000..8eb39f4
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/ReferenceSetServiceTest.java
@@ -0,0 +1,111 @@
+/*
+* 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.taverna.reference.impl;
+
+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.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.ReferenceSetDao;
+import org.apache.taverna.reference.WorkflowRunIdEntity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ReferenceSetServiceTest {
+
+ private List<ReferenceSetServiceImpl> serviceList = new ArrayList<ReferenceSetServiceImpl>();
+
+ @Before
+ public void setup() throws Exception {
+
+ AppContextSetup.setup();
+
+ ReferenceSetServiceImpl service = null;
+
+ service = new ReferenceSetServiceImpl();
+ service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(0).getBean("testDao")); // hibernate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ service = new ReferenceSetServiceImpl();
+ service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(1).getBean("testDao")); // in memory
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ service = new ReferenceSetServiceImpl();
+ service.setReferenceSetDao((ReferenceSetDao)AppContextSetup.contextList.get(2).getBean("testDao")); // transactional hibernate
+ service.setT2ReferenceGenerator(new SimpleT2ReferenceGenerator());
+ serviceList.add(service);
+
+ }
+
+ @Test
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void testDelete() throws Exception {
+ ReferenceContextImpl invocationContext = new ReferenceContextImpl();
+ invocationContext.addEntity(new WorkflowRunIdEntity("wfRunRefSetTest0"));
+ for (ReferenceSetServiceImpl service : serviceList){
+ ReferenceSet set = service.registerReferenceSet(new HashSet(), invocationContext);
+ assertNotNull(service.getReferenceSet(set.getId()));
+ assertTrue(service.delete(set.getId()));
+ assertNull(service.getReferenceSet(set.getId()));
+ assertFalse(service.delete(set.getId()));
+ }
+ }
+
+ @Test
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void testDeleteReferenceSetsForWFRun() throws Exception {
+
+ for (ReferenceSetServiceImpl service : serviceList){
+
+ String wfRunId1 = "wfRunRefSetTest1";
+ ReferenceContextImpl invocationContext1 = new ReferenceContextImpl();
+ invocationContext1.addEntity(new WorkflowRunIdEntity(wfRunId1));
+
+ String wfRunId2 = "wfRunRefSetTest2";
+ ReferenceContextImpl invocationContext2 = new ReferenceContextImpl();
+ invocationContext2.addEntity(new WorkflowRunIdEntity(wfRunId2));
+
+ ReferenceSet set1 = service.registerReferenceSet(new HashSet(), invocationContext1);
+ ReferenceSet set2 = service.registerReferenceSet(new HashSet(), invocationContext1);
+ ReferenceSet set3 = service.registerReferenceSet(new HashSet(), invocationContext2);
+
+ assertNotNull(service.getReferenceSet(set1.getId()));
+ assertNotNull(service.getReferenceSet(set2.getId()));
+ assertNotNull(service.getReferenceSet(set3.getId()));
+
+ service.deleteReferenceSetsForWorkflowRun(wfRunId1);
+
+ assertNull(service.getReferenceSet(set1.getId()));
+ assertNull(service.getReferenceSet(set2.getId()));
+ assertNotNull(service.getReferenceSet(set3.getId()));
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
new file mode 100644
index 0000000..aae12e6
--- /dev/null
+++ b/taverna-reference-impl/src/test/java/org/apache/taverna/reference/impl/TranslationPathTest.java
@@ -0,0 +1,65 @@
+/*
+* 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.taverna.reference.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.t2referencetest.DummyReferenceSet;
+import org.apache.taverna.t2referencetest.GreenBuilder;
+import org.apache.taverna.t2referencetest.GreenReference;
+import org.apache.taverna.t2referencetest.GreenToRed;
+import org.apache.taverna.t2referencetest.RedReference;
+
+import org.junit.Test;
+
+public class TranslationPathTest {
+
+ protected TranslationPath path = new TranslationPath();
+
+ @Test
+ public void doTranslationWithTranslator() throws Exception {
+ ReferenceContext context = new EmptyReferenceContext();
+ ReferenceSet rs = new DummyReferenceSet(new GreenReference("green"));
+ path.getTranslators().add(new GreenToRed());
+ Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);
+ assertEquals(1, set.size());
+ assertTrue(set.iterator().next() instanceof RedReference);
+ }
+
+ @Test
+ public void doTranslationByReadingStream() throws Exception {
+ ReferenceContext context = new EmptyReferenceContext();
+ path.setSourceReference(new RedReference("red"));
+ ReferenceSet rs = new DummyReferenceSet(path.getSourceReference());
+ path.setInitialBuilder(new GreenBuilder());
+ //augmentor.path.translators.add(new DummyTranslator());
+ Set<ExternalReferenceSPI> set = path.doTranslation(rs, context);
+ assertEquals(1, set.size());
+ assertTrue(set.iterator().next() instanceof GreenReference);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/log4j.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/log4j.xml b/taverna-reference-impl/src/test/resources/log4j.xml
index f1f4d5e..5573f50 100644
--- a/taverna-reference-impl/src/test/resources/log4j.xml
+++ b/taverna-reference-impl/src/test/resources/log4j.xml
@@ -11,11 +11,11 @@
</layout>
</appender>
- <logger name="net.sf.taverna.platform.spring.orm">
+ <logger name="org.apache.taverna.platform.spring.orm">
<level value="TRACE" />
</logger>
- <logger name="net.sf.taverna.platform.spring">
+ <logger name="org.apache.taverna.platform.spring">
<level value="INFO" />
</logger>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
index 8853410..0bcd04d 100644
--- a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml
@@ -23,7 +23,7 @@
<!-- Apache Derby rooted at a temporary directory -->
<bean id="t2reference.jdbc.temporaryjdbc"
- class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC">
+ class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC">
</bean>
<bean id="t2reference.jdbc.url" class="java.lang.String"
factory-bean="t2reference.jdbc.temporaryjdbc"
@@ -78,16 +78,16 @@
<property name="mappingResources">
<list>
<value>
- net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+ org/apache/taverna/reference/AbstractExternalReference.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+ org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+ org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+ org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
</value>
</list>
</property>
@@ -95,7 +95,7 @@
<!-- Test data access object -->
<bean id="testDao"
- class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao">
+ class="org.apache.taverna.reference.impl.HibernateReferenceSetDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
@@ -103,7 +103,7 @@
<!-- Test list data access object -->
<bean id="testListDao"
- class="net.sf.taverna.t2.reference.impl.HibernateListDao">
+ class="org.apache.taverna.reference.impl.HibernateListDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
@@ -111,7 +111,7 @@
<!-- Test list data access object -->
<bean id="testErrorDao"
- class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao">
+ class="org.apache.taverna.reference.impl.HibernateErrorDocumentDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
index be66358..373e2e8 100644
--- a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml
@@ -21,7 +21,7 @@
<!-- Apache Derby rooted at a temporary directory -->
<bean id="t2reference.jdbc.temporaryjdbc"
- class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC">
+ class="org.apache.taverna.platform.spring.jdbc.TemporaryJDBC">
</bean>
<bean id="t2reference.jdbc.url" class="java.lang.String"
factory-bean="t2reference.jdbc.temporaryjdbc"
@@ -76,16 +76,16 @@
<property name="mappingResources">
<list>
<value>
- net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml
+ org/apache/taverna/reference/AbstractExternalReference.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml
+ org/apache/taverna/reference/impl/ReferenceSetImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml
+ org/apache/taverna/reference/impl/T2ReferenceListImpl.hbm.xml
</value>
<value>
- net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml
+ org/apache/taverna/reference/impl/ErrorDocumentImpl.hbm.xml
</value>
</list>
</property>
@@ -93,7 +93,7 @@
<!-- Test data access object -->
<bean id="testDao"
- class="net.sf.taverna.t2.reference.impl.TransactionalHibernateReferenceSetDao">
+ class="org.apache.taverna.reference.impl.TransactionalHibernateReferenceSetDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
@@ -101,7 +101,7 @@
<!-- Test list data access object -->
<bean id="testListDao"
- class="net.sf.taverna.t2.reference.impl.TransactionalHibernateListDao">
+ class="org.apache.taverna.reference.impl.TransactionalHibernateListDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
@@ -109,7 +109,7 @@
<!-- Test list data access object -->
<bean id="testErrorDao"
- class="net.sf.taverna.t2.reference.impl.TransactionalHibernateErrorDocumentDao">
+ class="org.apache.taverna.reference.impl.TransactionalHibernateErrorDocumentDao">
<property name="sessionFactory">
<ref local="sessionFactoryBean" />
</property>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml b/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
index 6ea6565..bea0930 100644
--- a/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
+++ b/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml
@@ -13,17 +13,17 @@
<!-- Test data access object -->
<bean id="testDao"
- class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao">
+ class="org.apache.taverna.reference.impl.InMemoryReferenceSetDao">
</bean>
<!-- Test list data access object -->
<bean id="testListDao"
- class="net.sf.taverna.t2.reference.impl.InMemoryListDao">
+ class="org.apache.taverna.reference.impl.InMemoryListDao">
</bean>
<!-- Test list data access object -->
<bean id="testErrorDao"
- class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao">
+ class="org.apache.taverna.reference.impl.InMemoryErrorDocumentDao">
</bean>
</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
deleted file mode 100644
index 5eabe9d..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/BlueReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * BlueReferences carry their data as an internal String and have a resolution
- * cost of 1.0f whatever the value of that string.
- *
- * @author Tom Oinn
- *
- */
-public class BlueReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
-
- // Hold the 'value' of this reference, probably the simplest backing store
- // possible for an ExternalReferenceSPI implementation :)
- private String contents;
-
- public BlueReference() {
- //
- }
-
- public BlueReference(String contents) {
- this.contents = contents;
- }
-
- /**
- * Set the 'value' of this reference as a string. It's not really a
- * reference type in any true sense of the word, but it'll do for testing
- * the augmentation system. This method is really here so you can configure
- * test beans from spring.
- */
- public void setContents(String contents) {
- this.contents = contents;
- }
-
- /**
- * Get the 'value' of this reference as a string, really just returns the
- * internal string representation.
- */
- public String getContents() {
- return this.contents;
- }
-
- /**
- * Fakes a de-reference operation, returning a byte stream over the string
- * data.
- */
- @Override
- public InputStream openStream(ReferenceContext arg0) {
- try {
- return new ByteArrayInputStream(this.contents
- .getBytes(getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new DereferenceException(e);
- }
- }
-
- /**
- * Default resolution cost of 1.0f whatever the contents
- */
- @Override
- public float getResolutionCost() {
- return 1.0f;
- }
-
- /**
- * Data nature set to 'ReferencedDataNature.TEXT'
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return ReferencedDataNature.TEXT;
- }
-
- /**
- * Character encoding set to 'UTF-8'
- */
- @Override
- public String getCharset() {
- return "UTF-8";
- }
-
- /**
- * String representation for testing, returns <code>blue{CONTENTS}</code>
- */
- @Override
- public String toString() {
- return "blue{" + contents + "}";
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(contents.getBytes().length);
- }
-
- @Override
- public ExternalReferenceSPI clone() throws CloneNotSupportedException {
- return new BlueReference(this.getContents());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
deleted file mode 100644
index 1d51fe9..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/DummyReferenceSet.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.sf.taverna.t2referencetest;
-
-import java.util.Collections;
-import java.util.Set;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.T2Reference;
-
-public class DummyReferenceSet implements ReferenceSet {
-
- private Set<ExternalReferenceSPI> refs;
-
- public DummyReferenceSet(ExternalReferenceSPI ref) {
- refs = Collections.singleton(ref);
- }
-
- @Override
- public T2Reference getId() {
- return null;
- }
-
- @Override
- public Set<ExternalReferenceSPI> getExternalReferences() {
- return refs;
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
deleted file mode 100644
index 6a11546..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenBuilder.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-import org.apache.log4j.Logger;
-
-/**
- * Trivially build a GreenReference from an InputStream, implementing the
- * ExternalReferenceBuilderSPI interface. Used in the augmentation test cases.
- *
- * @author Tom Oinn
- *
- */
-public class GreenBuilder implements
- ExternalReferenceBuilderSPI<GreenReference> {
-
- private static Logger logger = Logger
- .getLogger(GreenBuilder.class);
-
- /**
- * Construct a new GreenReference from the given input stream, ignoring the
- * otherwise helpful context as we don't need any resources from it. We
- * assume UTF-8 encoding as that's what all the test reference types use,
- * again, with a real example this might have to be a bit smarter!
- *
- * @throws ExternalReferenceConstructionException
- * if there are any issues building the new GreenReference
- * (which there won't be)
- */
- @Override
- public GreenReference createReference(InputStream is,
- ReferenceContext context)
- throws ExternalReferenceConstructionException {
- GreenReference newReference = new GreenReference();
- // Read input stream into the 'contents' property of the reference
- BufferedReader in = new BufferedReader(new InputStreamReader(is));
- try {
- newReference.setContents(in.readLine());
- } catch (IOException e) {
- throw new ExternalReferenceConstructionException(e);
- } finally {
- try {
- is.close();
- in.close();
- } catch (IOException e) {
- logger.error("Unable to close streams", e);
- }
- }
- return newReference;
- }
-
- /**
- * Construction cost fixed at 1.5f
- *
- * @return <code>1.5f</code>
- */
- @Override
- public float getConstructionCost() {
- return 1.5f;
- }
-
- /**
- * @return <code>{@link net.sf.taverna.t2referencetest.GreenReference GreenReference}.class</code>
- */
- @Override
- public Class<GreenReference> getReferenceType() {
- return GreenReference.class;
- }
-
- /**
- * Doesn't use any context resources so is always enabled
- *
- * @return <code>true</code>
- */
- @Override
- public boolean isEnabled(ReferenceContext arg0) {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
deleted file mode 100644
index e01f604..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * GreenReferences carry their data as an internal String and have a resolution
- * cost of 1.1f whatever the value of that string.
- *
- * @author Tom Oinn
- *
- */
-public class GreenReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
-
- // Hold the 'value' of this reference, probably the simplest backing store
- // possible for an ExternalReferenceSPI implementation :)
- private String contents;
-
- public GreenReference() {
- //
- }
-
- public GreenReference(String contents) {
- this.contents = contents;
- }
-
- /**
- * Set the 'value' of this reference as a string. It's not really a
- * reference type in any true sense of the word, but it'll do for testing
- * the augmentation system. This method is really here so you can configure
- * test beans from spring.
- */
- public void setContents(String contents) {
- this.contents = contents;
- }
-
- /**
- * Get the 'value' of this reference as a string, really just returns the
- * internal string representation.
- */
- public String getContents() {
- return this.contents;
- }
-
- /**
- * Fakes a de-reference operation, returning a byte stream over the string
- * data.
- */
- @Override
- public InputStream openStream(ReferenceContext arg0) {
- try {
- return new ByteArrayInputStream(this.contents
- .getBytes(getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new DereferenceException(e);
- }
- }
-
- /**
- * Default resolution cost of 1.0f whatever the contents
- */
- @Override
- public float getResolutionCost() {
- return 1.1f;
- }
-
- /**
- * Data nature set to 'ReferencedDataNature.TEXT'
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return ReferencedDataNature.TEXT;
- }
-
- /**
- * Character encoding set to 'UTF-8'
- */
- @Override
- public String getCharset() {
- return "UTF-8";
- }
-
- /**
- * String representation for testing, returns <code>green{CONTENTS}</code>
- */
- @Override
- public String toString() {
- return "green{" + contents + "}";
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(contents.getBytes().length);
- }
-
- @Override
- public ExternalReferenceSPI clone() throws CloneNotSupportedException {
- return new GreenReference(this.getContents());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
deleted file mode 100644
index 8c673d6..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/GreenToRed.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-public class GreenToRed implements
- ExternalReferenceTranslatorSPI<GreenReference, RedReference> {
-
- @Override
- public RedReference createReference(GreenReference ref,
- ReferenceContext context) {
- RedReference newReference = new RedReference();
- newReference.setContents(ref.getContents());
- // Insert a two second pause to simulate reference translation and to
- // test the behaviour of multiple concurrent translations
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ie) {
- System.out
- .println("Translation thread was interrupted, probably something wrong.");
- }
- return newReference;
- }
-
- @Override
- public Class<GreenReference> getSourceReferenceType() {
- return GreenReference.class;
- }
-
- @Override
- public Class<RedReference> getTargetReferenceType() {
- return RedReference.class;
- }
-
- @Override
- public float getTranslationCost() {
- return 0.4f;
- }
-
- @Override
- public boolean isEnabled(ReferenceContext arg0) {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
deleted file mode 100644
index 0c21c72..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/RedReference.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * RedReferences carry their data as an internal String and have a resolution
- * cost of 0.9f whatever the value of that string.
- *
- * @author Tom Oinn
- *
- */
-public class RedReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
-
- // Hold the 'value' of this reference, probably the simplest backing store
- // possible for an ExternalReferenceSPI implementation :)
- private String contents;
-
- public RedReference() {
- //
- }
-
- public RedReference(String contents) {
- this.contents = contents;
- }
-
- /**
- * Set the 'value' of this reference as a string. It's not really a
- * reference type in any true sense of the word, but it'll do for testing
- * the augmentation system. This method is really here so you can configure
- * test beans from spring.
- */
- public void setContents(String contents) {
- this.contents = contents;
- }
-
- /**
- * Get the 'value' of this reference as a string, really just returns the
- * internal string representation.
- */
- public String getContents() {
- return this.contents;
- }
-
- /**
- * Fakes a de-reference operation, returning a byte stream over the string
- * data.
- */
- @Override
- public InputStream openStream(ReferenceContext arg0) {
- try {
- return new ByteArrayInputStream(this.contents
- .getBytes(getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new DereferenceException(e);
- }
- }
-
- /**
- * Default resolution cost of 1.0f whatever the contents
- */
- @Override
- public float getResolutionCost() {
- return 0.9f;
- }
-
- /**
- * Data nature set to 'ReferencedDataNature.TEXT'
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return ReferencedDataNature.TEXT;
- }
-
- /**
- * Character encoding set to 'UTF-8'
- */
- @Override
- public String getCharset() {
- return "UTF-8";
- }
-
- /**
- * String representation for testing, returns <code>red{CONTENTS}</code>
- */
- @Override
- public String toString() {
- return "red{" + contents + "}";
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(contents.getBytes().length);
- }
-
- @Override
- public ExternalReferenceSPI clone() throws CloneNotSupportedException {
- return new RedReference(this.getContents());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java b/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
deleted file mode 100644
index b276f58..0000000
--- a/taverna-reference-testhelpers/src/main/java/net/sf/taverna/t2referencetest/YellowReference.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2007 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2referencetest;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-
-/**
- * YellowReferences carry their data as an internal String and have a resolution
- * cost of 1.0f whatever the value of that string.
- *
- * @author Tom Oinn
- *
- */
-public class YellowReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
-
- // Hold the 'value' of this reference, probably the simplest backing store
- // possible for an ExternalReferenceSPI implementation :)
- private String contents;
-
- public YellowReference() {
- //
- }
-
- public YellowReference(String contents) {
- this.contents = contents;
- }
-
- /**
- * Set the 'value' of this reference as a string. It's not really a
- * reference type in any true sense of the word, but it'll do for testing
- * the augmentation system. This method is really here so you can configure
- * test beans from spring.
- */
- public void setContents(String contents) {
- this.contents = contents;
- }
-
- /**
- * Get the 'value' of this reference as a string, really just returns the
- * internal string representation.
- */
- public String getContents() {
- return this.contents;
- }
-
- /**
- * Fakes a de-reference operation, returning a byte stream over the string
- * data.
- */
- @Override
- public InputStream openStream(ReferenceContext arg0) {
- try {
- return new ByteArrayInputStream(this.contents
- .getBytes(getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new DereferenceException(e);
- }
- }
-
- /**
- * Default resolution cost of 1.0f whatever the contents
- */
- @Override
- public float getResolutionCost() {
- return 1.0f;
- }
-
- /**
- * Data nature set to 'ReferencedDataNature.TEXT'
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return ReferencedDataNature.TEXT;
- }
-
- /**
- * Character encoding set to 'UTF-8'
- */
- @Override
- public String getCharset() {
- return "UTF-8";
- }
-
- /**
- * String representation for testing, returns <code>yellow{CONTENTS}</code>
- */
- @Override
- public String toString() {
- return "yellow{" + contents + "}";
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(contents.getBytes().length);
- }
-
- @Override
- public ExternalReferenceSPI clone() throws CloneNotSupportedException {
- return new YellowReference(this.getContents());
- }
-
-}