X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Flogging%2Fbridge%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Flogging%2Fbridge%2Finternal%2FLogListenerImplTest.java;fp=opendaylight%2Flogging%2Fbridge%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Flogging%2Fbridge%2Finternal%2FLogListenerImplTest.java;h=2490c39171f57edd3a5213093984030f6b55dc19;hp=0000000000000000000000000000000000000000;hb=dbb635f96384aa204520ad7109fe072a7044ff6d;hpb=3eb3d2d181fd81a1b723f90ca98d56e8bc7b3ba4 diff --git a/opendaylight/logging/bridge/src/test/java/org/opendaylight/controller/logging/bridge/internal/LogListenerImplTest.java b/opendaylight/logging/bridge/src/test/java/org/opendaylight/controller/logging/bridge/internal/LogListenerImplTest.java new file mode 100644 index 0000000000..2490c39171 --- /dev/null +++ b/opendaylight/logging/bridge/src/test/java/org/opendaylight/controller/logging/bridge/internal/LogListenerImplTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.logging.bridge.internal; + +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogEntry; +import org.osgi.service.log.LogService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +public class LogListenerImplTest { + private static final Logger logger = LoggerFactory.getLogger(LogListenerImplTest.class); + + @Test + public void test() { + LogListenerImpl tested = new LogListenerImpl(logger); + tested.logged(getEntry("m1", null)); + tested.logged(getEntry("m2", new RuntimeException())); + } + + private LogEntry getEntry(final String message, final Exception e) { + return new LogEntry() { + @Override + public Bundle getBundle() { + Bundle mock = mock(Bundle.class); + doReturn(null).when(mock).getSymbolicName(); + return mock; + } + + @Override + public ServiceReference getServiceReference() { + return null; + } + + @Override + public int getLevel() { + return LogService.LOG_INFO; + } + + @Override + public String getMessage() { + return message; + } + + @Override + public Throwable getException() { + return e; + } + + @Override + public long getTime() { + return 0; + } + }; + } + +}