abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r710193 - in /incubator/abdera/java/trunk/extensions/json/src: main/java/org/apache/abdera/ext/json/ test/java/org/ test/java/org/apache/ test/java/org/apache/abdera/ test/java/org/apache/abdera/ext/ test/java/org/apache/abdera/ext/json/
Date Mon, 03 Nov 2008 22:28:32 GMT
Author: calavera
Date: Mon Nov  3 14:28:31 2008
New Revision: 710193

URL: http://svn.apache.org/viewvc?rev=710193&view=rev
Log:
[ABDERA-205]: JSONStream throws a npe when the content element is empty

I've added a simple test

Added:
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/JSONStreamTest.java
    incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/TestSuite.java
Modified:
    incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONStream.java

Modified: incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONStream.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONStream.java?rev=710193&r1=710192&r2=710193&view=diff
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONStream.java
(original)
+++ incubator/abdera/java/trunk/extensions/json/src/main/java/org/apache/abdera/ext/json/JSONStream.java
Mon Nov  3 14:28:31 2008
@@ -112,10 +112,12 @@
   }
   
   public void writeQuoted(String value) throws IOException {
-    writer.write('"');
-    writer.write(escape(value));
-    writer.write('"');
-    writer.flush();
+      if (value != null) {
+        writer.write('"');
+        writer.write(escape(value));
+        writer.write('"');
+        writer.flush();
+      }
   }
 
   public void writeField(String name) throws IOException {

Added: incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/JSONStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/JSONStreamTest.java?rev=710193&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/JSONStreamTest.java
(added)
+++ incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/JSONStreamTest.java
Mon Nov  3 14:28:31 2008
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.json;
+
+
+import org.apache.abdera.ext.json.JSONStream;
+import org.apache.abdera.Abdera;
+import org.apache.abdera.writer.Writer;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Entry;
+import org.junit.Test;
+import org.junit.Assert;
+import junit.framework.TestCase;
+
+
+/**
+ * JSONStreamTest
+ *
+ * @author David Calavera
+ * @since 11/01/08
+ */
+public class JSONStreamTest extends TestCase {
+
+	@Test
+	public void testJSONStreamContent() throws Exception {
+	    Abdera abdera = new Abdera();
+        Entry entry = abdera.newEntry();
+
+        entry.setContent(new IRI("http://example.org/xml"), "text/xml");
+
+        Writer json = abdera.getWriterFactory().getWriter("json");
+        entry.writeTo(json, System.out);
+    }
+}
\ No newline at end of file

Added: incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/TestSuite.java?rev=710193&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/TestSuite.java
(added)
+++ incubator/abdera/java/trunk/extensions/json/src/test/java/org/apache/abdera/ext/json/TestSuite.java
Mon Nov  3 14:28:31 2008
@@ -0,0 +1,29 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.ext.json;
+
+import org.junit.internal.runners.TextListener;
+import org.junit.runner.JUnitCore;
+
+public class TestSuite  {
+  public static void main(String[] args) {
+    JUnitCore runner = new JUnitCore();
+    runner.addListener(new TextListener(System.out));
+    runner.run(JSONStreamTest.class);
+  }
+}
\ No newline at end of file



Mime
View raw message