Author: davsclaus
Date: Fri Jun  6 02:24:45 2008
New Revision: 663868

URL: http://svn.apache.org/viewvc?rev=663868&view=rev
Log:
CAMEL-583: Improved unit test by adding assertions. JAXB conversion of 
MessageType is failing.

Added:
    
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
   (with props)
Modified:
    activemq/camel/trunk/components/camel-jaxb/src/test/data/bar.xml
    activemq/camel/trunk/components/camel-jaxb/src/test/data/foo.xml
    
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
    
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
    
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
    
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java

Modified: activemq/camel/trunk/components/camel-jaxb/src/test/data/bar.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/data/bar.xml?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/data/bar.xml (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/data/bar.xml Fri Jun  6 
02:24:45 2008
@@ -15,4 +15,6 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<hello>bar</hello>
+<message>
+    <hello>bar</hello>
+</message>

Modified: activemq/camel/trunk/components/camel-jaxb/src/test/data/foo.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/data/foo.xml?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/data/foo.xml (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/data/foo.xml Fri Jun  6 
02:24:45 2008
@@ -15,4 +15,6 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<hello>foo</hello>
+<message>
+    <hello>foo</hello>
+</message>

Modified: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
 Fri Jun  6 02:24:45 2008
@@ -34,24 +34,27 @@
 
         assertNotNull("Should have created a valid message Type");
 
-        log.info("headers: " + messageType.getHeaderMap());
-        log.info("body: " + messageType.getBody());
-
-        dump(messageType);
+        assertEquals("abc", messageType.getHeaderMap().get("foo"));
+        assertEquals(123, messageType.getHeaderMap().get("bar"));
+        assertEquals("<hello id='m123'>world!</hello>", messageType.getBody());
+        marshalMessage(messageType);
     }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         jaxbContext = 
JAXBContext.newInstance("org.apache.camel.converter.jaxb");
     }
 
-    protected void dump(Object object) throws Exception {
+    protected void marshalMessage(Object object) throws Exception {
         Marshaller marshaller = jaxbContext.createMarshaller();
         marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
         StringWriter buffer = new StringWriter();
         marshaller.marshal(object, buffer);
-        log.info("Created: " + buffer);
+        String out = buffer.toString();
+        assertTrue("Should be XML", out.startsWith("<?xml version=\"1.0\" 
encoding=\"UTF-8\" standalone=\"yes\"?>"));
+        assertTrue("Should containt string header", out.indexOf("<header 
value=\"abc\" name=\"foo\"/>") > -1);
+        assertTrue("Should containt int header", out.indexOf("<intHeader 
value=\"123\" name=\"bar\"/>") > -1);
+        assertTrue("Should containt the body", out.indexOf("&lt;hello 
id='m123'&gt;world!&lt;/hello&gt;") > -1);
     }
 }

Modified: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
 Fri Jun  6 02:24:45 2008
@@ -21,24 +21,18 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Revision$
  */
 public class JAXBConvertTest extends TestCase {
-    private static final transient Log LOG = 
LogFactory.getLog(JAXBConvertTest.class);
-    
     protected CamelContext context = new DefaultCamelContext();
     protected TypeConverter converter = context.getTypeConverter();
 
     public void testConverter() throws Exception {
         PurchaseOrder purchaseOrder = converter.convertTo(PurchaseOrder.class, 
"<purchaseOrder name='foo' amount='123.45' price='2.22'/>");
 
-        LOG.info("Parsed: " + purchaseOrder);
         assertNotNull("Purchase order should not be null!", purchaseOrder);
-
         assertEquals("name", "foo", purchaseOrder.getName());
         assertEquals("amount", 123.45, purchaseOrder.getAmount());
     }

Added: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java?rev=663868&view=auto
==============================================================================
--- 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
 (added)
+++ 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
 Fri Jun  6 02:24:45 2008
@@ -0,0 +1,43 @@
+/**
+ * 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.example;
+
+import junit.framework.TestCase;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.converter.jaxb.MessageType;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * Unit test for JABX conversion of MessageType
+ */
+public class JAXBConverterMessageTypeTest extends TestCase {
+    protected CamelContext context = new DefaultCamelContext();
+    protected TypeConverter converter = context.getTypeConverter();
+
+    public void testConverter() throws Exception {
+        // TODO: fails see CAMEL-583
+        /*
+        MessageType message = converter.convertTo(MessageType.class, 
"<message><hello>bar</hello></message>");
+        System.out.println(message);
+
+        assertNotNull("Message should not be null!", message);
+        */
+    }
+
+}

Propchange: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
 Fri Jun  6 02:24:45 2008
@@ -41,11 +41,9 @@
         resultEndpoint.assertIsSatisfied();
     }
 
-
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-
                 DataFormat jaxb = new 
JaxbDataFormat("org.apache.camel.example");
 
                 from("direct:start").

Modified: 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java?rev=663868&r1=663867&r2=663868&view=diff
==============================================================================
--- 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
 (original)
+++ 
activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
 Fri Jun  6 02:24:45 2008
@@ -25,6 +25,7 @@
  */
 public class DumpToXmlTest extends ContextTestSupport {
     public void testDumplFilesToJaxb() throws Exception {
+        // TODO: Needs assertions, fails see CAMEL-583
         Thread.sleep(5000);
     }
 


Reply via email to