cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1350303 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/ext/form/Form.java test/java/org/apache/cxf/jaxrs/ext/form/ test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
Date Thu, 14 Jun 2012 15:50:09 GMT
Author: sergeyb
Date: Thu Jun 14 15:50:09 2012
New Revision: 1350303

URL: http://svn.apache.org/viewvc?rev=1350303&view=rev
Log:
Minor update to Form to override toString

Added:
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java?rev=1350303&r1=1350302&r2=1350303&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/form/Form.java Thu
Jun 14 15:50:09 2012
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.jaxrs.ext.form;
 
+import java.io.ByteArrayOutputStream;
+
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
@@ -50,4 +52,14 @@ public class Form {
         return map;
     }
     
+    public String toString() {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            FormUtils.writeMapToOutputStream(map, bos, "UTF-8", false);
+            return bos.toString("UTF-8");
+        } catch (Exception ex) {
+            // will not happen
+        }
+        return "";
+    }
 }

Added: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java?rev=1350303&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
Thu Jun 14 15:50:09 2012
@@ -0,0 +1,32 @@
+/**
+ * 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.cxf.jaxrs.ext.form;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FormTest extends Assert {
+
+    @Test
+    public void testToString() {
+        Form form = new Form().set("a", "b").set("c", "d");
+        assertEquals("a=b&c=d", form.toString());
+    }
+
+}

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/form/FormTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message