http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java deleted file mode 100644 index 62b6427..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/AppContextSetup.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java deleted file mode 100644 index 24f1ce9..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/DatabaseSetupTest.java +++ /dev/null @@ -1,140 +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.t2.reference.impl; - -import java.util.HashSet; - -import net.sf.taverna.t2.reference.ExternalReferenceSPI; -import net.sf.taverna.t2.reference.ListDao; -import net.sf.taverna.t2.reference.ReferenceSet; -import net.sf.taverna.t2.reference.ReferenceSetDao; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java deleted file mode 100644 index d5d47af..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentDaoTest.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.sf.taverna.t2.reference.impl; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import net.sf.taverna.t2.reference.ErrorDocumentDao; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java deleted file mode 100644 index e035922..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ErrorDocumentServiceTest.java +++ /dev/null @@ -1,88 +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.List; - -import net.sf.taverna.t2.reference.ErrorDocument; -import net.sf.taverna.t2.reference.ErrorDocumentDao; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java deleted file mode 100644 index a39d353..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListDaoTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package net.sf.taverna.t2.reference.impl; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import net.sf.taverna.t2.reference.ListDao; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java deleted file mode 100644 index 062337a..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ListServiceTest.java +++ /dev/null @@ -1,91 +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.List; - -import net.sf.taverna.t2.reference.IdentifiedList; -import net.sf.taverna.t2.reference.ListDao; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java deleted file mode 100644 index a898d27..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceContextImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.sf.taverna.t2.reference.impl; - -import java.util.ArrayList; -import java.util.List; - -import net.sf.taverna.t2.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/3ecb1291/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java ---------------------------------------------------------------------- diff --git a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java b/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java deleted file mode 100644 index f453cca..0000000 --- a/taverna-reference-impl/src/test/java/net/sf/taverna/t2/reference/impl/ReferenceSetDaoTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package net.sf.taverna.t2.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 net.sf.taverna.t2.reference.ExternalReferenceSPI; -import net.sf.taverna.t2.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/3ecb1291/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/3ecb1291/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/3ecb1291/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 deleted file mode 100644 index f1f4d5e..0000000 --- a/taverna-reference-impl/src/test/resources/log4j.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> - -<!-- Default Log4J configuration for integration test module --> -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> - - <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" - value="%p - %C{1}.%M(%L) | %m%n" /> - </layout> - </appender> - - <logger name="net.sf.taverna.platform.spring.orm"> - <level value="TRACE" /> - </logger> - - <logger name="net.sf.taverna.platform.spring"> - <level value="INFO" /> - </logger> - - <logger name="org.hibernate"> - <level value="ERROR" /> - </logger> - - <!-- - <logger name="org.hibernate.SQL"> - <level value="TRACE" /> - </logger> - <logger name="org.hibernate.type"> - <level value="DEBUG" /> - </logger> - --> - - <logger name="org.springframework"> - <level value="WARN" /> - </logger> - - <root> - <level value="ERROR" /> - <appender-ref ref="CONSOLE" /> - </root> - -</log4j:configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index 8853410..0000000 --- a/taverna-reference-impl/src/test/resources/vanillaHibernateAppContext.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- A test context with no raven aware components used by the DatabaseSetupTest --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - <!-- Transaction manager, commented out to use the regular dao implementations --> - <!-- - <tx:annotation-driven transaction-manager="txManager" /> - <bean id="txManager" - class="org.springframework.orm.hibernate3.HibernateTransactionManager"> - <property name="sessionFactory" ref="sessionFactoryBean" /> - </bean> - --> - - - <!-- Apache Derby rooted at a temporary directory --> - <bean id="t2reference.jdbc.temporaryjdbc" - class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC"> - </bean> - <bean id="t2reference.jdbc.url" class="java.lang.String" - factory-bean="t2reference.jdbc.temporaryjdbc" - factory-method="getTemporaryDerbyJDBC" /> - - <!-- At least for testing purposes we use Apache Derby --> - <bean id="exampleDataSource" - class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - <property name="driverClassName"> - <value>org.apache.derby.jdbc.EmbeddedDriver</value> - </property> - <property name="url"> - <ref bean="t2reference.jdbc.url" /> - </property> - </bean> - - <!-- Configure hibernate to use dynamic schema update --> - <bean id="exampleHibernateProperties" - class="org.springframework.beans.factory.config.PropertiesFactoryBean"> - <property name="properties"> - <props> - <prop key="hibernate.hbm2ddl.auto">create</prop> - <prop key="hibernate.dialect"> - org.hibernate.dialect.DerbyDialect - </prop> - <prop key="hibernate.query.substitutions"> - true 'T', false 'F' - </prop> - <prop key="hibernate.show_sql">false</prop> - <prop key="hibernate.c3p0.minPoolSize">5</prop> - <prop key="hibernate.c3p0.maxPoolSize">20</prop> - <prop key="hibernate.c3p0.timeout">600</prop> - <prop key="hibernate.c3p0.max_statement">50</prop> - <prop key="hibernate.c3p0.testConnectionOnCheckout"> - false - </prop> - <prop key="show_sql">true</prop> - <prop key="format_sql">true</prop> - </props> - </property> - </bean> - - <!-- A regular hibernate session factory --> - <bean id="sessionFactoryBean" - class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> - <property name="dataSource"> - <ref local="exampleDataSource" /> - </property> - <property name="hibernateProperties"> - <ref bean="exampleHibernateProperties" /> - </property> - <property name="mappingResources"> - <list> - <value> - net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <!-- Test data access object --> - <bean id="testDao" - class="net.sf.taverna.t2.reference.impl.HibernateReferenceSetDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testListDao" - class="net.sf.taverna.t2.reference.impl.HibernateListDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testErrorDao" - class="net.sf.taverna.t2.reference.impl.HibernateErrorDocumentDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index be66358..0000000 --- a/taverna-reference-impl/src/test/resources/vanillaHibernateTransactionalAppContext.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- A test context with no raven aware components used by the DatabaseSetupTest --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - <!-- Transaction manager, commented out to use the regular dao implementations --> - <tx:annotation-driven transaction-manager="txManager" /> - - <bean id="txManager" - class="org.springframework.orm.hibernate3.HibernateTransactionManager"> - <property name="sessionFactory" ref="sessionFactoryBean" /> - </bean> - - <!-- Apache Derby rooted at a temporary directory --> - <bean id="t2reference.jdbc.temporaryjdbc" - class="net.sf.taverna.platform.spring.jdbc.TemporaryJDBC"> - </bean> - <bean id="t2reference.jdbc.url" class="java.lang.String" - factory-bean="t2reference.jdbc.temporaryjdbc" - factory-method="getTemporaryDerbyJDBC" /> - - <!-- At least for testing purposes we use Apache Derby --> - <bean id="exampleDataSource" - class="org.springframework.jdbc.datasource.DriverManagerDataSource"> - <property name="driverClassName"> - <value>org.apache.derby.jdbc.EmbeddedDriver</value> - </property> - <property name="url"> - <ref bean="t2reference.jdbc.url" /> - </property> - </bean> - - <!-- Configure hibernate to use dynamic schema update --> - <bean id="exampleHibernateProperties" - class="org.springframework.beans.factory.config.PropertiesFactoryBean"> - <property name="properties"> - <props> - <prop key="hibernate.hbm2ddl.auto">create</prop> - <prop key="hibernate.dialect"> - org.hibernate.dialect.DerbyDialect - </prop> - <prop key="hibernate.query.substitutions"> - true 'T', false 'F' - </prop> - <prop key="hibernate.show_sql">false</prop> - <prop key="hibernate.c3p0.minPoolSize">5</prop> - <prop key="hibernate.c3p0.maxPoolSize">20</prop> - <prop key="hibernate.c3p0.timeout">600</prop> - <prop key="hibernate.c3p0.max_statement">50</prop> - <prop key="hibernate.c3p0.testConnectionOnCheckout"> - false - </prop> - <prop key="show_sql">true</prop> - <prop key="format_sql">true</prop> - </props> - </property> - </bean> - - <!-- A regular hibernate session factory --> - <bean id="sessionFactoryBean" - class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> - <property name="dataSource"> - <ref local="exampleDataSource" /> - </property> - <property name="hibernateProperties"> - <ref bean="exampleHibernateProperties" /> - </property> - <property name="mappingResources"> - <list> - <value> - net/sf/taverna/t2/reference/AbstractExternalReference.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ReferenceSetImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/T2ReferenceListImpl.hbm.xml - </value> - <value> - net/sf/taverna/t2/reference/impl/ErrorDocumentImpl.hbm.xml - </value> - </list> - </property> - </bean> - - <!-- Test data access object --> - <bean id="testDao" - class="net.sf.taverna.t2.reference.impl.TransactionalHibernateReferenceSetDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testListDao" - class="net.sf.taverna.t2.reference.impl.TransactionalHibernateListDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - - <!-- Test list data access object --> - <bean id="testErrorDao" - class="net.sf.taverna.t2.reference.impl.TransactionalHibernateErrorDocumentDao"> - <property name="sessionFactory"> - <ref local="sessionFactoryBean" /> - </property> - </bean> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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 deleted file mode 100644 index 6ea6565..0000000 --- a/taverna-reference-impl/src/test/resources/vanillaInMemoryAppContext.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- A test context with no raven aware components used by the DatabaseSetupTest --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:aop="http://www.springframework.org/schema/aop" - xmlns:tx="http://www.springframework.org/schema/tx" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx - http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> - - <!-- Test data access object --> - <bean id="testDao" - class="net.sf.taverna.t2.reference.impl.InMemoryReferenceSetDao"> - </bean> - - <!-- Test list data access object --> - <bean id="testListDao" - class="net.sf.taverna.t2.reference.impl.InMemoryListDao"> - </bean> - - <!-- Test list data access object --> - <bean id="testErrorDao" - class="net.sf.taverna.t2.reference.impl.InMemoryErrorDocumentDao"> - </bean> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/pom.xml b/taverna-reference-testhelpers/pom.xml deleted file mode 100644 index 0f99adf..0000000 --- a/taverna-reference-testhelpers/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.taverna.engine</groupId> - <artifactId>taverna-engine</artifactId> - <version>3.1.0-incubating-SNAPSHOT</version> - </parent> - <artifactId>taverna-reference-testhelpers</artifactId> - <packaging>bundle</packaging> - <name>Apache Taverna Reference Test Helpers</name> - - <description> - In order to properly test OSGi-loaded t2ference modules - we need a module that is entire external - to t2reference and to the test cases. If the test - implementations are included in either the api, core - implementation or test modules they will be loaded by the root - classloader of the test runner - by putting them in an - independent artifact we allow them to be loaded through - various SPI discovery mechanisms as they would be in a 'real' - environment. - </description> - - <dependencies> - <!-- Only depend on the t2reference API package here --> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-reference-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>${log4j.version}</version> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/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/3ecb1291/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/3ecb1291/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/3ecb1291/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/3ecb1291/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/3ecb1291/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/3ecb1291/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()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI deleted file mode 100644 index 3f1a123..0000000 --- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI +++ /dev/null @@ -1,2 +0,0 @@ -# Implementation classes of ExternalReferenceBuilderSPI go here, one per line -net.sf.taverna.t2referencetest.GreenBuilder \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI deleted file mode 100644 index 20a63d6..0000000 --- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI +++ /dev/null @@ -1,5 +0,0 @@ -# Implementation classes of ExternalReferenceSPI go here, one per line -net.sf.taverna.t2referencetest.GreenReference -net.sf.taverna.t2referencetest.BlueReference -net.sf.taverna.t2referencetest.RedReference -net.sf.taverna.t2referencetest.YellowReference \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI deleted file mode 100644 index 7fff1a3..0000000 --- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI +++ /dev/null @@ -1,2 +0,0 @@ -# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line -net.sf.taverna.t2referencetest.GreenToRed \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml deleted file mode 100644 index dc6c0a4..0000000 --- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:beans="http://www.springframework.org/schema/beans" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/osgi - http://www.springframework.org/schema/osgi/spring-osgi.xsd" > - - <service ref="greenBuilder" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" /> - - <service ref="greenReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" /> - <service ref="blueReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" /> - <service ref="redReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" /> - <service ref="yellowReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" /> - - <service ref="greenToRedTranslator" interface="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" /> - -</beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml deleted file mode 100644 index 8838328..0000000 --- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <bean id="greenBuilder" class="net.sf.taverna.t2referencetest.GreenBuilder" /> - - <bean id="greenReference" class="net.sf.taverna.t2referencetest.GreenReference" /> - <bean id="blueReference" class="net.sf.taverna.t2referencetest.BlueReference" /> - <bean id="redReference" class="net.sf.taverna.t2referencetest.RedReference" /> - <bean id="yellowReference" class="net.sf.taverna.t2referencetest.YellowReference" /> - - <bean id="greenToRedTranslator" class="net.sf.taverna.t2referencetest.GreenToRed" /> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml deleted file mode 100644 index 9483784..0000000 --- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping PUBLIC - "-//Hibernate/Hibernate Mapping DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<!-- Hibernate mapping for blue reference bean --> -<hibernate-mapping> - <joined-subclass - name="net.sf.taverna.t2referencetest.BlueReference" - extends="net.sf.taverna.t2.reference.AbstractExternalReference"> - <!-- Link to primary key from abstract superclass --> - <key column="bean_id" /> - <!-- Dummy reference specific props --> - <property name="contents" type="string" /> - </joined-subclass> -</hibernate-mapping> - http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml deleted file mode 100644 index dc65151..0000000 --- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping PUBLIC - "-//Hibernate/Hibernate Mapping DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<!-- Hibernate mapping for green reference bean --> -<hibernate-mapping> - <joined-subclass - name="net.sf.taverna.t2referencetest.GreenReference" - extends="net.sf.taverna.t2.reference.AbstractExternalReference"> - <!-- Link to primary key from abstract superclass --> - <key column="bean_id" /> - <!-- Dummy reference specific props --> - <property name="contents" type="string" /> - </joined-subclass> -</hibernate-mapping> - http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml deleted file mode 100644 index 176f60d..0000000 --- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping PUBLIC - "-//Hibernate/Hibernate Mapping DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<!-- Hibernate mapping for red reference bean --> -<hibernate-mapping> - <joined-subclass - name="net.sf.taverna.t2referencetest.RedReference" - extends="net.sf.taverna.t2.reference.AbstractExternalReference"> - <!-- Link to primary key from abstract superclass --> - <key column="bean_id" /> - <!-- Dummy reference specific props --> - <property name="contents" type="string" /> - </joined-subclass> -</hibernate-mapping> - http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml ---------------------------------------------------------------------- diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml deleted file mode 100644 index 6f357f8..0000000 --- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE hibernate-mapping PUBLIC - "-//Hibernate/Hibernate Mapping DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<!-- Hibernate mapping for yellow reference bean --> -<hibernate-mapping> - <joined-subclass - name="net.sf.taverna.t2referencetest.YellowReference" - extends="net.sf.taverna.t2.reference.AbstractExternalReference"> - <!-- Link to primary key from abstract superclass --> - <key column="bean_id" /> - <!-- Dummy reference specific props --> - <property name="contents" type="string" /> - </joined-subclass> -</hibernate-mapping> -
