You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/08/28 16:33:54 UTC

[2/3] syncope git commit: Integration tests working with Glassfish via jaxrsContentType=application/xml - see SYNCOPE-688

Integration tests working with Glassfish via jaxrsContentType=application/xml - see SYNCOPE-688


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/716e2ed6
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/716e2ed6
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/716e2ed6

Branch: refs/heads/master
Commit: 716e2ed6a0614cf4b9e1882a80b7bb2496b83343
Parents: 8338f8f
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Aug 28 13:15:48 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Aug 28 13:15:48 2015 +0200

----------------------------------------------------------------------
 .../serialization/UnwrappedObjectMapper.java    | 93 --------------------
 .../core/rest/cxf/UnwrappedObjectMapper.java    | 85 ++++++++++++++++++
 .../src/main/resources/restCXFContext.xml       |  2 +-
 fit/core-reference/pom.xml                      |  5 ++
 .../fit/core/reference/DomainITCase.java        |  6 +-
 5 files changed, 95 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/716e2ed6/core/misc/src/main/java/org/apache/syncope/core/misc/serialization/UnwrappedObjectMapper.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/serialization/UnwrappedObjectMapper.java b/core/misc/src/main/java/org/apache/syncope/core/misc/serialization/UnwrappedObjectMapper.java
deleted file mode 100644
index 61770e0..0000000
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/serialization/UnwrappedObjectMapper.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.syncope.core.misc.serialization;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Map;
-
-/**
- * Jackson ObjectMapper that unwraps singleton map values and enable default
- * typing for handling abstract types serialization.
- */
-public class UnwrappedObjectMapper extends ObjectMapper {
-
-    private static final long serialVersionUID = -317191546835195103L;
-
-    /**
-     * Unwraps the given value if it implements the Map interface and contains
-     * only a single entry. Otherwise the value is returned unmodified.
-     *
-     * @param value the potential Map to unwrap
-     * @return the unwrapped map or the original value
-     */
-    private Object unwrapMap(final Object value) {
-        if (value instanceof Map) {
-            Map<?, ?> map = (Map<?, ?>) value;
-            if (map.size() == 1) {
-                return map.values().iterator().next();
-            }
-        }
-
-        return value;
-    }
-
-    @Override
-    public void writeValue(final JsonGenerator jgen, final Object value)
-            throws IOException {
-
-        super.writeValue(jgen, unwrapMap(value));
-    }
-
-    @Override
-    public void writeValue(final File resultFile, final Object value)
-            throws IOException {
-
-        super.writeValue(resultFile, unwrapMap(value));
-    }
-
-    @Override
-    public void writeValue(final OutputStream out, final Object value)
-            throws IOException {
-
-        super.writeValue(out, unwrapMap(value));
-    }
-
-    @Override
-    public void writeValue(final Writer w, final Object value)
-            throws IOException {
-
-        super.writeValue(w, unwrapMap(value));
-    }
-
-    @Override
-    public byte[] writeValueAsBytes(final Object value) throws JsonProcessingException {
-        return super.writeValueAsBytes(unwrapMap(value));
-    }
-
-    @Override
-    public String writeValueAsString(final Object value) throws JsonProcessingException {
-        return super.writeValueAsString(unwrapMap(value));
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/716e2ed6/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/UnwrappedObjectMapper.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/UnwrappedObjectMapper.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/UnwrappedObjectMapper.java
new file mode 100644
index 0000000..661f3b0
--- /dev/null
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/UnwrappedObjectMapper.java
@@ -0,0 +1,85 @@
+/*
+ * 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.syncope.core.rest.cxf;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * Jackson ObjectMapper that unwraps singleton map values and enable default
+ * typing for handling abstract types serialization.
+ */
+public class UnwrappedObjectMapper extends ObjectMapper {
+
+    private static final long serialVersionUID = -317191546835195103L;
+
+    /**
+     * Unwraps the given value if it implements the Map interface and contains only a single entry, otherwise the
+     * value is returned unmodified.
+     *
+     * @param value the potential Map to unwrap
+     * @return the unwrapped map or the original value
+     */
+    private Object unwrapMap(final Object value) {
+        if (value instanceof Map) {
+            Map<?, ?> map = (Map<?, ?>) value;
+            if (map.size() == 1) {
+                return map.values().iterator().next();
+            }
+        }
+
+        return value;
+    }
+
+    @Override
+    public void writeValue(final JsonGenerator jgen, final Object value) throws IOException {
+        super.writeValue(jgen, unwrapMap(value));
+    }
+
+    @Override
+    public void writeValue(final File resultFile, final Object value) throws IOException {
+        super.writeValue(resultFile, unwrapMap(value));
+    }
+
+    @Override
+    public void writeValue(final OutputStream out, final Object value) throws IOException {
+        super.writeValue(out, unwrapMap(value));
+    }
+
+    @Override
+    public void writeValue(final Writer writer, final Object value) throws IOException {
+        super.writeValue(writer, unwrapMap(value));
+    }
+
+    @Override
+    public byte[] writeValueAsBytes(final Object value) throws JsonProcessingException {
+        return super.writeValueAsBytes(unwrapMap(value));
+    }
+
+    @Override
+    public String writeValueAsString(final Object value) throws JsonProcessingException {
+        return super.writeValueAsString(unwrapMap(value));
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/716e2ed6/core/rest-cxf/src/main/resources/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/resources/restCXFContext.xml b/core/rest-cxf/src/main/resources/restCXFContext.xml
index 5155724..b5b75db 100644
--- a/core/rest-cxf/src/main/resources/restCXFContext.xml
+++ b/core/rest-cxf/src/main/resources/restCXFContext.xml
@@ -61,7 +61,7 @@ under the License.
     </property>
   </bean>
 
-  <bean id="jacksonObjectMapper" class="org.apache.syncope.core.misc.serialization.UnwrappedObjectMapper"/>
+  <bean id="jacksonObjectMapper" class="org.apache.syncope.core.rest.cxf.UnwrappedObjectMapper"/>
   <bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
     <property name="mapper" ref="jacksonObjectMapper"/>
   </bean>

http://git-wip-us.apache.org/repos/asf/syncope/blob/716e2ed6/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index 1339153..2e65089 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -518,6 +518,11 @@ under the License.
     <profile>
       <id>glassfish-it</id>
 
+      <properties>
+        <!-- see SYNCOPE-688 -->
+        <jaxrs.content.type>application/xml</jaxrs.content.type>
+      </properties>
+      
       <dependencies>
         <dependency>
           <groupId>com.h2database</groupId>

http://git-wip-us.apache.org/repos/asf/syncope/blob/716e2ed6/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
index 51d4aaf..728379a 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
@@ -83,14 +83,16 @@ public class DomainITCase extends AbstractITCase {
 
             // 2. attempt to access with old pwd -> fail
             try {
-                new SyncopeClientFactoryBean().setAddress(ADDRESS).setDomain("Two").
+                new SyncopeClientFactoryBean().
+                        setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).
                         create(ADMIN_UNAME, "password2").self();
             } catch (AccessControlException e) {
                 assertNotNull(e);
             }
 
             // 3. access with new pwd -> succeed
-            new SyncopeClientFactoryBean().setAddress(ADDRESS).setDomain("Two").
+            new SyncopeClientFactoryBean().
+                    setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).
                     create(ADMIN_UNAME, "password3").self();
         } finally {
             restoreTwo();