Search in sources :

Example 21 with SaturnJobReturn

use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.

the class JsonParseObjectTest method test_H_blank.

/**
 * 没有内容
 */
@Test
public void test_H_blank() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(ScriptJobRunner.class);
    logbackListAppender.start();
    SaturnJobReturn saturnJobReturn = readSaturnJobReturn("/SaturnJobReturnBlank");
    assertThat(logbackListAppender.getLastMessage()).isNull();
    assertThat(saturnJobReturn).isNull();
}
Also used : SaturnJobReturn(com.vip.saturn.job.SaturnJobReturn) LogbackListAppender(com.vip.saturn.job.executor.utils.LogbackListAppender) Test(org.junit.Test)

Example 22 with SaturnJobReturn

use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.

the class JsonParseObjectTest method test_I_trim.

@Test
public void test_I_trim() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(ScriptJobRunner.class);
    logbackListAppender.start();
    SaturnJobReturn saturnJobReturn = readSaturnJobReturn("/SaturnJobReturnTrim");
    SaturnJobReturn expect = new SaturnJobReturn(500, "hello world", 200);
    HashMap<String, String> prop = new HashMap();
    prop.put("key", "value");
    expect.setProp(prop);
    assertThat(logbackListAppender.getLastMessage()).isNull();
    assertThat(saturnJobReturn).isNotNull().isEqualToComparingFieldByField(expect);
}
Also used : SaturnJobReturn(com.vip.saturn.job.SaturnJobReturn) LogbackListAppender(com.vip.saturn.job.executor.utils.LogbackListAppender) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 23 with SaturnJobReturn

use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.

the class JsonParseObjectTest method test_B_overFields.

@Test
public void test_B_overFields() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(ScriptJobRunner.class);
    logbackListAppender.start();
    SaturnJobReturn saturnJobReturn = readSaturnJobReturn("/SaturnJobReturnMoreFields");
    SaturnJobReturn expect = new SaturnJobReturn(500, "hello world", 200);
    HashMap<String, String> prop = new HashMap();
    prop.put("key", "value");
    expect.setProp(prop);
    assertThat(logbackListAppender.getLastMessage()).isNull();
    assertThat(saturnJobReturn).isNotNull().isEqualToComparingFieldByField(expect);
}
Also used : SaturnJobReturn(com.vip.saturn.job.SaturnJobReturn) LogbackListAppender(com.vip.saturn.job.executor.utils.LogbackListAppender) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 24 with SaturnJobReturn

use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.

the class JsonParseObjectTest method test_C_lessFieldErrorGroup.

/**
 * 少errorGroup,默认为200
 */
@Test
public void test_C_lessFieldErrorGroup() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(ScriptJobRunner.class);
    logbackListAppender.start();
    SaturnJobReturn saturnJobReturn = readSaturnJobReturn("/SaturnJobReturnLessFieldErrorGroup");
    SaturnJobReturn expect = new SaturnJobReturn(500, "hello world", 200);
    HashMap<String, String> prop = new HashMap();
    prop.put("key", "value");
    expect.setProp(prop);
    assertThat(logbackListAppender.getLastMessage()).isNull();
    assertThat(saturnJobReturn).isNotNull().isEqualToComparingFieldByField(expect);
}
Also used : SaturnJobReturn(com.vip.saturn.job.SaturnJobReturn) LogbackListAppender(com.vip.saturn.job.executor.utils.LogbackListAppender) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 25 with SaturnJobReturn

use of com.vip.saturn.job.SaturnJobReturn in project Saturn by vipshop.

the class JsonParseObjectTest method test_G_NoFields.

/**
 * 少全部字段,只有{}
 */
@Test
public void test_G_NoFields() throws Exception {
    LogbackListAppender logbackListAppender = new LogbackListAppender();
    logbackListAppender.addToLogger(ScriptJobRunner.class);
    logbackListAppender.start();
    SaturnJobReturn saturnJobReturn = readSaturnJobReturn("/SaturnJobReturnNoFields");
    SaturnJobReturn expect = new SaturnJobReturn();
    assertThat(logbackListAppender.getLastMessage()).isNull();
    assertThat(saturnJobReturn).isNotNull().isEqualToComparingFieldByField(expect);
}
Also used : SaturnJobReturn(com.vip.saturn.job.SaturnJobReturn) LogbackListAppender(com.vip.saturn.job.executor.utils.LogbackListAppender) Test(org.junit.Test)

Aggregations

SaturnJobReturn (com.vip.saturn.job.SaturnJobReturn)35 LogbackListAppender (com.vip.saturn.job.executor.utils.LogbackListAppender)9 HashMap (java.util.HashMap)9 Test (org.junit.Test)9 Date (java.util.Date)4 JobInitAlarmException (com.vip.saturn.job.exception.JobInitAlarmException)2 UncaughtExceptionHandler (java.lang.Thread.UncaughtExceptionHandler)2 ExecutorService (java.util.concurrent.ExecutorService)2 DemoService (com.vip.saturn.demo.service.DemoService)1 SaturnExecutionContext (com.vip.saturn.job.basic.SaturnExecutionContext)1 ShardingItemCallable (com.vip.saturn.job.basic.ShardingItemCallable)1 ExecutionInfo (com.vip.saturn.job.internal.control.ExecutionInfo)1 RegException (com.vip.saturn.job.reg.exception.RegException)1 ScriptJobRunner (com.vip.saturn.job.shell.ScriptJobRunner)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CommandLine (org.apache.commons.exec.CommandLine)1