Skip to content

Commit

Permalink
Update to latest logback and jackson version (qos-ch#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
makkan authored and tony19 committed Jan 15, 2017
1 parent 8408153 commit c68c2e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.contrib.eclipse.EclipseLogAppender;
import ch.qos.logback.contrib.eclipse.IPlatform;
Expand Down Expand Up @@ -51,16 +52,18 @@ public class EclipseLogAppenderTest {

private EclipseLogAppenderWithMockPlatform appender = null;
private PatternLayoutEncoder encoder = null;

@Before
public void before() {
// create the encoder and start it so that it initializes inner parameters
// needed by the appender
LoggerContext context = new LoggerContext();
encoder = new PatternLayoutEncoder();
encoder.setPattern("%msg");
encoder.setContext(context);
encoder.start();
assertNotNull(encoder.getLayout());

appender = new EclipseLogAppenderWithMockPlatform();
appender.setEncoder(encoder);
}
Expand All @@ -72,7 +75,7 @@ public void testNullBundleName() {
appender.start();
// then appender should still start because the field is optional
assertTrue(appender.isStarted());

// verify valid default bundle name
assertNotNull(appender.getBundleName());
assertEquals(EclipseLogAppender.DEFAULT_BUNDLE_SYMBOLIC_NAME, appender.getBundleName());
Expand Down Expand Up @@ -104,12 +107,12 @@ public void testNullEncoder() {
// then appender should not start
assertFalse(appender.isStarted());
}

@Test
public void testAppendInfo() {
MockEclipseErrorLog log = (MockEclipseErrorLog)appender.getPlatform().getLog(null);
List<IStatus> events = log.getLog();

//TODO: write me...
}
}
Expand All @@ -121,12 +124,12 @@ public void testAppendInfo() {
class EclipseLogAppenderWithMockPlatform extends EclipseLogAppender {
static private final IPlatform _platform = new IPlatform() {
private final MockEclipseErrorLog log = new MockEclipseErrorLog();

@Override
public ILog getLog(Bundle bundle) {
return log;
}

@Override
public Bundle getBundle(String bundleName) {
if (log.getBundle().getSymbolicName().equals(bundleName)) {
Expand All @@ -135,7 +138,7 @@ public Bundle getBundle(String bundleName) {
return null;
}
};

@Override
protected IPlatform getPlatform() {
return _platform;
Expand All @@ -148,11 +151,11 @@ protected IPlatform getPlatform() {
class MockEclipseErrorLog implements ILog {
static private final MockEclipseBundle BUNDLE = new MockEclipseBundle();
private List<IStatus> log;

@Override
public void addLogListener(ILogListener listener) {
// TODO Auto-generated method stub

}

@Override
Expand All @@ -168,9 +171,9 @@ public void log(IStatus status) {
@Override
public void removeLogListener(ILogListener listener) {
// TODO Auto-generated method stub

}

public List<IStatus> getLog() {
return log;
}
Expand All @@ -190,43 +193,43 @@ public int getState() {
@Override
public void start(int options) throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void start() throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void stop(int options) throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void stop() throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void update(InputStream input) throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void update() throws BundleException {
// TODO Auto-generated method stub

}

@Override
public void uninstall() throws BundleException {
// TODO Auto-generated method stub

}

@Override
Expand Down Expand Up @@ -314,7 +317,7 @@ public long getLastModified() {

@Override
public Enumeration<URL> findEntries(String path, String filePattern,
boolean recurse) {
boolean recurse) {
// TODO Auto-generated method stub
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package ch.qos.logback.contrib.json.access;

import ch.qos.logback.access.TeztConstants;
import ch.qos.logback.access.dummy.DummyAccessEventBuilder;
import ch.qos.logback.access.joran.JoranConfigurator;
import ch.qos.logback.access.spi.AccessContext;
Expand All @@ -26,6 +25,7 @@
import java.util.LinkedHashMap;
import java.util.Map;

import static ch.qos.logback.access.AccessTestConstants.TEST_DIR_PREFIX;
import static ch.qos.logback.contrib.json.access.JsonLayout.REQUESTTIME_ATTR_NAME;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.not;
Expand Down Expand Up @@ -139,7 +139,7 @@ public void addMapToJsonMap() throws Exception {

@Test
public void jsonLayout() throws Exception {
configure(TeztConstants.TEST_DIR_PREFIX + "input/json/jsonLayout.xml");
configure(TEST_DIR_PREFIX + "input/json/jsonLayout.xml");
ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) context.getAppender("STR_LIST");
IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
listAppender.doAppend(event);
Expand Down Expand Up @@ -168,7 +168,7 @@ public void jsonLayout() throws Exception {

@Test
public void jsonLayoutIncludeDefaultOff() throws Exception {
configure(TeztConstants.TEST_DIR_PREFIX + "input/json/jsonLayout.xml");
configure(TEST_DIR_PREFIX + "input/json/jsonLayout.xml");
ListAppender<IAccessEvent> listAppender = (ListAppender<IAccessEvent>) context.getAppender("STR_LIST");
IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
listAppender.doAppend(event);
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Compile Dependencies: -->
<logback.version>1.1.3</logback.version>
<jackson.version>2.1.3</jackson.version>
<logback.version>1.1.8</logback.version>
<jackson.version>2.8.5</jackson.version>
<mongo-java-driver.version>2.10.1</mongo-java-driver.version>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>

Expand Down

0 comments on commit c68c2e5

Please sign in to comment.