openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1862127 - in /openwebbeans/meecrowave/trunk: ./ meecrowave-core/src/test/java/org/apache/meecrowave/ meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/ meecrowave-core/src/test/java/org/superbiz/app/
Date Wed, 26 Jun 2019 11:42:55 GMT
Author: struberg
Date: Wed Jun 26 11:42:55 2019
New Revision: 1862127

URL: http://svn.apache.org/viewvc?rev=1862127&view=rev
Log:
MEECROWAVE-200 test for johnzon buffer handling

Added:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java
  (with props)
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
  (with props)
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java
  (with props)
Modified:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/MeecrowaveTest.java
    openwebbeans/meecrowave/trunk/pom.xml

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/MeecrowaveTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/MeecrowaveTest.java?rev=1862127&r1=1862126&r2=1862127&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/MeecrowaveTest.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/MeecrowaveTest.java
Wed Jun 26 11:42:55 2019
@@ -26,6 +26,7 @@ import org.superbiz.app.Bounced;
 import org.superbiz.app.Endpoint;
 import org.superbiz.app.InterfaceApi;
 import org.superbiz.app.RsApp;
+import org.superbiz.app.TestJsonEndpoint;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -118,7 +119,7 @@ public class MeecrowaveTest {
             assertEquals("simplefalse", slurp(new URL("http://localhost:" + meecrowave.getConfiguration().getHttpPort()
+ "/api/test")));
             assertEquals("simplefiltertrue", slurp(new URL("http://localhost:" + meecrowave.getConfiguration().getHttpPort()
+ "/filter")));
             assertEquals(
-                    "sci:" + Bounced.class.getName() + Endpoint.class.getName() + InterfaceApi.class.getName()
+ RsApp.class.getName(),
+                    "sci:" + Bounced.class.getName() + Endpoint.class.getName() + InterfaceApi.class.getName()
+ RsApp.class.getName() + TestJsonEndpoint.class.getName(),
                     slurp(new URL("http://localhost:" + meecrowave.getConfiguration().getHttpPort()
+ "/sci")));
         } catch (final IOException e) {
             fail(e.getMessage());

Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java?rev=1862127&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java
(added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java
Wed Jun 26 11:42:55 2019
@@ -0,0 +1,31 @@
+package org.apache.meecrowave.johnzon;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.johnzon.core.BufferStrategy;
+import org.apache.johnzon.core.BufferStrategyFactory;
+
+public class DebugJohnzonBufferStrategy implements BufferStrategy {
+
+    private static AtomicInteger counter = new AtomicInteger(0);
+    private BufferStrategy delegate;
+
+    public DebugJohnzonBufferStrategy() {
+        counter.incrementAndGet();
+        delegate = BufferStrategyFactory.valueOf("BY_INSTANCE");
+    }
+
+
+    public static int getCounter() {
+        return counter.get();
+    }
+
+    public static void resetCounter() {
+        counter.set(0);
+    }
+
+    @Override
+    public BufferProvider<char[]> newCharProvider(int size) {
+        return delegate.newCharProvider(size);
+    }
+}

Propchange: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/DebugJohnzonBufferStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java?rev=1862127&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
(added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
Wed Jun 26 11:42:55 2019
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.meecrowave.johnzon;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.meecrowave.Meecrowave;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class JohnzonBufferTest {
+    @Test
+    public void test() {
+        DebugJohnzonBufferStrategy.resetCounter();
+        try (final Meecrowave meecrowave = new Meecrowave(new Meecrowave.Builder()
+                .randomHttpPort()
+                .withJsonpBufferStrategy(DebugJohnzonBufferStrategy.class.getName())
+                .includePackages("org.superbiz.app.TestJsonEndpoint")).bake()) {
+            final Client client = ClientBuilder.newClient();
+            try {
+                String jsonResponse = client
+                        .target("http://localhost:" + meecrowave.getConfiguration().getHttpPort()
+ "/testjsonendpoint/book")
+                        .request(MediaType.APPLICATION_JSON)
+                        .get(String.class);
+                assertEquals("{\"isbn\":\"dummyisbn\"}", jsonResponse);
+                //X TODO work in progress! assertEquals(1, DebugJohnzonBufferStrategy.getCounter());
+            } finally {
+                client.close();
+            }
+        }
+    }
+}

Propchange: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java?rev=1862127&view=auto
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java
(added)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java
Wed Jun 26 11:42:55 2019
@@ -0,0 +1,37 @@
+package org.superbiz.app;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@ApplicationScoped
+@Path("/testjsonendpoint")
+public class TestJsonEndpoint {
+
+
+    @GET
+    @Path("book")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Book getBook() {
+        return new Book("dummyisbn");
+    }
+
+
+    public static class Book {
+        private String isbn;
+
+        public Book(String isbn) {
+            this.isbn = isbn;
+        }
+
+        public String getIsbn() {
+            return isbn;
+        }
+
+        public void setIsbn(String isbn) {
+            this.isbn = isbn;
+        }
+    }
+}

Propchange: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/superbiz/app/TestJsonEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/meecrowave/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/pom.xml?rev=1862127&r1=1862126&r2=1862127&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/pom.xml (original)
+++ openwebbeans/meecrowave/trunk/pom.xml Wed Jun 26 11:42:55 2019
@@ -53,7 +53,7 @@
     <tomcat.version>9.0.21</tomcat.version>
     <openwebbeans.version>2.0.11</openwebbeans.version>
     <cxf.version>3.3.2</cxf.version>
-    <johnzon.version>1.1.12</johnzon.version>
+    <johnzon.version>1.1.13-SNAPSHOT</johnzon.version>
     <log4j2.version>2.11.2</log4j2.version>
     <deltaspike.version>1.8.2</deltaspike.version>
     <jaxb.version>2.2.11</jaxb.version>



Mime
View raw message