airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patanac...@apache.org
Subject svn commit: r1188504 - in /incubator/airavata/trunk/modules/commons: gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/ gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/ registry-api/src/test/java/org/apache/airava...
Date Tue, 25 Oct 2011 03:27:22 GMT
Author: patanachai
Date: Tue Oct 25 03:27:21 2011
New Revision: 1188504

URL: http://svn.apache.org/viewvc?rev=1188504&view=rev
Log:
AIRAVATA-138 service test case for JCR

Modified:
    incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/GramApplicationDeployment.java
    incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/GlobusHost.java
    incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java

Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/GramApplicationDeployment.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/GramApplicationDeployment.java?rev=1188504&r1=1188503&r2=1188504&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/GramApplicationDeployment.java
(original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/app/GramApplicationDeployment.java
Tue Oct 25 03:27:21 2011
@@ -29,7 +29,7 @@ public class GramApplicationDeployment e
 
     private GramApplicationDeploymentType gramApplicationDeploymentType;
 
-    private GramApplicationDeployment() {
+    public GramApplicationDeployment() {
         this.gramApplicationDeploymentType = GramApplicationDeploymentType.Factory.newInstance();
     }
 

Modified: incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/GlobusHost.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/GlobusHost.java?rev=1188504&r1=1188503&r2=1188504&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/GlobusHost.java
(original)
+++ incubator/airavata/trunk/modules/commons/gfac-schema/src/main/java/org/apache/airavata/commons/gfac/type/host/GlobusHost.java
Tue Oct 25 03:27:21 2011
@@ -28,7 +28,7 @@ public class GlobusHost extends HostDesc
 
 	private GlobusHostType globusHostType;
 
-	private GlobusHost() {
+	public GlobusHost() {
 		this.globusHostType = GlobusHostType.Factory.newInstance();
 	}
 

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java?rev=1188504&r1=1188503&r2=1188504&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java
(original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryTest.java
Tue Oct 25 03:27:21 2011
@@ -23,7 +23,14 @@ package org.apache.airavata.registry.api
 
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.commons.gfac.type.host.GlobusHost;
+import org.apache.airavata.schemas.gfac.DataType;
+import org.apache.airavata.schemas.gfac.Parameter;
 import org.junit.Test;
 
 public class JCRRegistryTest {
@@ -31,34 +38,113 @@ public class JCRRegistryTest {
     @Test
     public void testSaveLoadHostDescription() {
         try {
-        	/*
+            /*
              * Create database
              */
-            JCRRegistry jcrRegistry = new JCRRegistry(null, "org.apache.jackrabbit.core.RepositoryFactoryImpl",
"admin",
-                    "admin", null);
+            JCRRegistry jcrRegistry = new JCRRegistry(null, "org.apache.jackrabbit.core.RepositoryFactoryImpl",
+                    "admin", "admin", null);
 
             String hostId = "localhost";
             String address = "127.0.0.1";
             
+            String hostId2 = "localhost2";
+
             /*
              * Host
              */
             HostDescription host = new HostDescription();
             host.setId(hostId);
             host.setAddress(address);
-            
+
             jcrRegistry.saveHostDescription(host);
+
+            HostDescription hostR = jcrRegistry.getHostDescription(hostId);
+
+            if (!(hostR.getId().equals(hostId) && hostR.getAddress().equals(address)))
{
+                fail("Save and Load Host Description Fail with Different Value");
+            }
             
+            /*
+             * Test for polymorphism
+             */
+            GlobusHost globus = new GlobusHost();
+            globus.setId(hostId2);
+            globus.setAddress(address);
+
+            jcrRegistry.saveHostDescription(globus);
+
+            HostDescription hg = jcrRegistry.getHostDescription(hostId2);
+
+            if (!(hg.getId().equals(hostId2) && hg.getAddress().equals(address)))
{
+                fail("Save and Load Host Description Fail with Different Value");
+            }
             
-            HostDescription hostR = jcrRegistry.getHostDescription(hostId);
+            if(!(hg instanceof GlobusHost))
+                fail("Save and Load Host Type Fail with Different Type when loading");
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    @Test
+    public void testSaveLoadServiceDescription() {
+        try {
+
+            JCRRegistry jcrRegistry = new JCRRegistry(null, "org.apache.jackrabbit.core.RepositoryFactoryImpl",
+                    "admin", "admin", null);
+            
+            String serviceId = "SimpleEcho";            
+            
+            ServiceDescription serv = new ServiceDescription();
+            serv.setId(serviceId);
+
+            Parameter input = Parameter.Factory.newInstance();
+            input.setName("echo_input");
+            input.addNewType().setType(DataType.STRING);
+            List<Parameter> inputList = new ArrayList<Parameter>();
+            inputList.add(input);
+            org.apache.airavata.schemas.gfac.Parameter[] inputParamList = inputList
+                    .toArray(new org.apache.airavata.schemas.gfac.Parameter[inputList.size()]);
+
+            Parameter output = Parameter.Factory.newInstance();
+            output.setName("echo_output");
+            output.addNewType().setType(DataType.STRING);
+            List<Parameter> outputList = new ArrayList<Parameter>();
+            outputList.add(output);
+            org.apache.airavata.schemas.gfac.Parameter[] outputParamList = outputList
+                    .toArray(new org.apache.airavata.schemas.gfac.Parameter[outputList.size()]);
+            serv.setInputParameters(inputParamList);
+            serv.setOutputParameters(outputParamList);
+
+            /*
+             * Save to registry
+             */
+            jcrRegistry.saveServiceDescription(serv);
+                        
+            /*
+             * Load
+             */
+            ServiceDescription service = jcrRegistry.getServiceDescription(serviceId);
+            
+            if(service == null){
+                fail("Service is null");
+            }
             
-            if(!(hostR.getId().equals(hostId) && hostR.getAddress().equals(address))){
-            	fail("Save and Load Host Description Fail with Different Value");	
+            if(service.getInputParameters() == null || service.getInputParameters().length
!= 1){
+                fail("Input Parameters is missing");
             }
-          
-        }catch(Exception e){
+            
+            if(service.getOutputParameters()== null || service.getOutputParameters().length
!= 1){
+                fail("Input Parameters is missing");
+            }
+            
+            
+            
+        } catch (Exception e) {
             e.printStackTrace();
-        	fail(e.getMessage());
+            fail(e.getMessage());
         }
     }
 }



Mime
View raw message