ws-scout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r591890 - in /webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout: Creator.java Finder.java registry/BusinessLifeCyleManagerlTest.java registry/qa/JAXR010OrganizationTest.java
Date Mon, 05 Nov 2007 06:16:45 GMT
Author: kstam
Date: Sun Nov  4 22:16:43 2007
New Revision: 591890

URL: http://svn.apache.org/viewvc?rev=591890&view=rev
Log:
SCOUT-52 refactoring unittests

Modified:
    webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Creator.java
    webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Finder.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/JAXR010OrganizationTest.java

Modified: webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Creator.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Creator.java?rev=591890&r1=591889&r2=591890&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Creator.java (original)
+++ webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Creator.java Sun Nov 
4 22:16:43 2007
@@ -89,9 +89,9 @@
      * @return JAXR Service
      * @throws JAXRException
      */
-    public Service createService() throws JAXRException
+    public Service createService(String name) throws JAXRException
     {
-        Service service = blm.createService(getIString("JAXRTestService"));
+        Service service = blm.createService(getIString(name));
         service.setDescription(getIString("Test Services of UDDI Registry"));
         return service;
     }
@@ -115,12 +115,10 @@
      * @return JAXR ClassificationScheme
      * @throws JAXRException
      */
-    public ClassificationScheme createClassificationScheme() throws JAXRException
+    public ClassificationScheme createClassificationScheme(String name) throws JAXRException
     {
-        ClassificationScheme cs = blm.createClassificationScheme(getIString("apache-org:scout"),
+        ClassificationScheme cs = blm.createClassificationScheme(getIString(name),
                 getIString(""));
-        //Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2");
-        //cs.setKey(cKey);
         return cs;
     }
     /**
@@ -130,9 +128,8 @@
      * @return
      * @throws JAXRException
      */
-    public Classification createClassification() throws JAXRException
+    public Classification createClassification(ClassificationScheme classificationScheme)
throws JAXRException
     {
-        ClassificationScheme classificationScheme = createClassificationScheme();
         Classification classification = blm.createClassification(classificationScheme,
                 "Java Api for Xml Registries Services","1234");
         return classification;

Modified: webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Finder.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Finder.java?rev=591890&r1=591889&r2=591890&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Finder.java (original)
+++ webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/Finder.java Sun Nov  4
22:16:43 2007
@@ -84,6 +84,25 @@
         
         return response.getCollection();
     }
+    
+    public ClassificationScheme findClassificationSchemeByName(String queryStr) throws JAXRException
{
+        // Define find qualifiers and name patterns
+        Collection<String> findQualifiers = new ArrayList<String>();
+        findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+        Collection<String> namePatterns = new ArrayList<String>();
+        namePatterns.add("%" + queryStr + "%");
+        
+        // Find based upon qualifier type and values
+        System.out.println("\n-- searching the registry --\n");
+        BulkResponse response =
+            bqm.findClassificationSchemes(findQualifiers,
+                    namePatterns,
+                    null,
+                    null);
+        
+        return (ClassificationScheme) response.getCollection().iterator().next();
+    }
+    
     /**
      * Search a service, by matching the name and the classification.
      * 

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=591890&r1=591889&r2=591890&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
Sun Nov  4 22:16:43 2007
@@ -7,10 +7,13 @@
 import java.util.Collection;
 
 import javax.xml.registry.BulkResponse;
+import javax.xml.registry.JAXRException;
 import javax.xml.registry.JAXRResponse;
 import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.ClassificationScheme;
 import javax.xml.registry.infomodel.Key;
 import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.Service;
 
 import junit.framework.JUnit4TestAdapter;
 
@@ -51,7 +54,7 @@
             Organization organization = creator.createOrganization(this.getClass().getName());
             orgs.add(organization);
 
-            //Now save the Organization along with a Service, ServiceBinding and Classification
+            //save the Organization
             BulkResponse br = blm.saveOrganizations(orgs);
             assertEquals(JAXRResponse.STATUS_SUCCESS, br.getStatus());
             orgKeys = (Collection<Key>) br.getCollection();
@@ -70,29 +73,83 @@
             fail(e.getMessage());
         }
     }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void saveDeleteClassificationSchemes() 
+    {
+        login();
+       
+        try {
+            RegistryService rs = connection.getRegistryService();
+            blm = rs.getBusinessLifeCycleManager();
+            
+            ClassificationScheme cScheme = blm.createClassificationScheme("testScheme --
APACHE SCOUT TEST", "Sample Classification Scheme");
+
+            ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
+            cSchemes.add(cScheme);
+            //save
+            BulkResponse br = blm.saveClassificationSchemes(cSchemes);
+            assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
+            //remove
+            BulkResponse br2 = blm.deleteClassificationSchemes((Collection<Key>)br.getCollection());
+            assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
+        } catch (JAXRException je) {
+            fail(je.getMessage());
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void saveDeleteServices() 
+    {
+        login();
+       
+        try {
+            RegistryService rs = connection.getRegistryService();
+            blm = rs.getBusinessLifeCycleManager();
+            Creator creator = new Creator(blm);
+            Collection<Organization> orgs = new ArrayList<Organization>();
+            Organization organization = creator.createOrganization(this.getClass().getName());
+            orgs.add(organization);
+//          save the Organization
+            BulkResponse br = blm.saveOrganizations(orgs);
+            assertEquals(JAXRResponse.STATUS_SUCCESS, br.getStatus());
+            organization.setKey((Key)br.getCollection().iterator().next());
+            
+            Service service = creator.createService(this.getClass().getName());
+            ArrayList<Service> services = new ArrayList<Service>();
+            organization.addService(service);
+            services.add(service);
+            //save service
+            BulkResponse br2 = blm.saveServices(services);
+            assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
+            //remove service
+            BulkResponse br3 = blm.deleteServices((Collection<Key>)br2.getCollection());
+            assertEquals(BulkResponse.STATUS_SUCCESS, br3.getStatus());
+            //remove organization
+            BulkResponse br4 = blm.deleteOrganizations((Collection<Key>)br.getCollection());
+            assertEquals(JAXRResponse.STATUS_SUCCESS, br4.getStatus());
+        } catch (JAXRException je) {
+            fail(je.getMessage());
+        }
+    }
+        
+            
+            
     //TODO cover these methods
     
 //    BulkResponse deleteAssociations(Collection<Key> associationKeys) throws JAXRException;
 //
-//    BulkResponse deleteClassificationSchemes(Collection<Key> schemeKeys) throws JAXRException;
-//
 //    BulkResponse deleteConcepts(Collection<Key> conceptKeys) throws JAXRException;
 //
 //    BulkResponse deleteServiceBindings(Collection<Key> bindingKeys) throws JAXRException;
 //
-//    BulkResponse deleteServices(Collection<Key> serviceKeys) throws JAXRException;
-//
 //    BulkResponse saveAssociations(Collection<Association> associations, boolean replace)
throws JAXRException;
 //
-//    BulkResponse saveClassificationSchemes(Collection<ClassificationScheme> schemes)
throws JAXRException;
-//
-//    BulkResponse saveConcepts(Collection<Concept> concepts) throws JAXRException;
-//
-      
+//    BulkResponse saveConcepts(Collection<Concept> concepts) throws JAXRException;
 
 //
 //    BulkResponse saveServiceBindings(Collection<ServiceBinding> bindings) throws
JAXRException;
-//
-//    BulkResponse saveServices(Collection<Service> services) throws JAXRException;
 //
 //    void unConfirmAssociation(Association assoc) throws JAXRException, InvalidRequestException;
     

Modified: webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR010OrganizationTest.java
URL: http://svn.apache.org/viewvc/webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR010OrganizationTest.java?rev=591890&r1=591889&r2=591890&view=diff
==============================================================================
--- webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR010OrganizationTest.java
(original)
+++ webservices/scout/trunk/scout/src/test/java/org/apache/ws/scout/registry/qa/JAXR010OrganizationTest.java
Sun Nov  4 22:16:43 2007
@@ -79,7 +79,7 @@
             Creator creator = new Creator(blm);
             
             Collection<ClassificationScheme> schemes = new ArrayList<ClassificationScheme>();
-            ClassificationScheme classificationScheme = creator.createClassificationScheme();
+            ClassificationScheme classificationScheme = creator.createClassificationScheme(this.getClass().getName());
             schemes.add(classificationScheme);
             
             BulkResponse bulkResponse = blm.saveClassificationSchemes(schemes);
@@ -101,17 +101,20 @@
         {
             RegistryService rs = connection.getRegistryService();
             blm = rs.getBusinessLifeCycleManager();
+            bqm = rs.getBusinessQueryManager();
             Creator creator = new Creator(blm);
+            Finder finder = new Finder(bqm);
             
             Collection<Organization> orgs = new ArrayList<Organization>();
             Organization organization = creator.createOrganization(this.getClass().getName());
 //          Add a Service
-            Service service = creator.createService();
+            Service service = creator.createService(this.getClass().getName());
             ServiceBinding serviceBinding = creator.createServiceBinding();
             service.addServiceBinding(serviceBinding);
             organization.addService(service);
             //Add a classification
-            Classification classification = creator.createClassification();
+            ClassificationScheme cs = finder.findClassificationSchemeByName(this.getClass().getName());
+            Classification classification = creator.createClassification(cs);
             organization.addClassification(classification);
             
             orgs.add(organization);
@@ -151,6 +154,7 @@
     @Test
     public void queryOrganization()
     {
+        login();
         try
         {
             // Get registry service and business query manager
@@ -213,6 +217,7 @@
     @Test
     public void deleteClassificationScheme()
     {
+        login();
         try {
             RegistryService rs = connection.getRegistryService();
             bqm = rs.getBusinessQueryManager();



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