[jboss-cvs] JBossAS SVN: r91842 - in branches/Branch_5_x/testsuite: src/main/org/jboss/test/jaxr/scout/publish and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 30 16:24:03 EDT 2009


Author: anil.saldhana at jboss.com
Date: 2009-07-30 16:24:03 -0400 (Thu, 30 Jul 2009)
New Revision: 91842

Modified:
   branches/Branch_5_x/testsuite/build.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteAssociationTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteOrganizationTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveOrganizationTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveServiceBindingTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/infomodel/JaxrConfimAssociationTestCase.java
Log:
JBAS-7129: clean up jaxr tests

Modified: branches/Branch_5_x/testsuite/build.xml
===================================================================
--- branches/Branch_5_x/testsuite/build.xml	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/build.xml	2009-07-30 20:24:03 UTC (rev 91842)
@@ -719,6 +719,7 @@
    </patternset>
    <patternset id="jaxr.includes">
       <include name="org/jboss/test/jaxr/scout/**/*TestCase.class"/>
+      <exclude name="org/jboss/test/jaxr/scout/**/JaxrDeleteAssociationTestCase.class"/>
    </patternset>
    <!-- jbossmessaging includes -->
    <patternset id="jbossmessaging.includes">

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteAssociationTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteAssociationTestCase.java	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteAssociationTestCase.java	2009-07-30 20:24:03 UTC (rev 91842)
@@ -25,7 +25,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 
-import javax.xml.registry.BulkResponse;
 import javax.xml.registry.BusinessLifeCycleManager;
 import javax.xml.registry.BusinessQueryManager;
 import javax.xml.registry.Connection;
@@ -131,6 +130,7 @@
 
             Association a = blm.createAssociation(targetOrg, associationType);
             a.setSourceObject(pubSource);
+            a.setTargetObject(targetOrg);
 
             blm.confirmAssociation(a);
             blm2.confirmAssociation(a);

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteOrganizationTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteOrganizationTestCase.java	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrDeleteOrganizationTestCase.java	2009-07-30 20:24:03 UTC (rev 91842)
@@ -21,17 +21,19 @@
  */
 package org.jboss.test.jaxr.scout.publish;
 
-import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 import javax.xml.registry.BulkResponse;
 import javax.xml.registry.JAXRException;
 import javax.xml.registry.JAXRResponse;
 import javax.xml.registry.infomodel.Key;
 import javax.xml.registry.infomodel.Organization;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
 
