ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcunn...@apache.org
Subject svn commit: r816437 [3/3] - in /webservices/scout/trunk/src: main/java/org/apache/ws/scout/model/uddi/v2/ main/java/org/apache/ws/scout/registry/ test/java/org/apache/ws/scout/registry/ test/java/org/apache/ws/scout/registry/qa/
Date Fri, 18 Sep 2009 02:15:19 GMT
Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java?rev=816437&r1=816436&r2=816437&view=diff
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java (original)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryImpl.java Fri
Sep 18 02:15:18 2009
@@ -18,6 +18,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.StringReader;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.AccessController;
@@ -34,6 +35,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -84,6 +86,7 @@
 import org.apache.ws.scout.model.uddi.v2.TModelList;
 import org.apache.ws.scout.transport.Transport;
 import org.apache.ws.scout.transport.TransportException;
+import org.apache.ws.scout.util.XMLUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -341,7 +344,14 @@
 
         JAXBElement<?> uddiResponse = null;
 	    try {
-	        uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+	    	String xml = XMLUtils.convertNodeToXMLString(response);
+	        log.debug("Response is: " + xml);
+	    	
+		StringReader reader = new StringReader(xml);
+		uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(new StreamSource(reader));
+	    	//It is probably faster not to go to a String, but JAXB has issues with this
+	        //uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+
 	    } catch (JAXBException xmle) {
 	        throw (new RegistryException(xmle));
 	    }

Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java?rev=816437&r1=816436&r2=816437&view=diff
==============================================================================
--- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
(original)
+++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/RegistryV3Impl.java
Fri Sep 18 02:15:18 2009
@@ -18,6 +18,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.StringReader;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.security.AccessController;
@@ -35,6 +36,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -43,6 +45,8 @@
 import org.apache.ws.scout.transport.Transport;
 import org.apache.ws.scout.transport.TransportException;
 
+import org.apache.ws.scout.util.XMLUtils;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -299,7 +303,14 @@
 
         JAXBElement<?> uddiResponse = null;
 	    try {
-	        uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+	    	String xml = XMLUtils.convertNodeToXMLString(response);
+	        log.debug("Response is: " + xml);
+	    	
+		StringReader reader = new StringReader(xml);
+		uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(new StreamSource(reader));
+	    	//It is probably faster not to go to a String, but JAXB has issues with this
+	        //uddiResponse = (JAXBElement<?>) unmarshaller.unmarshal(response);
+
 	    } catch (JAXBException xmle) {
 	        throw (new RegistryV3Exception(xmle));
 	    }

Modified: webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/OwnershipTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/OwnershipTest.java?rev=816437&r1=816436&r2=816437&view=diff
==============================================================================
--- webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/OwnershipTest.java
(original)
+++ webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/OwnershipTest.java
Fri Sep 18 02:15:18 2009
@@ -36,7 +36,6 @@
 import org.apache.ws.scout.BaseTestCase;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -145,7 +144,7 @@
         }
     }
     
-    @Test @Ignore
+    @Test
 	public void testGetRegistryObjects() {
 
     	login();
@@ -158,36 +157,40 @@
             if (br.getStatus() == JAXRResponse.STATUS_SUCCESS)
             {
             	System.out.println("BR.size : " + br.getCollection().size());
-            	Collection coll = br.getCollection();
-            	Iterator iterator = coll.iterator();
+            	Collection coll1 = br.getCollection();
+            	Iterator iterator = coll1.iterator();
+            	Collection<String> orgKeys = new ArrayList<String>();
             	while (iterator.hasNext()) {
             		Organization org = (Organization) iterator.next();
             		System.out.println("BR " + org.getName().getValue(Locale.US));
+            		orgKeys.add(org.getKey().getId());
             	}
 
             	if (br.getCollection().size() == 0) {
             		fail("Found no organizations for user 1");
             	}
+            	
+            	BulkResponse br2 = bqm2.getRegistryObjects(LifeCycleManager.ORGANIZATION);
+                if (br2.getStatus() == JAXRResponse.STATUS_SUCCESS)
+                {
+                	Collection coll = br2.getCollection();
+                	Iterator iterator2 = coll.iterator();
+                	while (iterator2.hasNext()) {
+                		Organization org = (Organization) iterator2.next();
+                		System.out.println("BR2 " + org.getName().getValue(Locale.US));
+                		if (orgKeys.contains(org.getKey().getId())) {
+                			fail("Should not find organizations from user1");
+                		}
+                		
+                	}
+                }        	
+            	
+            	deleteTempOrg(org1.getKey());
+            	deleteTempOrg(org2.getKey());
 
             }
         	
-        	BulkResponse br2 = bqm2.getRegistryObjects(LifeCycleManager.ORGANIZATION);
-            if (br2.getStatus() == JAXRResponse.STATUS_SUCCESS)
-            {
-            	if (br2.getCollection().size() != 0) {
-            		fail("There should be no found organizations for user 2, found "
-            				+ br2.getCollection().size());
-            	}
-            	Collection coll = br2.getCollection();
-            	Iterator iterator = coll.iterator();
-            	while (iterator.hasNext()) {
-            		Organization org = (Organization) iterator.next();
-            		System.out.println("BR2 " + org.getName().getValue(Locale.US));
-            	}
-            }        	
         	
-        	deleteTempOrg(org1.getKey());
-        	deleteTempOrg(org2.getKey());
         
 		} catch (JAXRException e) {
 			e.printStackTrace();

Modified: webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java?rev=816437&r1=816436&r2=816437&view=diff
==============================================================================
--- webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
(original)
+++ webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
Fri Sep 18 02:15:18 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,22 +116,49 @@
             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();
-
-		} catch (JAXRException e) {
+			String associationID = findAndDeleteAssociation();
+			
+			//Let us look for associations now
+			BulkResponse associationResp = 
+				bqm.findCallerAssociations(null, Boolean.TRUE, Boolean.TRUE, null);
+			
+			if(associationResp.getExceptions() != null)
+			{
+				System.out.println(associationResp.getExceptions());
+				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)) {
+                    	  System.out.println("found: " + associationID);
+                          fail("Deleted Association found");
+                      }
+                   }
+                } 
+			}
+			 
+		} catch (Exception e) {
 			e.printStackTrace();
 			fail(e.getMessage());
-		} finally {
-
-		}
+		} 
 	}
     
 	private void createAssociation(Organization sOrg, Organization tOrg)
@@ -152,8 +191,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 +229,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 +265,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