I am using dropwizard 1.2.4 with log4j 1.2.17. I have followed the 
instructions as mentioned below

https://github.com/arteam/dropwizard-nologback/


It is throwing an exception like below during unit testing.


java.lang.NoClassDefFoundError: ch/qos/logback/core/filter/Filter

        at 
io.dropwizard.testing.junit.ResourceTestRule.<clinit>(ResourceTestRule.java:34)
        at 
com.vnera.restapilayer.api.resources.ApiInfoControllerTest.<clinit>(ApiInfoControllerTest.java:25)
        at sun.misc.Unsafe.ensureClassInitialized(Native Method)
        at 
sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
        at 
sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
        at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
        at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
        at java.lang.reflect.Field.get(Field.java:393)
        at org.junit.runners.model.FrameworkField.get(FrameworkField.java:73)
        at 
org.junit.runners.model.TestClass.getAnnotatedFieldValues(TestClass.java:230)
        at org.junit.runners.ParentRunner.classRules(ParentRunner.java:255)
        at org.junit.runners.ParentRunner.withClassRules(ParentRunner.java:244)
        at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:194)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:362)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
        at 
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
        at 
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
        at 
com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 19 more


My test code looks like below


import io.dropwizard.testing.junit.ResourceTestRule;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import javax.ws.rs.core.Response;

import static org.mockito.Mockito.mock;

@Category(value = UnitTest.class)
public class ApiInfoControllerTest {
    private static ApiNonFunctionalHandler nonFunctionalHandler = 
mock(ApiNonFunctionalHandler.class);
    private static ApiFilter apiFilter = new ApiFilter(nonFunctionalHandler);
    private static final String authToken = "NetworkInsight 
xTyAGJmZ8nU8yJDP7LnA8Q==";

    @ClassRule
    public static final ResourceTestRule resources = ResourceTestRule.builder()
            .addResource(new ApiInfoController())
            .addProvider(apiFilter).build();

    @Test
    public void testApiVersion() throws Exception {
        Response response = resources.client()
                .target(ApiConstants.INFO_BASE_URL + "/version")
                .request()
                .header("Authorization", authToken)
                .buildGet().invoke();
        
        Assert.assertNotNull(response);
        Assert.assertEquals(response.toString(), 
Response.Status.OK.getStatusCode(), response.getStatus());
        final VersionResponse actualError = 
response.readEntity(VersionResponse.class);
        Assert.assertEquals(actualError.getApiVersion(), 
ApiConstants.API_VERSION);
    }
}


My main application is working fine. The configuration.yaml for main 
application looks like below


# Change default server ports
server:
  applicationConnectors:
  - type: http
    port: 8123
  adminConnectors:
  - type: http
    port: 8124
  requestLog:
    type: external
logging:
  type: external


Can someone let me know how can I get around this?


-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to