30
30
import com .uber .cadence .testing .TestWorkflowEnvironment ;
31
31
import com .uber .cadence .worker .Worker ;
32
32
import java .time .Duration ;
33
- import java .util .Arrays ;
34
- import java .util .Collection ;
33
+ import java .util .UUID ;
35
34
import org .junit .Test ;
36
- import org .junit .runner .RunWith ;
37
- import org .junit .runners .Parameterized ;
38
- import org .junit .runners .Parameterized .Parameter ;
39
- import org .junit .runners .Parameterized .Parameters ;
40
35
import org .slf4j .Logger ;
41
36
import org .slf4j .LoggerFactory ;
42
37
43
- @ RunWith (Parameterized .class )
44
38
public class LoggerTest {
45
39
46
40
private static final ListAppender <ILoggingEvent > listAppender = new ListAppender <>();
@@ -54,29 +48,15 @@ public class LoggerTest {
54
48
}
55
49
56
50
private static final String taskList = "logger-test" ;
57
- private static final Logger workflowLogger = Workflow .getLogger (TestLoggingInWorkflow .class );
58
- private static final Logger childWorkflowLogger =
59
- Workflow .getLogger (TestLoggerInChildWorkflow .class );
60
-
61
- @ Parameters
62
- public static Collection <Object []> data () {
63
- return Arrays .asList (new Object [][] {{false , "wf-1" , 1 }, {true , "wf-2" , 3 }});
64
- }
65
-
66
- @ Parameter public boolean loggingEnabledInReplay ;
67
-
68
- @ Parameter (1 )
69
- public String wfID ;
70
-
71
- @ Parameter (2 )
72
- public int startLinesExpected ;
73
51
74
52
public interface TestWorkflow {
75
53
@ WorkflowMethod
76
54
void execute (String id );
77
55
}
78
56
79
57
public static class TestLoggingInWorkflow implements LoggerTest .TestWorkflow {
58
+ private final Logger workflowLogger = Workflow .getLogger (TestLoggingInWorkflow .class );
59
+
80
60
@ Override
81
61
public void execute (String id ) {
82
62
workflowLogger .info ("Start executing workflow {}." , id );
@@ -95,6 +75,8 @@ public interface TestChildWorkflow {
95
75
}
96
76
97
77
public static class TestLoggerInChildWorkflow implements LoggerTest .TestChildWorkflow {
78
+ private static final Logger childWorkflowLogger =
79
+ Workflow .getLogger (TestLoggerInChildWorkflow .class );
98
80
99
81
@ Override
100
82
public void executeChild (String id ) {
@@ -107,7 +89,7 @@ public void testWorkflowLogger() {
107
89
TestEnvironmentOptions testOptions =
108
90
new TestEnvironmentOptions .Builder ()
109
91
.setDomain (WorkflowTest .DOMAIN )
110
- .setEnableLoggingInReplay (loggingEnabledInReplay )
92
+ .setEnableLoggingInReplay (false )
111
93
.build ();
112
94
TestWorkflowEnvironment env = TestWorkflowEnvironment .newInstance (testOptions );
113
95
Worker worker = env .newWorker (taskList );
@@ -123,6 +105,7 @@ public void testWorkflowLogger() {
123
105
.build ();
124
106
LoggerTest .TestWorkflow workflow =
125
107
workflowClient .newWorkflowStub (LoggerTest .TestWorkflow .class , options );
108
+ String wfID = UUID .randomUUID ().toString ();
126
109
workflow .execute (wfID );
127
110
128
111
assertEquals (1 , matchingLines (String .format ("Start executing workflow %s." , wfID )));
0 commit comments