Skip to content

Commit 0184291

Browse files
committed
adding mockito runner
1 parent a1ed15c commit 0184291

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

google-cloud-contrib/google-cloud-logging-logback/src/main/java/com/google/cloud/logging/contrib/LoggingAppender.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class LoggingAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
5656
private static final String LEVEL_NAME_KEY = "levelName";
5757
private static final String LEVEL_VALUE_KEY = "levelValue";
5858

59-
private LoggingOptions loggingOptions;
6059
private volatile Logging logging;
6160
private List<LoggingEnhancer> loggingEnhancers;
6261
private WriteOption[] defaultWriteOptions;
@@ -156,7 +155,6 @@ List<LoggingEnhancer> getEnhancers() {
156155
/** Initialze and configure the cloud logging service. */
157156
@Override
158157
public synchronized void start() {
159-
loggingOptions = LoggingOptions.getDefaultInstance();
160158
MonitoredResource resource = getMonitoredResource(getProjectId());
161159
Level level = getLogLevel();
162160
defaultWriteOptions =
@@ -176,7 +174,7 @@ public synchronized void start() {
176174
}
177175

178176
protected String getProjectId() {
179-
return loggingOptions.getProjectId();
177+
return LoggingOptions.getDefaultInstance().getProjectId();
180178
}
181179

182180
@Override
@@ -209,7 +207,7 @@ protected Logging getLogging() {
209207
if (logging == null) {
210208
synchronized (this) {
211209
if (logging == null) {
212-
logging = loggingOptions.getService();
210+
logging = LoggingOptions.getDefaultInstance().getService();
213211
}
214212
}
215213
}

google-cloud-contrib/google-cloud-logging-logback/src/test/java/com/google/cloud/logging/contrib/LoggingAppenderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
import org.junit.Before;
3838
import org.junit.Test;
3939
import org.junit.runner.RunWith;
40-
import org.junit.runners.JUnit4;
4140

4241
import java.util.Collections;
42+
import org.mockito.junit.MockitoJUnitRunner;
4343

44-
@RunWith(JUnit4.class)
44+
@RunWith(MockitoJUnitRunner.class)
4545
public class LoggingAppenderTest {
4646

4747
private final String projectId = "test-project";

0 commit comments

Comments
 (0)