You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2011/12/21 21:09:59 UTC

svn commit: r1221862 - in /incubator/airavata/trunk/modules/commons/registry-api/src: main/java/org/apache/airavata/registry/api/ main/java/org/apache/airavata/registry/api/impl/ test/java/org/apache/airavata/registry/api/impl/

Author: lahiru
Date: Wed Dec 21 20:09:58 2011
New Revision: 1221862

URL: http://svn.apache.org/viewvc?rev=1221862&view=rev
Log:
adding more tests and changes to registry-api

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryDeleteTest.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java?rev=1221862&r1=1221861&r2=1221862&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java Wed Dec 21 20:09:58 2011
@@ -45,7 +45,7 @@ public interface Registry {
      * @param serviceId
      * @return List of HostDescription having the service
      */
-    public List<HostDescription> getServiceLocation(String serviceId);
+//    public List<HostDescription> getServiceLocation(String serviceId);
 
     /**
      * Retrieve a service description i.e. name, description, parameters

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1221862&r1=1221861&r2=1221862&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java Wed Dec 21 20:09:58 2011
@@ -200,31 +200,31 @@ public class JCRRegistry extends Observa
         }
     }
 
-    public List<HostDescription> getServiceLocation(String serviceId) {
-        Session session = null;
-        ArrayList<HostDescription> result = new ArrayList<HostDescription>();
-        try {
-            session = getSession();
-            Node node = getServiceNode(session);
-            Node serviceNode = node.getNode(serviceId);
-            if (serviceNode.hasProperty(LINK_NAME)) {
-                Property prop = serviceNode.getProperty(LINK_NAME);
-                Value[] vals = prop.getValues();
-                for (Value val : vals) {
-                    Node host = session.getNodeByIdentifier(val.getString());
-                    Property hostProp = host.getProperty(XML_PROPERTY_NAME);
-                    result.add(HostDescription.fromXML(hostProp.getString()));
-                }
-            }
-        } catch (Exception e) {
-            System.out.println(e);
-            e.printStackTrace();
-            // TODO propagate
-        } finally {
-            closeSession(session);
-        }
-        return result;
-    }
+//    public List<HostDescription> getServiceLocation(String serviceId) {
+//        Session session = null;
+//        ArrayList<HostDescription> result = new ArrayList<HostDescription>();
+//        try {
+//            session = getSession();
+//            Node node = getServiceNode(session);
+//            Node serviceNode = node.getNode(serviceId);
+//            if (serviceNode.hasProperty(LINK_NAME)) {
+//                Property prop = serviceNode.getProperty(LINK_NAME);
+//                Value[] vals = prop.getValues();
+//                for (Value val : vals) {
+//                    Node host = session.getNodeByIdentifier(val.getString());
+//                    Property hostProp = host.getProperty(XML_PROPERTY_NAME);
+//                    result.add(HostDescription.fromXML(hostProp.getString()));
+//                }
+//            }
+//        } catch (Exception e) {
+//            System.out.println(e);
+//            e.printStackTrace();
+//            // TODO propagate
+//        } finally {
+//            closeSession(session);
+//        }
+//        return result;
+//    }
 
     public void deleteServiceDescription(String serviceId) throws ServiceDescriptionRetrieveException {
         Session session = null;

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryDeleteTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryDeleteTest.java?rev=1221862&r1=1221861&r2=1221862&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryDeleteTest.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/test/java/org/apache/airavata/registry/api/impl/JCRRegistryDeleteTest.java Wed Dec 21 20:09:58 2011
@@ -20,18 +20,25 @@
 */
 package org.apache.airavata.registry.api.impl;
 
+import com.sun.source.tree.AssertTree;
 import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.OutputParameterType;
 import org.apache.jackrabbit.core.TransientRepository;
 import org.junit.Assert;
 import org.junit.Test;
 
 import javax.jcr.Repository;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import static org.junit.Assert.fail;
 
 public class JCRRegistryDeleteTest {
     @Test
-       public void testJCRRegistryDelete() {
+       public void testHostDescriptionDelete() {
            try {
                /*
                 * Create database
@@ -54,9 +61,53 @@ public class JCRRegistryDeleteTest {
 
                HostDescription hostR = jcrRegistry.getHostDescription(hostId);
                Assert.assertNull(hostR);
+
+
            } catch (Exception e) {
                e.printStackTrace();
                fail(e.getMessage());
            }
        }
+
+    @Test
+    public void testServiceDescriptionDelete() {
+        try {
+            /*
+            * Create database
+            */
+            JCRRegistry jcrRegistry = new JCRRegistry(null, "org.apache.jackrabbit.core.RepositoryFactoryImpl",
+                    "admin", "admin", null);
+
+            ServiceDescription serv = new ServiceDescription();
+            serv.getType().setName("SimpleEcho");
+
+            InputParameterType input = InputParameterType.Factory.newInstance();
+            input.setParameterName("echo_input");
+            List<InputParameterType> inputList = new ArrayList<InputParameterType>();
+            inputList.add(input);
+            InputParameterType[] inputParamList = inputList.toArray(new InputParameterType[inputList
+                    .size()]);
+
+            OutputParameterType output = OutputParameterType.Factory.newInstance();
+            output.setParameterName("echo_output");
+            List<OutputParameterType> outputList = new ArrayList<OutputParameterType>();
+            outputList.add(output);
+            OutputParameterType[] outputParamList = outputList
+                    .toArray(new OutputParameterType[outputList.size()]);
+            serv.getType().setInputParametersArray(inputParamList);
+            serv.getType().setOutputParametersArray(outputParamList);
+
+            /*
+             * Save to registry
+             */
+            jcrRegistry.saveServiceDescription(serv);
+
+            jcrRegistry.deleteServiceDescription(serv.getType().getName());
+            jcrRegistry.getServiceDescription(serv.getType().getName());
+        } catch (Exception e) {
+            junit.framework.Assert.assertTrue(true);
+            return;
+        }
+        Assert.assertTrue(false);
+    }
 }