GERONIMO-6745 ensure accumulate logic works in jsonbconfig

git-svn-id: https://svn.apache.org/repos/asf/geronimo/specs/trunk@1864876 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-jsonb_1.0_spec/pom.xml b/geronimo-jsonb_1.0_spec/pom.xml
index 69745af..c77d779 100644
--- a/geronimo-jsonb_1.0_spec/pom.xml
+++ b/geronimo-jsonb_1.0_spec/pom.xml
@@ -73,9 +73,16 @@
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-json_1.1_spec</artifactId>
-            <version>1.2-SNAPSHOT</version>
+            <version>1.2</version>
             <scope>provided</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <version>5.5.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -133,6 +140,11 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>3.0.0-M3</version>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbConfig.java b/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbConfig.java
index 2545961..90bc630 100644
--- a/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbConfig.java
+++ b/geronimo-jsonb_1.0_spec/src/main/java/javax/json/bind/JsonbConfig.java
@@ -126,7 +126,7 @@
             final T[] existing = (T[]) opt.get();
             final T[] aggregated = (T[]) Array.newInstance(componentType, existing.length + values.length);
             System.arraycopy(existing, 0, aggregated, 0, existing.length);
-            System.arraycopy(values, 0, aggregated, existing.length + 1, values.length);
+            System.arraycopy(values, 0, aggregated, existing.length, values.length);
             return setProperty(key, aggregated);
         }
         return setProperty(key, values);
diff --git a/geronimo-jsonb_1.0_spec/src/test/java/org/apache/geronimo/specs/jsonb/JsonbConfigTest.java b/geronimo-jsonb_1.0_spec/src/test/java/org/apache/geronimo/specs/jsonb/JsonbConfigTest.java
new file mode 100644
index 0000000..8cb24a3
--- /dev/null
+++ b/geronimo-jsonb_1.0_spec/src/test/java/org/apache/geronimo/specs/jsonb/JsonbConfigTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.geronimo.specs.jsonb;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import javax.json.bind.JsonbConfig;
+import javax.json.bind.adapter.JsonbAdapter;
+
+import org.junit.jupiter.api.Test;
+
+class JsonbConfigTest {
+    @Test
+    void accumulate() {
+        final JsonbConfig jsonbConfig = new JsonbConfig()
+                .withAdapters(new PassthroughIntegerAdapter())
+                .withAdapters(new PassthroughStringAdapter());
+
+        final Object adapters = jsonbConfig.getProperty(JsonbConfig.ADAPTERS).orElseThrow(AssertionError::new);
+        assertTrue(JsonbAdapter[].class.isAssignableFrom(adapters.getClass()));
+        assertEquals(2, JsonbAdapter[].class.cast(adapters).length);
+    }
+
+    public static class PassthroughStringAdapter implements JsonbAdapter<String, String> {
+        @Override
+        public String adaptToJson(final String obj) {
+            return obj;
+        }
+
+        @Override
+        public String adaptFromJson(final String obj) {
+            return obj;
+        }
+    }
+
+    public static class PassthroughIntegerAdapter implements JsonbAdapter<Integer, Integer> {
+        @Override
+        public Integer adaptToJson(final Integer obj) {
+            return obj;
+        }
+
+        @Override
+        public Integer adaptFromJson(final Integer obj) {
+            return obj;
+        }
+    }
+}