camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r824325 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/converter/jaxp/ test/java/org/apache/camel/converter/jaxp/
Date Mon, 12 Oct 2009 13:09:41 GMT
Author: davsclaus
Date: Mon Oct 12 13:09:40 2009
New Revision: 824325

URL: http://svn.apache.org/viewvc?rev=824325&view=rev
Log:
MR-187: Added more unit tests.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
  (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/BytesSource.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StreamSourceConverter.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/BytesSource.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/BytesSource.java?rev=824325&r1=824324&r2=824325&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/BytesSource.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/BytesSource.java
Mon Oct 12 13:09:40 2009
@@ -32,10 +32,7 @@
  * @version $Revision$
  */
 public class BytesSource extends StreamSource implements Serializable {
-    private byte[] data;
-
-    public BytesSource() {
-    }
+    private final byte[] data;
 
     public BytesSource(byte[] data) {
         ObjectHelper.notNull(data, "data");

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StreamSourceConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StreamSourceConverter.java?rev=824325&r1=824324&r2=824325&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StreamSourceConverter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/converter/jaxp/StreamSourceConverter.java
Mon Oct 12 13:09:40 2009
@@ -28,15 +28,18 @@
  * @version $Revision$
  */
 @Converter
-public class StreamSourceConverter {
+public final class StreamSourceConverter {
+
+    private StreamSourceConverter() {
+    }
 
     @Converter
-    public InputStream toInputStream(StreamSource source) {
+    public static InputStream toInputStream(StreamSource source) {
         return source.getInputStream();
     }
 
     @Converter
-    public Reader toReader(StreamSource source) {
+    public static Reader toReader(StreamSource source) {
         return source.getReader();
     }
 }
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java?rev=824325&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
Mon Oct 12 13:09:40 2009
@@ -0,0 +1,45 @@
+/**
+ * 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.camel.converter.jaxp;
+
+import org.apache.camel.ContextTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class BytesSourceTest extends ContextTestSupport {
+
+    public void testBytesSourceCtr() {
+        BytesSource bs = new BytesSource("foo".getBytes());
+        assertNotNull(bs.getData());
+        assertEquals("BytesSource[foo]", bs.toString());
+        assertNull(bs.getSystemId());
+
+        assertNotNull(bs.getInputStream());
+        assertNotNull(bs.getReader());
+    }
+
+    public void testBytesSourceCtrSystemId() {
+        BytesSource bs = new BytesSource("foo".getBytes(), "Camel");
+        assertNotNull(bs.getData());
+        assertEquals("BytesSource[foo]", bs.toString());
+        assertEquals("Camel", bs.getSystemId());
+
+        assertNotNull(bs.getInputStream());
+        assertNotNull(bs.getReader());
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/BytesSourceTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java?rev=824325&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
Mon Oct 12 13:09:40 2009
@@ -0,0 +1,45 @@
+/**
+ * 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.camel.converter.jaxp;
+
+import java.io.InputStream;
+import java.io.Reader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.camel.ContextTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class StreamSourceConverterTest extends ContextTestSupport {
+
+    public void testToInputStream() throws Exception {
+        StreamSource source = context.getTypeConverter().convertTo(StreamSource.class, "<foo>bar</foo>");
+
+        InputStream out = StreamSourceConverter.toInputStream(source);
+        assertNotNull(out);
+        assertEquals("<foo>bar</foo>", context.getTypeConverter().convertTo(String.class,
out));
+    }
+
+    public void testToReader() throws Exception {
+        StreamSource source = context.getTypeConverter().convertTo(StreamSource.class, "<foo>bar</foo>");
+
+        Reader out = StreamSourceConverter.toReader(source);
+        assertNotNull(out);
+        assertEquals("<foo>bar</foo>", context.getTypeConverter().convertTo(String.class,
out));
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/converter/jaxp/StreamSourceConverterTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message