@@ -160,15 +160,19 @@ public void setUp() {
160160 new ImmutableMap .Builder <String , String >()
161161 .put ("project_id" , PROJECT_ID )
162162 .build ())
163- .build ())
163+ .build ()),
164+ WriteOption .partialSuccess (true ),
164165 };
165166
166167 @ Test
167168 public void testFlushLevelConfigUpdatesLoggingFlushSeverity () {
168169 logging .setFlushSeverity (Severity .WARNING );
169170 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
170171 logging .write (
171- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
172+ capture (capturedArgument ),
173+ anyObject (WriteOption .class ),
174+ anyObject (WriteOption .class ),
175+ anyObject (WriteOption .class ));
172176 replay (logging );
173177 Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
174178 LoggingEvent loggingEvent = createLoggingEvent (Level .WARN , timestamp .getSeconds ());
@@ -194,7 +198,10 @@ public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {
194198 logging .setFlushSeverity (Severity .ERROR );
195199 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
196200 logging .write (
197- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
201+ capture (capturedArgument ),
202+ anyObject (WriteOption .class ),
203+ anyObject (WriteOption .class ),
204+ anyObject (WriteOption .class ));
198205 expectLastCall ().once ();
199206 replay (logging );
200207 Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
@@ -215,12 +222,16 @@ public void testFilterLogsOnlyLogsAtOrAboveLogLevel() {
215222 }
216223
217224 @ Test
218- public void testDefaultWriteOptionsHasExpectedDefaults () {
225+ public void testPartialSuccessOverrideHasExpectedValue () {
219226 logging .setFlushSeverity (Severity .ERROR );
220227 Capture <WriteOption > logNameArg = Capture .newInstance ();
221228 Capture <WriteOption > resourceArg = Capture .newInstance ();
229+ Capture <WriteOption > partialSuccessArg = Capture .newInstance ();
222230 logging .write (
223- EasyMock .<Iterable <LogEntry >>anyObject (), capture (logNameArg ), capture (resourceArg ));
231+ EasyMock .<Iterable <LogEntry >>anyObject (),
232+ capture (logNameArg ),
233+ capture (resourceArg ),
234+ capture (partialSuccessArg ));
224235 expectLastCall ().once ();
225236 replay (logging );
226237 loggingAppender .start ();
@@ -231,14 +242,37 @@ public void testDefaultWriteOptionsHasExpectedDefaults() {
231242 assertThat (logNameArg .getValue ()).isEqualTo (defaultWriteOptions [0 ]);
232243 // TODO(chingor): Fix this test to work on GCE and locally
233244 // assertThat(resourceArg.getValue()).isEqualTo(defaultWriteOptions[1]);
245+ assertThat (partialSuccessArg .getValue ()).isEqualTo (defaultWriteOptions [2 ]);
246+ }
247+
248+ @ Test
249+ public void testDefaultWriteOptionsHasExpectedDefaults () {
250+ logging .setFlushSeverity (Severity .ERROR );
251+ Capture <WriteOption > partialSuccessArg = Capture .newInstance ();
252+ logging .write (
253+ EasyMock .<Iterable <LogEntry >>anyObject (),
254+ anyObject (WriteOption .class ),
255+ anyObject (WriteOption .class ),
256+ capture (partialSuccessArg ));
257+ expectLastCall ().once ();
258+ replay (logging );
259+ loggingAppender .setPartialSuccess (false );
260+ loggingAppender .start ();
261+ Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
262+ LoggingEvent loggingEvent = createLoggingEvent (Level .ERROR , timestamp .getSeconds ());
263+ loggingAppender .doAppend (loggingEvent );
264+ assertThat (partialSuccessArg .getValue ()).isEqualTo (WriteOption .partialSuccess (false ));
234265 }
235266
236267 @ Test
237268 public void testMdcValuesAreConvertedToLabels () {
238269 logging .setFlushSeverity (Severity .ERROR );
239270 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
240271 logging .write (
241- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
272+ capture (capturedArgument ),
273+ anyObject (WriteOption .class ),
274+ anyObject (WriteOption .class ),
275+ anyObject (WriteOption .class ));
242276 expectLastCall ().once ();
243277 replay (logging );
244278 Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
@@ -294,7 +328,10 @@ public void testMdcValuesAreConvertedToLabelsWithPassingNullValues() {
294328 logging .setFlushSeverity (Severity .ERROR );
295329 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
296330 logging .write (
297- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
331+ capture (capturedArgument ),
332+ anyObject (WriteOption .class ),
333+ anyObject (WriteOption .class ),
334+ anyObject (WriteOption .class ));
298335 expectLastCall ().once ();
299336 replay (logging );
300337 Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
@@ -317,7 +354,10 @@ public void testAddCustomLoggingEventEnhancers() {
317354 logging .setFlushSeverity (Severity .ERROR );
318355 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
319356 logging .write (
320- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
357+ capture (capturedArgument ),
358+ anyObject (WriteOption .class ),
359+ anyObject (WriteOption .class ),
360+ anyObject (WriteOption .class ));
321361 expectLastCall ().once ();
322362 replay (logging );
323363 Timestamp timestamp = Timestamp .ofTimeSecondsAndNanos (100000 , 0 );
@@ -338,7 +378,10 @@ public void testAddCustomLoggingEnhancer() {
338378 logging .setFlushSeverity (Severity .ERROR );
339379 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
340380 logging .write (
341- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
381+ capture (capturedArgument ),
382+ anyObject (WriteOption .class ),
383+ anyObject (WriteOption .class ),
384+ anyObject (WriteOption .class ));
342385 expectLastCall ().once ();
343386 replay (logging );
344387 loggingAppender .addEnhancer (CustomLoggingEnhancer .class .getName ());
@@ -359,6 +402,7 @@ public void testFlush() {
359402 logging .write (
360403 EasyMock .<Iterable <LogEntry >>anyObject (),
361404 anyObject (WriteOption .class ),
405+ anyObject (WriteOption .class ),
362406 anyObject (WriteOption .class ));
363407 expectLastCall ().times (2 );
364408 logging .flush ();
@@ -395,6 +439,7 @@ public void testAutoPopulationEnabled() {
395439 logging .write (
396440 EasyMock .<Iterable <LogEntry >>anyObject (),
397441 anyObject (WriteOption .class ),
442+ anyObject (WriteOption .class ),
398443 anyObject (WriteOption .class ));
399444 expectLastCall ().once ();
400445 replay (logging );
@@ -460,7 +505,10 @@ public void testFDiagnosticInfoAdded() {
460505 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
461506 logging .setFlushSeverity (Severity .ERROR );
462507 logging .write (
463- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
508+ capture (capturedArgument ),
509+ anyObject (WriteOption .class ),
510+ anyObject (WriteOption .class ),
511+ anyObject (WriteOption .class ));
464512 replay (logging );
465513 LoggingEvent loggingEvent =
466514 createLoggingEvent (Level .ERROR , Timestamp .ofTimeSecondsAndNanos (100000 , 0 ).getSeconds ());
@@ -502,7 +550,10 @@ public void testFDiagnosticInfoNotAdded() {
502550 logging .setFlushSeverity (Severity .ERROR );
503551 Capture <Iterable <LogEntry >> capturedArgument = Capture .newInstance ();
504552 logging .write (
505- capture (capturedArgument ), anyObject (WriteOption .class ), anyObject (WriteOption .class ));
553+ capture (capturedArgument ),
554+ anyObject (WriteOption .class ),
555+ anyObject (WriteOption .class ),
556+ anyObject (WriteOption .class ));
506557 replay (logging );
507558 LoggingEvent loggingEvent =
508559 createLoggingEvent (Level .WARN , Timestamp .ofTimeSecondsAndNanos (100000 , 0 ).getSeconds ());
0 commit comments