ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r592188 - in /webservices/scout/trunk/scout/src: main/java/org/apache/ws/scout/registry/ test/java/org/apache/ws/scout/registry/ test/java/org/apache/ws/scout/registry/qa/
Date Mon, 05 Nov 2007 23:44:33 GMT
Author: kstam
Date: Mon Nov  5 15:44:32 2007
New Revision: 592188

URL: http://svn.apache.org/viewvc?rev=592188&view=rev
Log:
SCOUT-52 refactoring and adding unittests, fixing associations.

Modified:
    webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BulkResponseImpl.java
    webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
    webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
    webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java

Modified: webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BulkResponseImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BulkResponseImpl.java?rev=592188&r1=592187&r2=592188&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BulkResponseImpl.java
(original)
+++ webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BulkResponseImpl.java
Mon Nov  5 15:44:32 2007
@@ -35,7 +35,7 @@
     private boolean partialResponse = false;
 
     private Collection<Exception> exceptions = new ArrayList<Exception>();
-    private LinkedHashSet<? extends Object> collection = new LinkedHashSet<Object>();
+    private Collection<? extends Object> collection = new ArrayList<Object>();
     /**
      * Creates a new instance of BulkResponseImpl
      */
@@ -87,7 +87,7 @@
         this.partialResponse = b;
     }
 
-    public void setCollection(LinkedHashSet<? extends Object> coll) throws JAXRException
+    public void setCollection(Collection<? extends Object> coll) throws JAXRException
     {
         this.collection = coll;
     }

Modified: webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java?rev=592188&r1=592187&r2=592188&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
(original)
+++ webservices/scout/trunk/scout/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java
Mon Nov  5 15:44:32 2007
@@ -47,6 +47,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.ws.scout.registry.infomodel.ConceptImpl;
+import org.apache.ws.scout.registry.infomodel.InternationalStringImpl;
 import org.apache.ws.scout.registry.infomodel.KeyImpl;
 import org.apache.ws.scout.uddi.AssertionStatusItem;
 import org.apache.ws.scout.uddi.AssertionStatusReport;
@@ -228,45 +230,48 @@
     }
 
 
