Author: lahiru
Date: Fri Feb  1 22:00:30 2013
New Revision: 1441647

URL: http://svn.apache.org/viewvc?rev=1441647&view=rev
Log:
Adding test case to test input file stagin.

Added:
    
airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTest.java

Added: 
airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTest.java
URL: 
http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTest.java?rev=1441647&view=auto
==============================================================================
--- 
airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTest.java
 (added)
+++ 
airavata/trunk/modules/gfac-core/src/test/java/org/apache/airavata/core/gfac/services/impl/ParamChemTest.java
 Fri Feb  1 22:00:30 2013
@@ -0,0 +1,291 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.core.gfac.services.impl;
+
+import org.apache.airavata.commons.gfac.type.*;
+import org.apache.airavata.gfac.GFacAPI;
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.GFacException;
+import org.apache.airavata.gfac.context.ApplicationContext;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.schemas.gfac.*;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+public class ParamChemTest {
+    private JobExecutionContext jobExecutionContext;
+
+    @Before
+    public void setUp() throws Exception {
+
+        GFacConfiguration gFacConfiguration = new GFacConfiguration(null);
+        gFacConfiguration.setMyProxyLifeCycle(3600);
+        gFacConfiguration.setMyProxyServer("myproxy.teragrid.org");
+        gFacConfiguration.setMyProxyUser("ccguser");
+        gFacConfiguration.setMyProxyPassphrase("");
+        
gFacConfiguration.setTrustedCertLocation("/Users/lahirugunathilake/Downloads/certificates");
+        //have to set InFlwo Handlers and outFlowHandlers
+        jobExecutionContext = new JobExecutionContext(gFacConfiguration);
+        ApplicationContext applicationContext = new ApplicationContext();
+        jobExecutionContext.setApplicationContext(applicationContext);
+        /*
+        * Host
+        */
+        String serviceName = "Prepare_Model_Reference_Data";
+        HostDescription host = new HostDescription(GlobusHostType.type);
+        host.getType().setHostName("trestles");
+        host.getType().setHostAddress("trestles.sdsc.edu");
+        ((GlobusHostType) 
host.getType()).addGridFTPEndPoint("gsiftp://trestles-login2.sdsc.edu:2811";);
+        ((GlobusHostType) 
host.getType()).addGlobusGateKeeperEndPoint("trestles-login2.sdsc.edu:2119/jobmanager-pbstest2");
+
+        applicationContext.setHostDescription(host);
+        /*
+        * App
+        */
+        ApplicationDescription appDesc =
+                new ApplicationDescription(HpcApplicationDeploymentType.type);
+        ApplicationDeploymentDescriptionType 
applicationDeploymentDescriptionType
+                = appDesc.getType();
+        
applicationDeploymentDescriptionType.addNewApplicationName().setStringValue(serviceName);
+        String tempDir = 
"/oasis/projects/nsf/uic151/gridchem/airavata-workdirs";
+        String date = (new Date()).toString();
+        date = date.replaceAll(" ", "_");
+        date = date.replaceAll(":", "_");
+
+        tempDir = tempDir + File.separator
+                + serviceName + "_" + date + "_" + UUID.randomUUID();
+        
applicationDeploymentDescriptionType.setExecutableLocation("/home/gridchem/workflow_script/sys_exec/scripts/step1/step1_model_refdata_prep.sh");
+        
applicationDeploymentDescriptionType.setScratchWorkingDirectory(tempDir);
+        
applicationDeploymentDescriptionType.setStaticWorkingDirectory(tempDir);
+        applicationDeploymentDescriptionType.setInputDataDirectory(tempDir + 
File.separator + "inputData");
+        applicationDeploymentDescriptionType.setOutputDataDirectory(tempDir + 
File.separator + "outputData");
+        applicationDeploymentDescriptionType.setStandardOutput(tempDir + 
File.separator + 
applicationDeploymentDescriptionType.getApplicationName().getStringValue() + 
".stdout");
+        applicationDeploymentDescriptionType.setStandardError(tempDir + 
File.separator + 
applicationDeploymentDescriptionType.getApplicationName().getStringValue() + 
".stderr");
+
+        ProjectAccountType projectAccountType = 
((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).addNewProjectAccount();
+        projectAccountType.setProjectAccountNumber("uic151");
+
+        QueueType queueType = ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).addNewQueue();
+        queueType.setQueueName("shared");
+
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setJobType(JobTypeType.SERIAL);
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setMaxWallTime(30);
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setMaxMemory(2000);
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setCpuCount(1);
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setNodeCount(1);
+        ((HpcApplicationDeploymentType) 
applicationDeploymentDescriptionType).setProcessorsPerNode(1);
+
+        applicationContext.setApplicationDeploymentDescription(appDesc);
+
+        /*
+        * Service
+        */
+        ServiceDescription serv = new ServiceDescription();
+        List<InputParameterType> inputParameters = new 
ArrayList<InputParameterType>();
+        List<OutputParameterType> outputParameters = new 
ArrayList<OutputParameterType>();
+
+        serv.getType().setName(serviceName);
+        serv.getType().setDescription(serviceName);
+
+        //Creating input parameters
+        InputParameterType parameter = 
InputParameterType.Factory.newInstance();
+        parameter.setParameterName("molecule_id");
+        ParameterType parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("geom_mol2");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.URI);
+        parameterType.setName("URI");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("toppar_main_tgz");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.URI);
+        parameterType.setName("URI");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("toppar_usr_tgz");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.URI);
+        parameterType.setName("URI");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("toppar_mol_str");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.URI);
+        parameterType.setName("URI");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("molecule_dir_in_tgz");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.URI);
+        parameterType.setName("URI");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("GC_UserName");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("GC_ProjectName");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        parameter = InputParameterType.Factory.newInstance();
+        parameter.setParameterName("GC_WorkflowName");
+        parameterType = parameter.addNewParameterType();
+        parameterType.setType(DataType.STRING);
+        parameterType.setName("String");
+        inputParameters.add(parameter);
+
+        //Creating output parameters
+        OutputParameterType outputParameter = 
OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("opt_freq_input_gjf");
+        ParameterType outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.URI);
+        outputParaType.setName("URI");
+        outputParameters.add(outputParameter);
+
+        outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("charmm_miminized_crd");
+        outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.URI);
+        outputParaType.setName("URI");
+        outputParameters.add(outputParameter);
+
+        outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("step1_log");
+        outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.URI);
+        outputParaType.setName("URI");
+        outputParameters.add(outputParameter);
+
+        outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("molecule_dir_out_tgz");
+        outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.URI);
+        outputParaType.setName("URI");
+        outputParameters.add(outputParameter);
+
+        outputParameter = OutputParameterType.Factory.newInstance();
+        outputParameter.setParameterName("gcvars");
+        outputParaType = outputParameter.addNewParameterType();
+        outputParaType.setType(DataType.URI);
+        outputParaType.setName("URI");
+        outputParameters.add(outputParameter);
+
+        //Setting input and output parameters to serviceDescriptor
+        serv.getType().setInputParametersArray(inputParameters.toArray(new 
InputParameterType[]{}));
+        serv.getType().setOutputParametersArray(outputParameters.toArray(new 
OutputParameterType[]{}));
+
+        applicationContext.setServiceDescription(serv);
+
+        MessageContext inMessage = new MessageContext();
+
+        ActualParameter echo_input = new ActualParameter();
+        ((StringParameterType) echo_input.getType()).setValue("ai");
+        inMessage.addParameter("molecule_id", echo_input);
+
+        ActualParameter geom_mol2 = new ActualParameter(URIParameterType.type);
+        ((URIParameterType) 
geom_mol2.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/ai.mol2";);
+        inMessage.addParameter("geom_mol2", geom_mol2);
+
+        ActualParameter toppar_main_tgz = new 
ActualParameter(URIParameterType.type);
+        ((URIParameterType) 
toppar_main_tgz.getType()).setValue("/home/gridchem/workflow_script/toppar/cgenff/releases/2b7/main.tgz");
+        inMessage.addParameter("toppar_main_tgz", toppar_main_tgz);
+
+        ActualParameter toppar_usr_tgz = new 
ActualParameter(URIParameterType.type);
+        ((URIParameterType) 
toppar_usr_tgz.getType()).setValue("gsiftp://trestles.sdsc.edu";);
+        inMessage.addParameter("toppar_usr_tgz", toppar_usr_tgz);
+
+        ActualParameter toppar_mol_str = new 
ActualParameter(URIParameterType.type);
+        ((URIParameterType) 
toppar_mol_str.getType()).setValue("http://ccg-mw1.ncsa.uiuc.edu/cgenff/leoshen/cgenff_project/ai/toppar/ai.str";);
+        inMessage.addParameter("toppar_mol_str", toppar_mol_str);
+
+        ActualParameter molecule_dir_in_tgz = new 
ActualParameter(URIParameterType.type);
+        ((URIParameterType) molecule_dir_in_tgz.getType()).setValue("");
+        inMessage.addParameter("molecule_dir_in_tgz", molecule_dir_in_tgz);
+
+        ActualParameter GC_UserName = new ActualParameter();
+        ((StringParameterType) GC_UserName.getType()).setValue("leoshen");
+        inMessage.addParameter("GC_UserName", GC_UserName);
+
+        ActualParameter GC_ProjectName = new ActualParameter();
+        ((StringParameterType) GC_ProjectName.getType()).setValue("leoshen");
+        inMessage.addParameter("GC_ProjectName", GC_ProjectName);
+
+        ActualParameter GC_WorkflowName = new ActualParameter();
+        ((StringParameterType) 
GC_WorkflowName.getType()).setValue("ai__1339258840");
+        inMessage.addParameter("GC_WorkflowName", GC_WorkflowName);
+
+        jobExecutionContext.setInMessageContext(inMessage);
+
+        MessageContext outMessage = new MessageContext();
+
+        ActualParameter opt_freq_input_gjf = new 
ActualParameter(URIParameterType.type);
+        outMessage.addParameter("opt_freq_input_gjf", opt_freq_input_gjf);
+
+        ActualParameter charmm_miminized_crd = new 
ActualParameter(URIParameterType.type);
+        outMessage.addParameter("charmm_miminized_crd", charmm_miminized_crd);
+
+        ActualParameter step1_log = new ActualParameter(URIParameterType.type);
+        outMessage.addParameter("step1_log", step1_log);
+
+        ActualParameter molecule_dir_out_tgz = new 
ActualParameter(URIParameterType.type);
+        outMessage.addParameter("molecule_dir_out_tgz", molecule_dir_out_tgz);
+
+        ActualParameter gcvars = new ActualParameter(URIParameterType.type);
+        outMessage.addParameter("gcvars", gcvars);
+
+        jobExecutionContext.setOutMessageContext(outMessage);
+
+    }
+
+    @Test
+    public void testGramProvider() throws GFacException {
+//        GFacAPI gFacAPI = new GFacAPI();
+//        gFacAPI.submitJob(jobExecutionContext);
+//        MessageContext outMessageContext = 
jobExecutionContext.getOutMessageContext();
+//        Assert.assertFalse(outMessageContext.getParameters().isEmpty());
+//        Assert.assertEquals(MappingFactory.toString((ActualParameter) 
outMessageContext.getParameter("echo_output")), "hello");
+    }
+}


Reply via email to