[jackson-jaxrs-providers] 30/162: trying to add integration tests

Timo Aaltonen tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-jaxrs-providers.

commit f90a0af791b4f7dfd700f56588e25e67eb592c1a
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date:   Wed Mar 27 09:06:20 2013 -0700

    trying to add integration tests
---
 json/pom.xml                                       |  9 +++-
 .../fasterxml/jackson/jaxrs/json/TestJsonView.java |  2 +-
 .../jackson/jaxrs/json/dw/TestService.java         | 56 ++++++++++++++++++++++
 .../jackson/jaxrs/json/dw/TestServiceConfig.java   | 10 ++++
 .../jackson/jaxrs/json/dw/TestSimpleEndpoint.java  | 39 +++++++++++++++
 5 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/json/pom.xml b/json/pom.xml
index 48ef2de..b5d9d0e 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -76,7 +76,14 @@
       <version>${version.jackson.jaxb}</version>
     </dependency>
 
-    <!-- test deps should come from parent -->
+    <!-- test deps should come from parent. Except for DW -->
+    <dependency>
+        <groupId>com.yammer.dropwizard</groupId>
+        <artifactId>dropwizard-core</artifactId>
+        <version>0.6.2</version>
+        <scope>test</scope>
+    </dependency>
+
   </dependencies>
   <build>
     <plugins>
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java
index 1567351..c5c0d16 100644
--- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonView.java
@@ -23,7 +23,7 @@ public class TestJsonView extends JaxrsTestBase
 
     @JsonView({ MyView1.class })
     public void bogus() { }
-    
+
     /*
     /**********************************************************
     /* Test methods
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestService.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestService.java
new file mode 100644
index 0000000..e52c383
--- /dev/null
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestService.java
@@ -0,0 +1,56 @@
+package com.fasterxml.jackson.jaxrs.json.dw;
+
+import org.eclipse.jetty.server.Server;
+
+import com.yammer.dropwizard.Service;
+import com.yammer.dropwizard.config.Bootstrap;
+import com.yammer.dropwizard.config.Environment;
+import com.yammer.dropwizard.config.ServerFactory;
+import com.yammer.dropwizard.json.ObjectMapperFactory;
+import com.yammer.dropwizard.validation.Validator;
+
+public class TestService extends Service<TestServiceConfig>
+{
+    protected final static ObjectMapperFactory MAPPER_FACTORY = new ObjectMapperFactory();
+    
+    protected Server _jettyServer;
+
+    protected TestService() { }
+
+    public static TestService create(TestServiceConfig config,
+            Object... resources)
+        throws Exception
+    {
+        TestService service = new TestService();
+        Bootstrap<TestServiceConfig> bootstrap = new Bootstrap<TestServiceConfig>(service);
+        final Environment environment = new Environment("TestService", config,
+                MAPPER_FACTORY, new Validator());
+        for (Object resource : resources) {
+            environment.addResource(resource);
+        }
+        bootstrap.runWithBundles(config, environment);
+        service.run(config, environment);
+        final Server server = new ServerFactory(config.getHttpConfiguration(),
+                "StoreForTests").buildServer(environment);
+        service._jettyServer = server;
+        return service;
+    }
+
+    public void start() throws Exception {
+        _jettyServer.start();
+    }
+
+    public void stop() throws Exception {
+        _jettyServer.stop();
+    }
+    
+    @Override
+    public void initialize(Bootstrap<TestServiceConfig> bootstrap) {
+    }
+
+    @Override
+    public void run(TestServiceConfig configuration, Environment environment)
+            throws Exception
+    {
+    }
+}
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestServiceConfig.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestServiceConfig.java
new file mode 100644
index 0000000..8fe5e5e
--- /dev/null
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestServiceConfig.java
@@ -0,0 +1,10 @@
+package com.fasterxml.jackson.jaxrs.json.dw;
+
+import com.yammer.dropwizard.config.Configuration;
+
+public class TestServiceConfig extends Configuration
+{
+    public TestServiceConfig(int port) {
+        this.getHttpConfiguration().setPort(port);
+    }
+}
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java
new file mode 100644
index 0000000..ce8bc2f
--- /dev/null
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/dw/TestSimpleEndpoint.java
@@ -0,0 +1,39 @@
+package com.fasterxml.jackson.jaxrs.json.dw;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import com.fasterxml.jackson.jaxrs.json.JaxrsTestBase;
+
+public class TestSimpleEndpoint extends JaxrsTestBase
+{
+    static class Point {
+        public int x, y;
+    }
+    
+    static class SimpleResource {
+        @Path("/point")
+        @GET
+        @Produces(MediaType.APPLICATION_JSON)
+        public Point getPoint() {
+            return new Point();
+        }
+    }
+    
+    /*
+    /**********************************************************
+    /* Test methods
+    /**********************************************************
+     */
+    
+    public void testStandardJson() throws Exception
+    {
+        TestServiceConfig config = new TestServiceConfig(9090);
+        TestService svc = TestService.create(config, new SimpleResource());
+        svc.start();
+        svc.stop();
+    }
+
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git



More information about the pkg-java-commits mailing list