juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r727259 - in /webservices/juddi/branches/v3_trunk/juddi-core/src: main/resources/persistence/ test/java/org/apache/juddi/api/impl/
Date Wed, 17 Dec 2008 03:35:38 GMT
Author: kstam
Date: Tue Dec 16 19:35:36 2008
New Revision: 727259

URL: http://svn.apache.org/viewvc?rev=727259&view=rev
Log:
JUDDI-142, cleaning up the tests

Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/persistence/hibernate-persistence.xml
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_010_PublisherTest.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_020_TmodelTest.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_030_BusinessEntityTest.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_050_PublisherAssertionTest.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/persistence/hibernate-persistence.xml
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/persistence/hibernate-persistence.xml?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/persistence/hibernate-persistence.xml
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/resources/persistence/hibernate-persistence.xml
Tue Dec 16 19:35:36 2008
@@ -17,7 +17,7 @@
 
       <!-- derby connection properties -->
       <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
-       <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+      <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/>
       <property name="hibernate.connection.url" value="jdbc:derby:juddi-derby-test-db;create=true"/>
       <property name="hibernate.connection.username" value=""/>
       <property name="hibernate.connection.password" value=""/>

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_010_PublisherTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_010_PublisherTest.java?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_010_PublisherTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_010_PublisherTest.java
Tue Dec 16 19:35:36 2008
@@ -28,6 +28,7 @@
 import org.apache.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Test;
+import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -40,35 +41,74 @@
 	final static String SAM_SYNDICATOR_XML = "api_xml_data/samsyndicator/publisher.xml";
     final static String SAM_SYNDICATOR_ID  = "ssyndicator";
     
-    private Logger logger = Logger.getLogger(this.getClass());
+    private static Logger logger = Logger.getLogger(API_010_PublisherTest.class);
     
 	private UDDIPublicationImpl publish = new UDDIPublicationImpl();
 	private UDDIInquiryImpl inquiry = new UDDIInquiryImpl();
+	private static String authInfo = null;
 	
 	@Test