+import org.jboss.logging.Logger;
+import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
+
 /**
  * Checks Deletion of Organization
  *
@@ -41,16 +43,18 @@
 
 public class JaxrDeleteOrganizationTestCase extends JaxrBaseTestCase
 {
+   private static Logger log = Logger.getLogger(JaxrDeleteAssociationTestCase.class);
 
     public String saveOrg(String orgname)
     {
         String keyid = "";
         login();
+        Organization org = null;
         try
         {
             getJAXREssentials();
             Collection orgs = new ArrayList();
-            Organization org = createOrganization("JBOSS");
+            org = createOrganization("JBOSS");
 
             orgs.add(org);
             BulkResponse br = blm.saveOrganizations(orgs);
@@ -77,15 +81,31 @@
                 while (iter.hasNext())
                 {
                     Exception e = (Exception) iter.next();
-                    System.err.println(e.toString());
+                    log.error("Exception:",e);
                     fail(e.toString());
                 }
             }
         } catch (JAXRException e)
         {
-            e.printStackTrace();
+            log.error("Exception:",e);
             fail(e.getMessage());
         }
+        finally
+        {
+           if(org != null)
+           {
+              try
+              {
+                 Key orgkey = org.getKey();
+                 if(orgkey != null)
+                   this.deleteOrganization(org.getKey()); 
+              }
+              catch(Exception e)
+              {
+                 log.error("Cleanup failed:",e); 
+              }  
+           }
+        }
         return keyid;
     }
 

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveOrganizationTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveOrganizationTestCase.java	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveOrganizationTestCase.java	2009-07-30 20:24:03 UTC (rev 91842)
@@ -22,6 +22,7 @@
 package org.jboss.test.jaxr.scout.publish;
 
 
+import org.jboss.logging.Logger;
 import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
 
 import javax.xml.registry.BulkResponse;
@@ -42,19 +43,22 @@
 
 public class JaxrSaveOrganizationTestCase extends JaxrBaseTestCase
 {
+   private static Logger log = Logger.getLogger(JaxrSaveOrganizationTestCase.class);
+   
    private Key orgKey = null;
    
     public void testSaveOrg() throws JAXRException
     {
         String keyid = "";
         login();
+        Organization org = null;
         try
         {
             rs = connection.getRegistryService();
 
             blm = rs.getBusinessLifeCycleManager();
             Collection orgs = new ArrayList();
-            Organization org = createOrganization("JBOSS");
+            org = createOrganization("JBOSS");
 
             orgs.add(org);
             BulkResponse br = blm.saveOrganizations(orgs);
@@ -85,12 +89,28 @@
                     fail(e.toString());
                 }
             }
+            checkBusinessExists("JBOSS"); 
         } catch (JAXRException e)
         {
-            e.printStackTrace();
+            log.error("Exception:",e);
             fail(e.getMessage());
         }
-        checkBusinessExists("JBOSS"); 
+        finally
+        {
+           if(org != null)
+           {
+              try
+              {
+                 Key orgkey = org.getKey();
+                 if(orgkey != null)
+                   this.deleteOrganization(org.getKey());
+              }
+              catch(Exception e)
+              {
+                 log.error("Exception in finally:",e); 
+              }
+           }
+        }
     }
 
     private void checkBusinessExists(String bizname)

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveServiceBindingTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveServiceBindingTestCase.java	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/JaxrSaveServiceBindingTestCase.java	2009-07-30 20:24:03 UTC (rev 91842)
@@ -21,7 +21,9 @@
  */
 package org.jboss.test.jaxr.scout.publish;
 
-import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 import javax.xml.registry.BulkResponse;
 import javax.xml.registry.JAXRException;
@@ -32,11 +34,11 @@
 import javax.xml.registry.infomodel.Service;
 import javax.xml.registry.infomodel.ServiceBinding;
 import javax.xml.registry.infomodel.SpecificationLink;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
 
+import org.jboss.logging.Logger;
+import org.jboss.test.jaxr.scout.JaxrBaseTestCase;
 
+
 /**
  * Tests Saving ServiceBindings
  *
@@ -45,6 +47,8 @@
  */
 public class JaxrSaveServiceBindingTestCase extends JaxrBaseTestCase
 {
+   private static Logger log = Logger.getLogger(JaxrSaveServiceBindingTestCase.class);
+   
     /**
      * @throws JAXRException
      */
@@ -201,33 +205,54 @@
             }
         } catch (Exception e)
         {
-            e.printStackTrace();
+            log.error("Exception:",e);
             fail("Test has failed due to an exception:" + e.getMessage());
         } finally
         {
-            try
-            {
-                if (conceptKeys != null)
-                {
-                    blm.deleteConcepts(conceptKeys);
-                }
-                if (sbKeys != null)
-                {
-                    blm.deleteServiceBindings(sbKeys);
-                }
-                if (serviceKeys != null)
-                {
-                    blm.deleteServices(serviceKeys);
-                }
-                if (orgKeys != null)
-                {
-                    blm.deleteOrganizations(orgKeys);
-                }
+           try
+           {
+              if (conceptKeys != null)
+              {
+                 blm.deleteConcepts(conceptKeys);
+              } 
+           } catch (JAXRException je)
+           {
+              fail("Cleanup of JAXR objects failed:"+je);
+           }
+           try{
 
-            } catch (JAXRException je)
-            {
-                fail("Cleanup of JAXR objects failed");
-            }
+              if (sbKeys != null)
+              {
+                 blm.deleteServiceBindings(sbKeys);
+              } 
+
+           } catch (JAXRException je)
+           {
+              fail("Cleanup of JAXR objects failed:"+je);
+           }
+
+           try
+           {
+              if (serviceKeys != null)
+              {
+                 blm.deleteServices(serviceKeys);
+              } 
+
+           } catch (JAXRException je)
+           {
+              fail("Cleanup of JAXR objects failed:"+je);
+           } 
+           try
+           { 
+              if (orgKeys != null)
+              {
+                 blm.deleteOrganizations(orgKeys);
+              }
+           } 
+           catch (JAXRException je)
+           {
+              fail("Cleanup of JAXR objects failed:"+je);
+           }
         }
     } //end method
