package com.sos.scheduler.model.commands;
import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
import com.sos.JSHelper.Exceptions.JobSchedulerException;
import com.sos.scheduler.model.SchedulerObjectFactory;
import com.sos.scheduler.model.answers.Answer;
import com.sos.scheduler.model.answers.ERROR;
import com.sos.scheduler.model.objects.Param;
import com.sos.scheduler.model.objects.Params;
import com.sos.scheduler.model.objects.Spooler;
public class JSCmdAddOrderTest \{
private final static Logger logger = Logger.getLogger(JSCmdAddOrderTest.class);
private static SchedulerObjectFactory factory = null;
@BeforeClass
public static void setUpBeforeClass() throws Exception \{
factory = new SchedulerObjectFactory("localhost",4112);
factory.initMarshaller(Spooler.class);
\}
@Test
public final void testSetValidXmlContent() \{
JSCmdAddOrder cmdOrder = factory.createAddOrder();
cmdOrder.setJobChain("/job_chain_multiple_inheritance_sample/job_chain_multiple_inheritance_sample");
cmdOrder.setReplace("yes");
cmdOrder.setId("A");
cmdOrder.setTitle("JobNet: null");
Param p1 = factory.createParam("uuid_jobnet_identifier","989ac2ce-2538-4276-8003-3350a6224c97");
Param p2 = factory.createParam("jobnet","/job_chain_multiple_inheritance_sample/job_chain_multiple_inheritance_sample");
Param p3 = factory.createParam("successor","B,C,D,");
Param p4 = factory.createParam("predecessor","");
Param p5 = factory.createParam("script_to_execute","echo Here is the bootstrap order");
cmdOrder.setParams( new Params() );
cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p3);
cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p4);
cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p5);
cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p1);
cmdOrder.getParams().getParamOrCopyParamsOrInclude().add(p2);
cmdOrder.setAt("2012-04-17 22:00");
cmdOrder.run();
Answer answer = cmdOrder.getAnswer();
ERROR jsError = answer.getERROR();
if (jsError != null) \{
String xml = cmdOrder.toXMLString();
logger.debug(xml);
throw new JobSchedulerException("Command not executed due to an error");
\}
\}
\}
|