-    public BulkResponse saveAssociations(Collection asso, boolean replace) throws JAXRException
{    //TODO
+    public BulkResponse saveAssociations(Collection associations, boolean replace) throws
JAXRException {
         BulkResponseImpl bulk = new BulkResponseImpl();
-        PublisherAssertion[] sarr = new PublisherAssertion[asso.size()];
+        PublisherAssertion[] sarr = new PublisherAssertion[associations.size()];
 
-        LinkedHashSet<String> coll = new LinkedHashSet<String>();
+        Collection<Key> coll = new ArrayList<Key>();
         Collection<Exception> exceptions = new ArrayList<Exception>();
 
-        Iterator iter = asso.iterator();
+        Iterator iter = associations.iterator();
         int currLoc = 0;
         while (iter.hasNext()) {
-            try {
-                PublisherAssertion pa = ScoutJaxrUddiHelper.getPubAssertionFromJAXRAssociation((Association)
iter.next());
+            
+                Association association = (Association) iter.next();
+                association.getSourceObject();
+                PublisherAssertion pa = ScoutJaxrUddiHelper.getPubAssertionFromJAXRAssociation(association);
                 sarr[currLoc] = pa;
                 currLoc++;
-            }
-            catch (ClassCastException ce) {
-                throw new UnexpectedObjectException();
-            }
-        }
-        // Save PublisherAssertion
-        PublisherAssertions bd = null;
-        try {
-            bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION");
-        }
-        catch (RegistryException e) {
-            exceptions.add(new SaveException(e));
-            bulk.setExceptions(exceptions);
-            bulk.setStatus(JAXRResponse.STATUS_FAILURE);
-            return bulk;
-        }
-        if(bd != null)
-        {
-        	PublisherAssertion[] keyarr = bd.getPublisherAssertionArray();
-        	for (int i = 0; keyarr != null && i < keyarr.length; i++) {
-        		PublisherAssertion result = (PublisherAssertion) keyarr[i];
-               KeyedReference kr = result.getKeyedReference();
-               coll.add(kr.getTModelKey()); //TODO:Verify This
-
-           }
+            
+                // Save PublisherAssertion
+                PublisherAssertions bd = null;
+                try {
+                    bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION");
+                }
+                catch (RegistryException e) {
+                    exceptions.add(new SaveException(e));
+                    bulk.setExceptions(exceptions);
+                    bulk.setStatus(JAXRResponse.STATUS_FAILURE);
+                    return bulk;
+                }
+                if(bd != null)
+                {
+                	PublisherAssertion[] keyarr = bd.getPublisherAssertionArray();
+                	for (int i = 0; keyarr != null && i < keyarr.length; i++) {
+                		PublisherAssertion result = (PublisherAssertion) keyarr[i];
+                        KeyedReference keyr = result.getKeyedReference();
+                        Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
+                        c.setName(new InternationalStringImpl(keyr.getKeyName()));
+                        c.setKey( new KeyImpl(keyr.getTModelKey()) );
+                        c.setValue(keyr.getKeyValue());
+                        association.setAssociationType(c);
+                        coll.add(association.getKey());
+                   }
+                }
         }
         bulk.setCollection(coll);
         bulk.setExceptions(exceptions);

Modified: webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java?rev=592188&r1=592187&r2=592188&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
(original)
+++ webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/BusinessLifeCyleManagerlTest.java
Mon Nov  5 15:44:32 2007
@@ -5,6 +5,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 
 import javax.xml.registry.BulkResponse;
 import javax.xml.registry.JAXRException;
@@ -222,9 +223,40 @@
         try {
             RegistryService rs = connection.getRegistryService();
             blm = rs.getBusinessLifeCycleManager();
-            Collection<Association> associations = new ArrayList<Association>();
-            //Association association = blm.createAssociation(targetObject, Association.);
+            bqm = rs.getBusinessQueryManager();
+            Creator creator = new Creator(blm);
+            
+            System.out.println("\nCreating temporary organizations...\n");
+            Organization sOrg = creator.createOrganization("sourceOrg");
+            Organization tOrg = creator.createOrganization("targetOrg");
+            Collection<Organization> organizations = new ArrayList<Organization>();
+            organizations.add(sOrg);
+            organizations.add(tOrg);
+            BulkResponse br = blm.saveOrganizations(organizations);
+            assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
+            //setting the keys on the organizations
+            Collection<Key> keys = (Collection<Key>) br.getCollection();
+            Iterator<Key> iterator = keys.iterator();
+            sOrg.setKey(iterator.next());
+            tOrg.setKey(iterator.next());
+            //creating the RelatedTo Association between these two organizations
+            Concept type = bqm.findConceptByPath("AssociationType/RelatedTo");
+            Association association = blm.createAssociation(tOrg, type);
+            sOrg.addAssociation(association);
+            ArrayList<Association> associations = new ArrayList<Association>();
+            associations.add(association);
+            //save associations
+            BulkResponse br2 = blm.saveAssociations(associations, true);
+            assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
             
+            //delete association
+            BulkResponse br3 = blm.deleteAssociations((Collection<Key>)br2.getCollection());
+            assertEquals(BulkResponse.STATUS_SUCCESS, br3.getStatus());
+            
+            //delete organizations
+            BulkResponse br4 = blm.deleteOrganizations((Collection<Key>)br.getCollection());
+            assertEquals(BulkResponse.STATUS_SUCCESS, br4.getStatus());
+           
         } catch (JAXRException je) {
             fail(je.getMessage());
         }

Modified: webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java?rev=592188&r1=592187&r2=592188&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
(original)
+++ webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR030AssociationsTest.java
Mon Nov  5 15:44:32 2007
@@ -102,17 +102,13 @@
             organizations.add(org1);
             organizations.add(org2);
             blm.saveOrganizations(organizations);
-            
-
+           
 			System.out.println("\nSearching for newly created organizations...\n");
 			ArrayList<Organization> orgs = findTempOrgs();
-
 			sOrg = orgs.get(0);
 			tOrg = orgs.get(1);
 
 			System.out.println("\nCreating association...\n");
-            
-            //TODO this does not actually succeed!
 			createAssociation(sOrg, tOrg);
 
 			// All created ... now try to delete.



---------------------------------------------------------------------
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