-	public void joePublisher() {
+	public void testJoePublisher() {
 		//We can only test this if the publisher is not there already.
+		//If it already there is probably has foreign key relationships.
+		//This test should really only run on an empty database. Seed
+		//data will be added if the root publisher is missing.
 		if (!isExistPublisher(JOE_PUBLISHER_ID)) {
-			savePublisher(JOE_PUBLISHER_ID, JOE_PUBLISHER_XML);
-			deletePublisher(JOE_PUBLISHER_ID);
+			saveJoePublisher();
+			deleteJoePublisher();
 		}
 	}
 	
 	@Test
-	public void samSyndicator() {
+	public void testSamSyndicator() {
 		//We can only test this if the publisher is not there already.
 		if (!isExistPublisher(SAM_SYNDICATOR_ID)) {
+			saveSamSyndicator();
+			deleteSamSyndicator();
+		}
+	}
+	/**
+	 * Persists Joe Publisher to the database.
+	 * @return - true if the published did not exist already, 
+	 * 		   - false in all other cases.
+	 */
+	protected boolean saveJoePublisher() {
+		if (!isExistPublisher(JOE_PUBLISHER_ID)) {
+			savePublisher(JOE_PUBLISHER_ID, JOE_PUBLISHER_XML);
+			return true;
+		} else {
+			return false;
+		}
+	}
+	/**
+	 * Removes Joe Publisher from the database, this will fail if there
+	 * are child objects attached; think Services etc.
+	 */
+	protected void deleteJoePublisher() {
+		deletePublisher(JOE_PUBLISHER_ID);
+	}
+	/**
+	 * Persists Sam Syndicator to the database.
+	 * @return publisherId
+	 */
+	protected String saveSamSyndicator() {
+		if (!isExistPublisher(SAM_SYNDICATOR_ID)) {
 			savePublisher(SAM_SYNDICATOR_ID, SAM_SYNDICATOR_XML);
-			deletePublisher(SAM_SYNDICATOR_ID);
 		}
+		return SAM_SYNDICATOR_ID;
+	}
+	/**
+	 * Removes Sam Syndicator from the database, this will fail if there
+	 * are child objects attached; think Services etc.
+	 */
+	protected void deleteSamSyndicator() {
+		deletePublisher(SAM_SYNDICATOR_ID);
 	}
 	
 	
-	public void savePublisher(String publisherId, String publisherXML) {
+	private void savePublisher(String publisherId, String publisherXML) {
 		try {
-			logger.debug("Getting auth token..");
-			String authInfo = UDDIApiTestHelper.getAuthToken(Constants.ROOT_PUBLISHER);
-			
+			authInfo = UDDIApiTestHelper.getAuthToken(Constants.ROOT_PUBLISHER);
 			logger.debug("Saving new publisher: " + publisherXML);
 			SavePublisher sp = new SavePublisher();
 			sp.setAuthInfo(authInfo);
@@ -110,11 +150,9 @@
 		}
 	}
 	
-	public void deletePublisher(String publisherId) {
+	private void deletePublisher(String publisherId) {
 		try {
-			logger.debug("Getting auth token..");
-			String authInfo = UDDIApiTestHelper.getAuthToken(Constants.ROOT_PUBLISHER);
-			
+			authInfo = UDDIApiTestHelper.getAuthToken(Constants.ROOT_PUBLISHER);
 			logger.debug("Delete publisher: " + publisherId);
 			//Now deleting this publisher
 			DeletePublisher dp = new DeletePublisher();
@@ -141,7 +179,7 @@
 		}
 	}
 	
-	public boolean isExistPublisher(String publisherId) {
+	private boolean isExistPublisher(String publisherId) {
 		GetPublisherDetail gp = new GetPublisherDetail();
 		gp.getPublisherId().add(publisherId);
 		try {
@@ -152,4 +190,12 @@
 		}
 	}
 	
+	protected static String authInfoJoe() throws DispositionReportFaultMessage {
+		return UDDIApiTestHelper.getAuthToken(JOE_PUBLISHER_ID);
+	}
+	
+	protected static String authInfoSam() throws DispositionReportFaultMessage {
+		return UDDIApiTestHelper.getAuthToken(SAM_SYNDICATOR_ID);
+	}
+	
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_020_TmodelTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_020_TmodelTest.java?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_020_TmodelTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_020_TmodelTest.java
Tue Dec 16 19:35:36 2008
@@ -20,12 +20,14 @@
 
 import org.apache.log4j.Logger;
 import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.uddi.api_v3.DeleteTModel;
 import org.uddi.api_v3.GetTModelDetail;
 import org.uddi.api_v3.SaveTModel;
 import org.uddi.api_v3.TModel;
 import org.uddi.api_v3.TModelDetail;
+import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -39,43 +41,61 @@
     final static String SAM_SYNDICATOR_TMODEL_XML     = "api_xml_data/samsyndicator/tModelKeyGen.xml";
     final static String SAM_SYNDICATOR_TMODEL_KEY     = "uddi:juddi.apache.org:samco:repository:keygenerator";
     
-	private static UDDIPublicationImpl publish = new UDDIPublicationImpl();
-	private static UDDIInquiryImpl inquiry     = new UDDIInquiryImpl();
-	private static Logger logger               = Logger.getLogger(API_020_TmodelTest.class);
+	private static UDDIPublicationImpl publish        = new UDDIPublicationImpl();
+	private static UDDIInquiryImpl inquiry            = new UDDIInquiryImpl();
 	
-	@Test
-	public void joePublisher() {
-		String publisherId  = API_010_PublisherTest.JOE_PUBLISHER_ID;
-		String publisherXML = API_010_PublisherTest.JOE_PUBLISHER_XML;
-		API_010_PublisherTest api010 = new API_010_PublisherTest();
-		if (!api010.isExistPublisher(publisherId)) {
-			//Add the Publisher
-			api010.savePublisher(publisherId, publisherXML);
+	private static Logger logger                      = Logger.getLogger(API_020_TmodelTest.class);
+	private static API_010_PublisherTest api010       = new API_010_PublisherTest();
+	private static String authInfoJoe                 = null;
+	private static String authInfoSam                 = null;
+	
+	@BeforeClass
+	public static void setup() {
+		logger.debug("Getting auth token..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			authInfoJoe = API_010_PublisherTest.authInfoJoe();
+			authInfoSam = API_010_PublisherTest.authInfoSam();
+		} catch (DispositionReportFaultMessage e) {
+			logger.error(e.getMessage(), e);
+			Assert.fail("Could not obtain authInfo token.");
 		}
-		saveTModel(publisherId, JOE_PUBLISHER_TMODEL_XML, JOE_PUBLISHER_TMODEL_KEY);
-		deleteTModel(publisherId, JOE_PUBLISHER_TMODEL_XML, JOE_PUBLISHER_TMODEL_KEY);
 	}
 	
 	@Test
-	public void samSyndicator() {
-		String publisherId  = API_010_PublisherTest.SAM_SYNDICATOR_ID;
-		String publisherXML = API_010_PublisherTest.SAM_SYNDICATOR_XML;
-		API_010_PublisherTest api010 = new API_010_PublisherTest();
-		if (!api010.isExistPublisher(publisherId)) {
-			//Add the Publisher
-			api010.savePublisher(publisherId, publisherXML);
-		}
-		saveTModel(publisherId, SAM_SYNDICATOR_TMODEL_XML, SAM_SYNDICATOR_TMODEL_KEY);
-		deleteTModel(publisherId, SAM_SYNDICATOR_TMODEL_XML, SAM_SYNDICATOR_TMODEL_KEY);
+	public void testJoePublisherTmodel() {
+		saveJoePublisherTmodel(authInfoJoe);
+		deleteJoePublisherTmodel(authInfoJoe);
+	}
+	
+	@Test
+	public void testSamSyndicatorTmodelTest() {
+		api010.saveSamSyndicator();
+		saveSamSyndicatorTmodel(authInfoSam);
+		deleteSamSyndicatorTmodel(authInfoSam);
+	}
+	
+	protected void saveJoePublisherTmodel(String authInfoJoe) {
+		saveTModel(authInfoJoe, JOE_PUBLISHER_TMODEL_XML, JOE_PUBLISHER_TMODEL_KEY);
 	}
 	
-	public void saveTModel(String publisherId, String tModelXml, String tModelKey) {
+	protected void deleteJoePublisherTmodel(String authInfoJoe) {
+		deleteTModel(authInfoJoe, JOE_PUBLISHER_TMODEL_XML, JOE_PUBLISHER_TMODEL_KEY);
+	}
+	
+	protected void saveSamSyndicatorTmodel(String authInfoSam) {
+		saveTModel(authInfoSam, SAM_SYNDICATOR_TMODEL_XML, SAM_SYNDICATOR_TMODEL_KEY);
+	}
+	
+	protected void deleteSamSyndicatorTmodel(String authInfoSam) {
+		deleteTModel(authInfoSam, SAM_SYNDICATOR_TMODEL_XML, SAM_SYNDICATOR_TMODEL_KEY);
+	}
+	
+	private void saveTModel(String authInfo, String tModelXml, String tModelKey) {
 		
 		// Add the tModel
 		try {
-			logger.debug("Getting auth token..");
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-			
 			SaveTModel st = new SaveTModel();
 			st.setAuthInfo(authInfo);
 
@@ -102,11 +122,9 @@
 		}
 	}
 	
-	public void deleteTModel(String publisherId, String tModelXml, String tModelKey) {
+	private void deleteTModel(String authInfo, String tModelXml, String tModelKey) {
 		
 		try {
-			logger.debug("Getting auth token..");
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
 			//Now deleting the TModel
 			// Delete the entity and make sure it is removed
 			DeleteTModel dt = new DeleteTModel();
@@ -114,6 +132,7 @@
 			
 			dt.getTModelKey().add(tModelKey);
 			publish.deleteTModel(dt);
+			
 		} catch(Exception e) {
 			logger.error(e.getMessage(),e);
 			Assert.fail("No exception should be thrown");

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_030_BusinessEntityTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_030_BusinessEntityTest.java?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_030_BusinessEntityTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_030_BusinessEntityTest.java
Tue Dec 16 19:35:36 2008
@@ -20,12 +20,14 @@
 
 import org.apache.log4j.Logger;
 import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.uddi.api_v3.BusinessDetail;
 import org.uddi.api_v3.BusinessEntity;
 import org.uddi.api_v3.DeleteBusiness;
 import org.uddi.api_v3.GetBusinessDetail;
 import org.uddi.api_v3.SaveBusiness;
+import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -33,56 +35,76 @@
  */
 public class API_030_BusinessEntityTest {
 	
-	final static String JOE_BUSINESS_XML    = "api_xml_data/joepublisher/businessEntity.xml";
-    final static String JOE_BUSINESS_KEY    = "uddi:juddi.apache.org:joepublisher:businessone";
+	final static String JOE_BUSINESS_XML        = "api_xml_data/joepublisher/businessEntity.xml";
+    final static String JOE_BUSINESS_KEY        = "uddi:juddi.apache.org:joepublisher:businessone";
     
-    final static String SAM_BUSINESS_XML    = "api_xml_data/samsyndicator/businessEntity.xml";
-    final static String SAM_BUSINESS_KEY    = "uddi:juddi.apache.org:samco:repository:samco";
+    final static String SAM_BUSINESS_XML        = "api_xml_data/samsyndicator/businessEntity.xml";
+    final static String SAM_BUSINESS_KEY        = "uddi:juddi.apache.org:samco:repository:samco";
     
-    
-	private static UDDIPublicationImpl publish = new UDDIPublicationImpl();
-	private static UDDIInquiryImpl inquiry     = new UDDIInquiryImpl();
-	private static Logger logger               = Logger.getLogger(API_030_BusinessEntityTest.class);
+	private static UDDIPublicationImpl publish  = new UDDIPublicationImpl();
+	private static UDDIInquiryImpl inquiry      = new UDDIInquiryImpl();
+	private static Logger logger                = Logger.getLogger(API_030_BusinessEntityTest.class);
+	
+	private static API_010_PublisherTest api010 = new API_010_PublisherTest();
+	private static API_020_TmodelTest api020    = new API_020_TmodelTest();
+	private static String authInfoJoe           = null;
+	private static String authInfoSam           = null;
+	
+	@BeforeClass
+	public static void setup() {
+		logger.debug("Getting auth token..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			authInfoJoe = API_010_PublisherTest.authInfoJoe();
+			authInfoSam = API_010_PublisherTest.authInfoSam();
+		} catch (DispositionReportFaultMessage e) {
+			logger.error(e.getMessage(), e);
+			Assert.fail("Could not obtain authInfo token.");
+		}
+	}
 	
 	@Test
-	public void joePublisher() {
-		String publisherId = API_010_PublisherTest.JOE_PUBLISHER_ID;
+	public void testJoePublisherBusinessEntity() {
 		try {
-			API_010_PublisherTest api010 = new API_010_PublisherTest();
-			if (!api010.isExistPublisher(publisherId)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId, API_010_PublisherTest.JOE_PUBLISHER_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
-			saveBusiness(publisherId, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
-			deleteBusiness(publisherId, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
+			api020.saveJoePublisherTmodel(authInfoJoe);
+			saveJoePublisherBusiness(authInfoJoe);
+			deleteJoePublisherBusiness(authInfoJoe);
 		} finally {
-			new API_020_TmodelTest().deleteTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
+			api020.deleteJoePublisherTmodel(authInfoJoe);
 		}
-	}
+	}	
 	
 	@Test
-	public void samSyndicator() {
-		String publisherId = API_010_PublisherTest.SAM_SYNDICATOR_ID;
+	public void testSamSyndicatorBusiness() {
 		try {
-			API_010_PublisherTest api010 = new API_010_PublisherTest();
-			if (!api010.isExistPublisher(publisherId)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId, API_010_PublisherTest.SAM_SYNDICATOR_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
-			saveBusiness(publisherId, SAM_BUSINESS_XML, SAM_BUSINESS_KEY);
-			deleteBusiness(publisherId, SAM_BUSINESS_XML, SAM_BUSINESS_KEY);
+			api020.saveSamSyndicatorTmodel(authInfoSam);
+			saveSamSyndicatorBusiness(authInfoSam);
+			deleteSamSyndicatorBusiness(authInfoSam);
 		} finally {
-			new API_020_TmodelTest().deleteTModel(publisherId, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
+			api020.deleteSamSyndicatorTmodel(authInfoSam);
 		}
 	}
 	
+	protected void saveSamSyndicatorBusiness(String authInfoSam) {
+		saveBusiness(authInfoSam, SAM_BUSINESS_XML, SAM_BUSINESS_KEY);
+	}
 	
-	public void saveBusiness(String publisherId, String businessXML, String businessKey) {
+	protected void deleteSamSyndicatorBusiness(String authInfoSam) {
+		deleteBusiness(authInfoSam, SAM_BUSINESS_XML, SAM_BUSINESS_KEY);
+	}
+	
+	protected void saveJoePublisherBusiness(String authInfoJoe) {
+    	saveBusiness(authInfoJoe, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
+    }
+    
+    protected void deleteJoePublisherBusiness(String authInfoJoe) {
+    	deleteBusiness(authInfoJoe, JOE_BUSINESS_XML, JOE_BUSINESS_KEY);
+    }
+	
+	
+	private void saveBusiness(String authInfo, String businessXML, String businessKey) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-			
 			SaveBusiness sb = new SaveBusiness();
 			sb.setAuthInfo(authInfo);
 
@@ -113,10 +135,8 @@
 	}
 	
 	
-	public void deleteBusiness(String publisherId, String businessXML, String businessKey) {
+	private void deleteBusiness(String authInfo, String businessXML, String businessKey) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-			
 			// Delete the entity and make sure it is removed
 			DeleteBusiness db = new DeleteBusiness();
 			db.setAuthInfo(authInfo);

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_040_BusinessServiceTest.java
Tue Dec 16 19:35:36 2008
@@ -21,6 +21,7 @@
 import org.apache.juddi.api.impl.UDDIPublicationImpl;
 import org.apache.log4j.Logger;
 import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.uddi.api_v3.ServiceDetail;
@@ -28,6 +29,7 @@
 import org.uddi.api_v3.DeleteService;
 import org.uddi.api_v3.GetServiceDetail;
 import org.uddi.api_v3.SaveService;
+import org.uddi.v3_service.DispositionReportFaultMessage;
 
 /**
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -35,59 +37,82 @@
  */
 public class API_040_BusinessServiceTest 
 {
-	final static String JOE_SERVICE_XML    = "api_xml_data/joepublisher/businessService.xml";
-    final static String JOE_SERVICE_KEY    = "uddi:juddi.apache.org:joepublisher:serviceone";
+	final static String JOE_SERVICE_XML              = "api_xml_data/joepublisher/businessService.xml";
+    final static String JOE_SERVICE_KEY              = "uddi:juddi.apache.org:joepublisher:serviceone";
     
-    final static String SAM_SERVICE_XML    = "api_xml_data/samsyndicator/businessService.xml";
-    final static String SAM_SERVICE_KEY    = "uddi:juddi.apache.org:samco:repository:listingservice";
+    final static String SAM_SERVICE_XML              = "api_xml_data/samsyndicator/businessService.xml";
+    final static String SAM_SERVICE_KEY              = "uddi:juddi.apache.org:samco:repository:listingservice";
     
-    private Logger logger                  = Logger.getLogger(this.getClass());
-	private UDDIPublicationImpl publish    = new UDDIPublicationImpl();
-	private UDDIInquiryImpl inquiry        = new UDDIInquiryImpl();
-
+    private static Logger logger                     = Logger.getLogger(API_040_BusinessServiceTest.class);
+	private UDDIPublicationImpl publish              = new UDDIPublicationImpl();
+	private UDDIInquiryImpl inquiry                  = new UDDIInquiryImpl();
+	
+	private static API_010_PublisherTest api010      = new API_010_PublisherTest();
+	private static API_020_TmodelTest api020         = new API_020_TmodelTest();
+	private static API_030_BusinessEntityTest api030 = new API_030_BusinessEntityTest();
+	private static String authInfoJoe                = null;
+	private static String authInfoSam                = null;
+	
+	@BeforeClass
+	public static void setup() {
+		logger.debug("Getting auth token..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			authInfoJoe = API_010_PublisherTest.authInfoJoe();
+			authInfoSam = API_010_PublisherTest.authInfoSam();
+		} catch (DispositionReportFaultMessage e) {
+			logger.error(e.getMessage(), e);
+			Assert.fail("Could not obtain authInfo token.");
+		}
+	}
+	
 	@Test
 	public void joepublisher() {
-		String publisherId = API_010_PublisherTest.JOE_PUBLISHER_ID;
 		try {
-			API_010_PublisherTest api010 = new API_010_PublisherTest();
-			if (!api010.isExistPublisher(publisherId)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId, API_010_PublisherTest.JOE_PUBLISHER_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
-			new API_030_BusinessEntityTest().saveBusiness(publisherId, API_030_BusinessEntityTest.JOE_BUSINESS_XML,
API_030_BusinessEntityTest.JOE_BUSINESS_KEY);
-			saveService(publisherId, JOE_SERVICE_XML, JOE_SERVICE_KEY);
-			deleteService(publisherId, JOE_SERVICE_KEY);
+			api020.saveJoePublisherTmodel(authInfoJoe);
+			api030.saveJoePublisherBusiness(authInfoJoe);
+			saveJoePublisherService(authInfoJoe);
+			deleteJoePublisherService(authInfoJoe);
 		} finally {
-			new API_030_BusinessEntityTest().deleteBusiness(publisherId, API_030_BusinessEntityTest.JOE_BUSINESS_XML,
API_030_BusinessEntityTest.JOE_BUSINESS_KEY);
-			new API_020_TmodelTest().deleteTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
+			api030.deleteJoePublisherBusiness(authInfoJoe);
+			api020.deleteJoePublisherTmodel(authInfoJoe);
 		}
 	}
 	
 	@Test
 	public void samsyndicator() {
-		String publisherId = API_010_PublisherTest.SAM_SYNDICATOR_ID;
 		try {
-			API_010_PublisherTest api010 = new API_010_PublisherTest();
-			if (!api010.isExistPublisher(publisherId)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId, API_010_PublisherTest.SAM_SYNDICATOR_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
-			new API_030_BusinessEntityTest().saveBusiness(publisherId, API_030_BusinessEntityTest.SAM_BUSINESS_XML,
API_030_BusinessEntityTest.SAM_BUSINESS_KEY);
-			saveService(publisherId, SAM_SERVICE_XML, SAM_SERVICE_KEY);
-			deleteService(publisherId, SAM_SERVICE_KEY);
+			
+			api020.saveSamSyndicatorTmodel(authInfoSam);
+			api030.saveSamSyndicatorBusiness(authInfoSam);
+			saveSamSyndicatorService(authInfoSam);
+			deleteSamSyndicatorService(authInfoSam);
 		} finally {
-			new API_030_BusinessEntityTest().deleteBusiness(publisherId, API_030_BusinessEntityTest.SAM_BUSINESS_XML,
API_030_BusinessEntityTest.SAM_BUSINESS_KEY);
-			new API_020_TmodelTest().deleteTModel(publisherId, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
+			api030.deleteSamSyndicatorBusiness(authInfoSam);
+			api020.deleteSamSyndicatorTmodel(authInfoSam);
 		}
 	}
 	
+	protected void saveJoePublisherService(String authInfoJoe) {
+		saveService(authInfoJoe, JOE_SERVICE_XML, JOE_SERVICE_KEY);
+	}
 	
-	public void saveService(String publisherId, String serviceXML, String serviceKey) {
+	protected void deleteJoePublisherService(String authInfoJoe) {
+		deleteService(authInfoJoe, JOE_SERVICE_KEY);
+	}
+	
+	protected void saveSamSyndicatorService(String authInfoSam) {
+		saveService(authInfoSam, SAM_SERVICE_XML, SAM_SERVICE_KEY);
+	}
+	
+	protected void deleteSamSyndicatorService(String authInfoSam) {
+		deleteService(authInfoSam, SAM_SERVICE_KEY);
+	}
+	
+	
+	private void saveService(String authInfo, String serviceXML, String serviceKey) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-
 			// First save the entity
 			SaveService ss = new SaveService();
 			ss.setAuthInfo(authInfo);
@@ -116,10 +141,8 @@
 		
 	}
 	
-	public void deleteService(String publisherId, String serviceKey) {
+	private void deleteService(String authInfo, String serviceKey) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-	
 			// Delete the entity and make sure it is removed
 			DeleteService ds = new DeleteService();
 			ds.setAuthInfo(authInfo);

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_050_PublisherAssertionTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_050_PublisherAssertionTest.java?rev=727259&r1=727258&r2=727259&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_050_PublisherAssertionTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/api/impl/API_050_PublisherAssertionTest.java
Tue Dec 16 19:35:36 2008
@@ -24,53 +24,60 @@
 
 import org.apache.log4j.Logger;
 import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.uddi.api_v3.AddPublisherAssertions;
 import org.uddi.api_v3.DeletePublisherAssertions;
 import org.uddi.api_v3.KeyedReference;
 import org.uddi.api_v3.PublisherAssertion;
+import org.uddi.v3_service.DispositionReportFaultMessage;
 
 public class API_050_PublisherAssertionTest {
 	
 	final static String JOE_ASSERT_XML    = "api_xml_data/joepublisher/publisherAssertion.xml";
-	private Logger logger = Logger.getLogger(this.getClass());
+	private static Logger logger = Logger.getLogger(API_050_PublisherAssertionTest.class);
     
 	private UDDIPublicationImpl publish = new UDDIPublicationImpl();
 	
+	private static API_010_PublisherTest api010      = new API_010_PublisherTest();
+	private static API_020_TmodelTest api020         = new API_020_TmodelTest();
+	private static API_030_BusinessEntityTest api030 = new API_030_BusinessEntityTest();
+	private static String authInfoJoe                = null;
+	private static String authInfoSam                = null;
+	
+	@BeforeClass
+	public static void setup() {
+		logger.debug("Getting auth token..");
+		try {
+			api010.saveJoePublisher();
+			api010.saveSamSyndicator();
+			authInfoJoe = API_010_PublisherTest.authInfoJoe();
+			authInfoSam = API_010_PublisherTest.authInfoSam();
+		} catch (DispositionReportFaultMessage e) {
+			logger.error(e.getMessage(), e);
+			Assert.fail("Could not obtain authInfo token.");
+		}
+	}
+	
 	@Test
-	public void joepublisherToSamSyndicator() {
-		String publisherId = API_010_PublisherTest.JOE_PUBLISHER_ID;
-		String publisherId2 = API_010_PublisherTest.SAM_SYNDICATOR_ID;
+	public void testJoepublisherToSamSyndicator() {
 		try {
-			API_010_PublisherTest api010 = new API_010_PublisherTest();
-			//joepublisher
-			if (!api010.isExistPublisher(publisherId)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId, API_010_PublisherTest.JOE_PUBLISHER_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
-			new API_030_BusinessEntityTest().saveBusiness(publisherId, API_030_BusinessEntityTest.JOE_BUSINESS_XML,
API_030_BusinessEntityTest.JOE_BUSINESS_KEY);
-			//samsyndicator
-			if (!api010.isExistPublisher(publisherId2)) {
-				//Add the Publisher
-				api010.savePublisher(publisherId2, API_010_PublisherTest.SAM_SYNDICATOR_XML);
-			}
-			new API_020_TmodelTest().saveTModel(publisherId2, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
-			new API_030_BusinessEntityTest().saveBusiness(publisherId2, API_030_BusinessEntityTest.SAM_BUSINESS_XML,
API_030_BusinessEntityTest.SAM_BUSINESS_KEY);
-			addPublisherAssertion(publisherId, JOE_ASSERT_XML);
-			deletePublisherAssertion(publisherId, JOE_ASSERT_XML);
+			api020.saveJoePublisherTmodel(authInfoJoe);
+			api020.saveSamSyndicatorTmodel(authInfoSam);
+			api030.saveJoePublisherBusiness(authInfoJoe);
+			api030.saveSamSyndicatorBusiness(authInfoSam);
+			addPublisherAssertion(authInfoJoe, JOE_ASSERT_XML);
+			deletePublisherAssertion(authInfoJoe, JOE_ASSERT_XML);
 		} finally {
-			new API_030_BusinessEntityTest().deleteBusiness(publisherId, API_030_BusinessEntityTest.JOE_BUSINESS_XML,
API_030_BusinessEntityTest.JOE_BUSINESS_KEY);
-			new API_020_TmodelTest().deleteTModel(publisherId, API_020_TmodelTest.JOE_PUBLISHER_TMODEL_XML,
API_020_TmodelTest.JOE_PUBLISHER_TMODEL_KEY);
-			new API_030_BusinessEntityTest().deleteBusiness(publisherId2, API_030_BusinessEntityTest.SAM_BUSINESS_XML,
API_030_BusinessEntityTest.SAM_BUSINESS_KEY);
-			new API_020_TmodelTest().deleteTModel(publisherId2, API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_XML,
API_020_TmodelTest.SAM_SYNDICATOR_TMODEL_KEY);
+			api030.deleteJoePublisherBusiness(authInfoJoe);
+			api030.deleteSamSyndicatorBusiness(authInfoSam);
+			api020.deleteJoePublisherTmodel(authInfoJoe);
+			api020.deleteSamSyndicatorTmodel(authInfoSam);
 		}
 	}
 	
-	public void addPublisherAssertion(String publisherId, String pubassertXML) {
+	private void addPublisherAssertion(String authInfo, String pubassertXML) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-			
 			AddPublisherAssertions ap = new AddPublisherAssertions();
 			ap.setAuthInfo(authInfo);
 
@@ -100,10 +107,8 @@
 
 	}
 
-	public void deletePublisherAssertion(String publisherId, String pubassertXML) {
+	private void deletePublisherAssertion(String authInfo, String pubassertXML) {
 		try {
-			String authInfo = UDDIApiTestHelper.getAuthToken(publisherId);
-			
 			// Delete the entity and make sure it is removed
 			DeletePublisherAssertions dp = new DeletePublisherAssertions();
 			dp.setAuthInfo(authInfo);



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message