ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r801256 - /webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
Date Wed, 05 Aug 2009 15:12:16 GMT
Author: kstam
Date: Wed Aug  5 15:12:16 2009
New Revision: 801256

URL: http://svn.apache.org/viewvc?rev=801256&view=rev
Log:
scout-88. Fixing unittest itself. Code does the right thing.

Modified:
    webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java

Modified: webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java?rev=801256&r1=801255&r2=801256&view=diff
==============================================================================
--- webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
(original)
+++ webservices/scout/branches/scout-1.1/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
Wed Aug  5 15:12:16 2009
@@ -66,7 +66,8 @@
 	private static String tempSrcOrgName = "Apache Source Org -- APACHE SCOUT TEST";
 	private static String tempTgtOrgName = "Apache Target Org -- APACHE SCOUT TEST";
 
-	Organization sOrg, tOrg;
+	private Organization sOrg=null;
+	private Organization tOrg=null;
 
     @Before
 	public void setUp() {
@@ -89,10 +90,21 @@
     @Test
 	public void testPublishFindAndDeleteAssociation() {
 		login();
+		
 		try {
+			
 			RegistryService rs = connection.getRegistryService();
 			bqm = rs.getBusinessQueryManager();
 			blm = rs.getBusinessLifeCycleManager();
+			
+			//deleting any pre-exisiting organizations
+			ArrayList<Organization> orgs = findTempOrgs();
+			for (Organization organization : orgs) {
+				Collection<Key> keys = new ArrayList<Key>();
+				keys.add(organization.getKey());
+				blm.deleteOrganizations(keys);
+			}
+			
             Creator creator = new Creator(blm);
 
 			System.out.println("\nCreating temporary organizations...\n");
@@ -104,16 +116,42 @@
             blm.saveOrganizations(organizations);
            
 			System.out.println("\nSearching for newly created organizations...\n");
-			ArrayList<Organization> orgs = findTempOrgs();
-			sOrg = orgs.get(0);
-			tOrg = orgs.get(1);
+			ArrayList<Organization> newOrgs = findTempOrgs();
+			sOrg = newOrgs.get(0);
+			tOrg = newOrgs.get(1);
 
 			System.out.println("\nCreating association...\n");
 			createAssociation(sOrg, tOrg);
 
 			// All created ... now try to delete.
-			findAndDeleteAssociation();
-
+			String associationID = findAndDeleteAssociation();
+			
+			//Let us look for associations now
+			BulkResponse associationResp = 
+				bqm.findCallerAssociations(null, Boolean.TRUE, Boolean.TRUE, null);
+			
+			if(associationResp.getExceptions() != null)
+			{
+				fail("Association lookup failed");
+			}
+			else
+			{
+				Collection retAssocs = associationResp.getCollection();
+                if (retAssocs.size() == 0)
+                {
+                    //Pass
+                } else
+                {
+                   Iterator iterAss = retAssocs.iterator();
+                   while(iterAss.hasNext())
+                   {
+                      Association assc = (Association) iterAss.next();
+                      if(assc.getKey().getId().equals(associationID))
+                         fail("Deleted Association found");
+                   }
+                } 
+			}
+			 
 		} catch (JAXRException e) {
 			e.printStackTrace();
 			fail(e.getMessage());
@@ -152,8 +190,10 @@
 		}
 	}
 
-	private void findAndDeleteAssociation() throws JAXRException {
+	private String findAndDeleteAssociation() throws JAXRException {
 
+		String id = null;
+		
 		String sOrgID = sOrg.getKey().getId();
 		String tOrgID = tOrg.getKey().getId();
 
@@ -188,11 +228,13 @@
 				// Print spacer between messages
 				System.out.println(" --- ");
 
+				id = a.getKey().getId();
 				deleteAssociation(a.getKey());
 
 				System.out.println("\n ============================== \n");
-			}
+			} 
 		}
+		return id;
 	}
 
 	private void deleteAssociation(Key key) throws JAXRException {
@@ -222,9 +264,7 @@
 
 	private ArrayList<Organization> findTempOrgs() throws JAXRException {
 
-		ArrayList<Organization> toReturn = new ArrayList<Organization>(2);
-        toReturn.add(null);
-        toReturn.add(null);
+		ArrayList<Organization> toReturn = new ArrayList<Organization>();
 
 		// Define find qualifiers and name patterns
 		Collection<String> findQualifiers = new ArrayList<String>();



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


Mime
View raw message