From: Aron Roberts Date: Fri, 6 Nov 2009 20:20:28 +0000 (+0000) Subject: CSPACE-543: Completed removal of 'verbose' methods from client test framework and... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=4f1dc8f587c382f0941260d413c9033143e3aacd;p=tmp%2Fjakarta-migration.git CSPACE-543: Completed removal of 'verbose' methods from client test framework and individual client tests. Log statements will now correctly show line numbers from the relevant client test classes, not from the abstract base class. --- diff --git a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java index 9700810b2..c3a8f80c7 100644 --- a/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java +++ b/services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java @@ -309,7 +309,8 @@ public class AcquisitionServiceTest extends AbstractServiceTest { // Update the content of this resource. acquisition.setAccessionDate("updated-" + acquisition.getAccessionDate()); if(logger.isDebugEnabled()){ - verbose("updated object", acquisition, AcquisitionsCommon.class); + logger.debug("updated object"); + logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class)); } // Submit the request to the service and store the response. MultipartOutput output = new MultipartOutput(); @@ -577,8 +578,8 @@ public class AcquisitionServiceTest extends AbstractServiceTest { commonPart.getHeaders().add("label", client.getCommonPartName()); if(logger.isDebugEnabled()){ - verbose("to be created, acquisition common ", - acquisition, AcquisitionsCommon.class); + logger.debug("to be created, acquisition common"); + logger.debug(objectAsXmlString(acquisition, AcquisitionsCommon.class)); } return multipart; } diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java index 04fe9926b..8407fda3c 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTest.java @@ -24,6 +24,7 @@ package org.collectionspace.services.client.test; import java.io.ByteArrayInputStream; +import java.io.StringWriter; import java.lang.reflect.Method; import java.util.ArrayList; import javax.ws.rs.core.MultivaluedMap; @@ -597,35 +598,28 @@ public abstract class AbstractServiceTest implements ServiceTest { // to be moved to a utilities module, suitable for use // by both client-side and server-side code. - protected void verbose(String msg) { - if(logger.isDebugEnabled()){ - logger.debug(msg); - } - } - - protected void verbose(String msg, Object o, Class clazz) { + protected String objectAsXmlString(Object o, Class clazz) { + StringWriter sw = new StringWriter(); try{ - if(logger.isDebugEnabled()){ - logger.debug(msg); - } JAXBContext jc = JAXBContext.newInstance(clazz); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - m.marshal(o, System.out); + m.marshal(o, sw); }catch(Exception e){ e.printStackTrace(); } + return sw.toString(); } - - protected void verboseMap(MultivaluedMap map) { + + protected String mapAsString(MultivaluedMap map) { + StringBuffer sb = new StringBuffer(); for(Object entry : map.entrySet()){ MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry; - if(logger.isDebugEnabled()){ - logger.debug(" name=" + mentry.getKey() + - " value=" + mentry.getValue()); - } + sb.append(" name=" + mentry.getKey()); + sb.append(" value=" + mentry.getValue() + "\n"); } + return sb.toString(); } private void banner(String label) { diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 2c05547e5..bfca1da89 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -348,9 +348,11 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber()); collectionObject.setObjectName("updated-" + collectionObject.getObjectName()); if (logger.isDebugEnabled()) { - verbose("updated object", collectionObject, - CollectionobjectsCommon.class); + logger.debug("updated object"); + logger.debug(objectAsXmlString(collectionObject, + CollectionobjectsCommon.class)); } + // Submit the request to the service and store the response. MultipartOutput output = new MultipartOutput(); OutputPart commonPart = output.addPart(collectionObject, MediaType.APPLICATION_XML_TYPE); @@ -609,8 +611,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { commonPart.getHeaders().add("label", commonPartName); if (logger.isDebugEnabled()) { - verbose("to be created, collectionobject common ", - collectionObject, CollectionobjectsCommon.class); + logger.debug("to be created, collectionobject common"); + logger.debug(objectAsXmlString(collectionObject, + CollectionobjectsCommon.class)); } CollectionObjectNaturalhistory conh = new CollectionObjectNaturalhistory(); @@ -621,8 +624,9 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { nhPart.getHeaders().add("label", getNHPartName()); if (logger.isDebugEnabled()) { - verbose("to be created, collectionobject nhistory", - conh, CollectionObjectNaturalhistory.class); + logger.debug("to be created, collectionobject nhistory"); + logger.debug(objectAsXmlString(conh, + CollectionObjectNaturalhistory.class)); } return multipart; diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index 811f61c42..f064f95dc 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -337,7 +337,8 @@ public class IntakeServiceTest extends AbstractServiceTest { intake.setEntryNumber("updated-" + intake.getEntryNumber()); intake.setEntryDate("updated-" + intake.getEntryDate()); if(logger.isDebugEnabled()){ - verbose("to be updated object", intake, IntakesCommon.class); + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(intake, IntakesCommon.class)); } // Submit the request to the service and store the response. MultipartOutput output = new MultipartOutput(); @@ -589,7 +590,8 @@ public class IntakeServiceTest extends AbstractServiceTest { commonPart.getHeaders().add("label", client.getCommonPartName()); if(logger.isDebugEnabled()){ - verbose("to be created, intake common ", intake, IntakesCommon.class); + logger.debug("to be created, intake common"); + logger.debug(objectAsXmlString(intake, IntakesCommon.class)); } return multipart; diff --git a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java index d502f88a7..2e6a60295 100644 --- a/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java +++ b/services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java @@ -334,7 +334,8 @@ public class RelationServiceTest extends AbstractServiceTest { relation.setDocumentId2("updated-" + relation.getDocumentId2()); relation.setDocumentType2("updated-" + relation.getDocumentType2()); if(logger.isDebugEnabled()){ - verbose("updated object", relation, RelationsCommon.class); + logger.debug("updated object"); + logger.debug(objectAsXmlString(relation, RelationsCommon.class)); } // Submit the request to the service and store the response. @@ -590,8 +591,8 @@ public class RelationServiceTest extends AbstractServiceTest { multipart.addPart(relation, MediaType.APPLICATION_XML_TYPE); commonPart.getHeaders().add("label", client.getCommonPartName()); if(logger.isDebugEnabled()){ - verbose("to be created, relation common ", relation, - RelationsCommon.class); + logger.debug("to be created, relation common"); + logger.debug(objectAsXmlString(relation, RelationsCommon.class)); } return multipart; } diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index 9763da2f3..e4ed30d63 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -476,7 +476,8 @@ public class VocabularyServiceTest extends AbstractServiceTest { vocabulary.setDisplayName("updated-" + vocabulary.getDisplayName()); vocabulary.setVocabType("updated-" + vocabulary.getVocabType()); if(logger.isDebugEnabled()){ - verbose("to be updated Vocabulary", vocabulary, VocabulariesCommon.class); + logger.debug("to be updated Vocabulary"); + logger.debug(objectAsXmlString(vocabulary, VocabulariesCommon.class)); } // Submit the updated resource to the service and store the response. @@ -534,8 +535,9 @@ public class VocabularyServiceTest extends AbstractServiceTest { // Update the contents of this resource. vocabularyItem.setDisplayName("updated-" + vocabularyItem.getDisplayName()); if(logger.isDebugEnabled()){ - verbose("to be updated VocabularyItem", vocabularyItem, - VocabularyitemsCommon.class); + logger.debug("to be updated VocabularyItem"); + logger.debug(objectAsXmlString(vocabularyItem, + VocabularyitemsCommon.class)); } // Submit the updated resource to the service and store the response. @@ -910,7 +912,8 @@ public class VocabularyServiceTest extends AbstractServiceTest { commonPart.getHeaders().add("label", client.getCommonPartName()); if(logger.isDebugEnabled()) { - verbose("to be created, vocabulary common ", vocabulary, VocabulariesCommon.class); + logger.debug("to be created, vocabulary common"); + logger.debug(objectAsXmlString(vocabulary, VocabulariesCommon.class)); } return multipart; } @@ -926,8 +929,9 @@ public class VocabularyServiceTest extends AbstractServiceTest { commonPart.getHeaders().add("label", client.getItemCommonPartName()); if(logger.isDebugEnabled()){ - verbose("to be created, vocabularyitem common ", vocabularyItem, - VocabularyitemsCommon.class); + logger.debug("to be created, vocabularyitem common"); + logger.debug(objectAsXmlString(vocabularyItem, + VocabularyitemsCommon.class)); } return multipart;