-}
+}
\ No newline at end of file

Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/infomodel/JaxrConfimAssociationTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/infomodel/JaxrConfimAssociationTestCase.java	2009-07-30 19:21:10 UTC (rev 91841)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/jaxr/scout/publish/infomodel/JaxrConfimAssociationTestCase.java	2009-07-30 20:24:03 UTC (rev 91842)
@@ -36,6 +36,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Tests confirming Association
@@ -52,8 +53,8 @@
      */
     public void testConfirmAssociation() throws JAXRException
     {
-        String orgTarget = "Target Organization";
-        String orgSource = "Source Organization";
+        String orgTarget = "Target Organization2";
+        String orgSource = "Source Organization2";
         String type = "Implements";
         Key savekey = null;
 
@@ -64,8 +65,8 @@
         String sourceId = null;
         BusinessQueryManager bqm2 = null;
         BusinessLifeCycleManager blm2 = null;
+        Association association = null;
 
-
         try
         {
             login();
@@ -122,13 +123,13 @@
             if (associationType == null)
                 fail(" getAssociationConcept returned null");
 
-            Association a = blm.createAssociation(pubTarget, associationType);
-            a.setSourceObject(pubSource);
+            association = blm.createAssociation(pubTarget, associationType);
+            association.setSourceObject(pubSource);
 
-            blm2.confirmAssociation(a);
+            blm2.confirmAssociation(association);
 
             Collection associations = new ArrayList();
-            associations.add(a);
+            associations.add(association);
             br = blm2.saveAssociations(associations, false);
             if (br.getExceptions() != null)
             {
@@ -156,20 +157,20 @@
             iter = associations.iterator();
             while (iter.hasNext())
             {
-                a = (Association) iter.next();
+                association = (Association) iter.next();
             }
 
-            assertNotNull("Association type:", a.getAssociationType().getValue());
-            if (a.isConfirmed())
+            assertNotNull("Association type:", association.getAssociationType().getValue());
+            if (association.isConfirmed())
             {
                 fail("FAIL: isConfirmed returned true  ");
             }
-            if (a.isConfirmedBySourceOwner())
+            if (association.isConfirmedBySourceOwner())
             {
                 fail("FAIL: isConfirmedBySourceOwner returned true  ");
             }
 
-            blm.confirmAssociation(a);
+            blm.confirmAssociation(association);
             br = blm.saveAssociations(associations, false);
             if (br.getExceptions() != null)
             {
@@ -188,15 +189,15 @@
             iter = associations.iterator();
             while (iter.hasNext())
             {
-                a = (Association) iter.next();
+                association = (Association) iter.next();
             }
 
-            if (!(a.isConfirmed()))
+            if (!(association.isConfirmed()))
             {
                 fail("FAIL: isConfirmed incorrectly returned false ");
             }
 
-            if (!(a.isConfirmedBySourceOwner()))
+            if (!(association.isConfirmedBySourceOwner()))
             {
                 fail("FAIL: isConfirmedBySourceOwner incorrectly returned false ");
             }
@@ -211,6 +212,13 @@
             {
                 blm2.deleteOrganizations(targetKeys);
                 blm.deleteOrganizations(sourceKeys);
+                if(association != null)
+                {
+                   Key asskey = association.getKey();
+                   List<Key> keyList = new ArrayList<Key>();
+                   keyList.add(asskey);
+                   blm.deleteAssociations(keyList);
+                }
             } catch (JAXRException je)
             {
                 fail("Error: not able to delete registry objects");




More information about the jboss-cvs-commits mailing list