camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r896302 - in /camel/trunk/components: camel-jaxb/ camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/ camel-jaxb/src/test/java/org/apache/camel/example/ camel-jaxb/src/test/java/org/apache/camel/jaxb/ camel-test/src/main/java/org/apac...
Date Wed, 06 Jan 2010 01:45:53 GMT
Author: ningjiang
Date: Wed Jan  6 01:45:52 2010
New Revision: 896302

URL: http://svn.apache.org/viewvc?rev=896302&view=rev
Log:
Moved camel-jaxb test to use camel-test and JUnit4

Added:
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
  (with props)
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
  (with props)
Modified:
    camel/trunk/components/camel-jaxb/pom.xml
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbConverterTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatDataSetTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JaxbConcurrentDataFormatTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/RouteWithErrorHandlerTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatWithEncodingTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java

Modified: camel/trunk/components/camel-jaxb/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/pom.xml?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/pom.xml (original)
+++ camel/trunk/components/camel-jaxb/pom.xml Wed Jan  6 01:45:52 2010
@@ -75,14 +75,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
-            <type>test-jar</type>
+            <artifactId>camel-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbConverterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbConverterTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbConverterTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbConverterTest.java
Wed Jan  6 01:45:52 2010
@@ -25,15 +25,18 @@
 import org.w3c.dom.Document;
 
 import org.apache.camel.CamelException;
-import org.apache.camel.ExchangeTestSupport;
 import org.apache.camel.example.PurchaseOrder;
+import org.apache.camel.test.junit4.ExchangeTestSupport;
+import org.junit.Before;
+import org.junit.Test;
 
 public class JaxbConverterTest  extends ExchangeTestSupport {
     private JaxbConverter jaxbConverter;
     private PurchaseOrder order;
         
     @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         super.setUp();
         jaxbConverter = new JaxbConverter();
         order = new PurchaseOrder();
@@ -42,6 +45,7 @@
         order.setPrice(2.4);
     }
     
+    @Test
     public void testToSourceUsingExplicitJaxbConverter() throws JAXBException {        
         JAXBSource source = jaxbConverter.toSource(order);
         assertNotNull("The result should be not be null", source);
@@ -49,6 +53,7 @@
         assertNull("The result should be null", source);
     }
     
+    @Test
     public void testToSourceUsingTypeConverter() {
         // this time the fall back converter will be use
         exchange.getIn().setBody(order);
@@ -59,6 +64,7 @@
         assertNull("The result should be null", source);
     }
 
+    @Test
     public void testToDocumentUsingExplicitJaxbConverter() throws JAXBException, ParserConfigurationException
{
         Document document = jaxbConverter.toDocument(order);
         assertNotNull("The result should be not be null", document);
@@ -66,6 +72,7 @@
         assertNull("The result should be null", document);
     }
     
+    @Test
     public void testToDocumentUsingTypeConverter() {
         // this time the fall back converter will be use
         exchange.getIn().setBody(order);

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
Wed Jan  6 01:45:52 2010
@@ -21,7 +21,10 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 
-import org.apache.camel.ExchangeTestSupport;
+import org.apache.camel.test.junit4.ExchangeTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
 
 /**
  * @version $Revision$
@@ -29,6 +32,7 @@
 public class MessageTypeTest extends ExchangeTestSupport {
     protected JAXBContext jaxbContext;
 
+    @Test
     public void testCamelToJaxbUsingExplicitJaxbConverter() throws Exception {
         MessageDefinition messageType = JaxbConverter.toMessageType(exchange);
 
@@ -41,7 +45,8 @@
     }
 
     @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         super.setUp();
         jaxbContext = JAXBContext.newInstance("org.apache.camel.converter.jaxb");
     }

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatConcurrentTest.java
Wed Jan  6 01:45:52 2010
@@ -19,19 +19,21 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class DataFormatConcurrentTest extends ContextTestSupport {
+public class DataFormatConcurrentTest extends CamelTestSupport {
 
     private int size = 2000;
 
+    @Test
     public void testSendConcurrent() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(size);

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatDataSetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatDataSetTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatDataSetTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatDataSetTest.java
Wed Jan  6 01:45:52 2010
@@ -18,17 +18,19 @@
 
 import javax.naming.Context;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.dataset.SimpleDataSet;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class DataFormatDataSetTest extends ContextTestSupport {
+public class DataFormatDataSetTest extends CamelTestSupport {
 
+    @Test
     public void testConcurrentMarshall() throws Exception {
         assertMockEndpointsSatisfied();
     }

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/DataFormatTest.java
Wed Jan  6 01:45:52 2010
@@ -16,26 +16,30 @@
  */
 package org.apache.camel.example;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.foo.bar.PersonType;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class DataFormatTest extends ContextTestSupport {
+public class DataFormatTest extends CamelTestSupport {
     
     private MockEndpoint resultEndpoint;
     
     @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         super.setUp();
         resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
     }
 
+    @Test
     public void testMarshalThenUnmarshalBean() throws Exception {
         
         PurchaseOrder bean = new PurchaseOrder();
@@ -50,6 +54,7 @@
         resultEndpoint.assertIsSatisfied();
     }
     
+    @Test
     public void testMarshalPrettyPrint() throws Exception {
         PersonType person = new PersonType();
         person.setFirstName("Willem");

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConvertTest.java
Wed Jan  6 01:45:52 2010
@@ -18,51 +18,56 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
+
 import javax.xml.bind.UnmarshalException;
 
-import junit.framework.TestCase;
 import org.apache.camel.CamelContext;
 import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.StreamCache;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class JAXBConvertTest extends TestCase {
+public class JAXBConvertTest extends Assert {
     protected CamelContext context = new DefaultCamelContext();
     protected TypeConverter converter = context.getTypeConverter();
 
+    @Test
     public void testConverter() throws Exception {
         PurchaseOrder purchaseOrder = converter.convertTo(PurchaseOrder.class, 
             "<purchaseOrder name='foo' amount='123.45' price='2.22'/>");
 
         assertNotNull("Purchase order should not be null!", purchaseOrder);
         assertEquals("name", "foo", purchaseOrder.getName());
-        assertEquals("amount", 123.45, purchaseOrder.getAmount());
-        assertEquals("price", 2.22, purchaseOrder.getPrice());
+        assertEquals("amount", 123.45, purchaseOrder.getAmount(), 0);
+        assertEquals("price", 2.22, purchaseOrder.getPrice(), 0);
     }
 
+    @Test
     public void testConverterTwice() throws Exception {
         PurchaseOrder purchaseOrder = converter.convertTo(PurchaseOrder.class,
             "<purchaseOrder name='foo' amount='123.45' price='2.22'/>");
 
         assertNotNull("Purchase order should not be null!", purchaseOrder);
         assertEquals("name", "foo", purchaseOrder.getName());
-        assertEquals("amount", 123.45, purchaseOrder.getAmount());
-        assertEquals("price", 2.22, purchaseOrder.getPrice());
+        assertEquals("amount", 123.45, purchaseOrder.getAmount(), 0);
+        assertEquals("price", 2.22, purchaseOrder.getPrice(), 0);
 
         PurchaseOrder purchaseOrder2 = converter.convertTo(PurchaseOrder.class,
             "<purchaseOrder name='bar' amount='5.12' price='3.33'/>");
 
         assertNotNull("Purchase order should not be null!", purchaseOrder2);
         assertEquals("name", "bar", purchaseOrder2.getName());
-        assertEquals("amount", 5.12, purchaseOrder2.getAmount());
-        assertEquals("amount", 3.33, purchaseOrder2.getPrice());
+        assertEquals("amount", 5.12, purchaseOrder2.getAmount(), 0);
+        assertEquals("amount", 3.33, purchaseOrder2.getPrice(), 0);
     }
 
+    @Test
     public void testStreamShouldBeClosed() throws Exception {
         String data = "<purchaseOrder name='foo' amount='123.45' price='2.22'/>";
         InputStream is = new ByteArrayInputStream(data.getBytes());
@@ -72,6 +77,7 @@
         assertEquals(-1, is.read());
     }
 
+    @Test
     public void testStreamShouldBeClosedEvenForException() throws Exception {
         String data = "<errorOrder name='foo' amount='123.45' price='2.22'/>";
         InputStream is = new ByteArrayInputStream(data.getBytes());
@@ -84,6 +90,7 @@
         assertEquals(-1, is.read());
     }
     
+    @Test
     public void testNoConversionForStreamCache() throws Exception {
         PurchaseOrder order = new PurchaseOrder();
         try {

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JAXBConverterMessageTypeTest.java
Wed Jan  6 01:45:52 2010
@@ -16,20 +16,21 @@
  */
 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.MessageDefinition;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
  * Unit test for JABX conversion of MessageType
  */
-public class JAXBConverterMessageTypeTest extends TestCase {
+public class JAXBConverterMessageTypeTest extends Assert {
     protected CamelContext context = new DefaultCamelContext();
     protected TypeConverter converter = context.getTypeConverter();
 
+    @Test
     public void testConverter() throws Exception {
         MessageDefinition message = converter.convertTo(MessageDefinition.class, "<message><hello>bar</hello></message>");
         assertNotNull("Message should not be null!", message);

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JaxbConcurrentDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JaxbConcurrentDataFormatTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JaxbConcurrentDataFormatTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/JaxbConcurrentDataFormatTest.java
Wed Jan  6 01:45:52 2010
@@ -20,20 +20,23 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class JaxbConcurrentDataFormatTest extends ContextTestSupport {
+public class JaxbConcurrentDataFormatTest extends CamelTestSupport {
 
+    @Test
     public void testNoConcurrentProducers() throws Exception {
         doSendMessages(1, 1);
     }
 
+    @Test
     public void testConcurrentProducers() throws Exception {
         doSendMessages(10, 5);
     }

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/RouteWithErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/RouteWithErrorHandlerTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/RouteWithErrorHandlerTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/RouteWithErrorHandlerTest.java
Wed Jan  6 01:45:52 2010
@@ -16,17 +16,19 @@
  */
 package org.apache.camel.example;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class RouteWithErrorHandlerTest extends ContextTestSupport {
+public class RouteWithErrorHandlerTest extends CamelTestSupport {
 
+    @Test
     public void testOk() throws Exception {
         PurchaseOrder order = new PurchaseOrder();
         order.setName("Wine");
@@ -41,6 +43,7 @@
         assertMockEndpointsSatisfied();
     }
 
+    @Test
     public void testUnmarshalError() throws Exception {
         MockEndpoint error = getMockEndpoint("mock:error");
         error.expectedBodiesReceived("<foo/>");
@@ -52,6 +55,7 @@
         assertMockEndpointsSatisfied();
     }
 
+    @Test
     public void testNotWine() throws Exception {
         PurchaseOrder order = new PurchaseOrder();
         order.setName("Beer");

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatTest.java
Wed Jan  6 01:45:52 2010
@@ -17,14 +17,17 @@
 package org.apache.camel.example;
 
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
+
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version $Revision$
  */
-public class SpringDataFormatTest extends SpringTestSupport {
+public class SpringDataFormatTest extends CamelSpringTestSupport {
+    @Test
     public void testMarshalThenUnmarshalBean() throws Exception {
         PurchaseOrder bean = new PurchaseOrder();
         bean.setName("Beer");

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatWithEncodingTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatWithEncodingTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatWithEncodingTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/SpringDataFormatWithEncodingTest.java
Wed Jan  6 01:45:52 2010
@@ -18,14 +18,16 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.spring.SpringTestSupport;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
  * @version $Revision$
  */
-public class SpringDataFormatWithEncodingTest extends SpringTestSupport {
+public class SpringDataFormatWithEncodingTest extends CamelSpringTestSupport {
 
+    @Test
     public void testMarshalWithEncoding() throws Exception {
         PurchaseOrder bean = new PurchaseOrder();
         bean.setName("Beer");
@@ -41,6 +43,7 @@
         mock.assertIsSatisfied();
     }
 
+    @Test
     public void testMarshalWithEncodingPropertyInExchange() throws Exception {
         PurchaseOrder bean = new PurchaseOrder();
         bean.setName("Beer");

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/UnmarshalTest.java
Wed Jan  6 01:45:52 2010
@@ -16,17 +16,19 @@
  */
 package org.apache.camel.example;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class UnmarshalTest extends ContextTestSupport {
+public class UnmarshalTest extends CamelTestSupport {
 
+    @Test
     public void testSendXmlAndUnmarshal() throws Exception {
         PurchaseOrder expected = new PurchaseOrder();
         expected.setName("Wine");

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbSpringTest.java
Wed Jan  6 01:45:52 2010
@@ -17,18 +17,31 @@
 package org.apache.camel.jaxb;
 
 import org.apache.camel.CamelContext;
-import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+import org.apache.camel.Service;
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
 
 public class CamelJaxbSpringTest extends CamelJaxbTest {
     
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/jaxb/CamelJaxbTest.xml");
-    }
-    
-    @Override
-    protected void setUp() throws Exception {
         setUseRouteBuilder(false);
-        super.setUp();
+        final AbstractXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/jaxb/CamelJaxbTest.xml");
+        setCamelContextService(new Service() {
+            public void start() throws Exception {
+                applicationContext.start();
+            }
+
+            public void stop() throws Exception {
+                applicationContext.stop();
+            }
+        });
+
+        return SpringCamelContext.springCamelContext(applicationContext);
+        
     }
+    
+   
 
 }

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java
Wed Jan  6 01:45:52 2010
@@ -21,7 +21,7 @@
 
 import javax.xml.bind.JAXBElement;
 
-import org.apache.camel.ContextTestSupport;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.builder.RouteBuilder;
@@ -29,10 +29,13 @@
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
 import org.apache.camel.foo.bar.PersonType;
 import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
 
 
-public class CamelJaxbTest extends ContextTestSupport {
+public class CamelJaxbTest extends CamelTestSupport {
     
+    @Test
     public void testConvertor() throws Exception {
         TypeConverter converter = context.getTypeConverter();
         PersonType person = converter.convertTo(PersonType.class, 
@@ -42,6 +45,7 @@
         assertEquals("Get the wrong second name ", person.getLastName(), "BAR");
     }
     
+    @Test
     public void testFilteringUnmarshal() throws Exception {
         final byte[] buffers = "<Person><firstName>FOO</firstName><lastName>BAR\u0008</lastName></Person>".getBytes("UTF-8");
         InputStream is = new ByteArrayInputStream(buffers);
@@ -54,6 +58,7 @@
         assertEquals("Get the wrong second name ", person.getLastName(), "BAR");
     }
 
+    @Test
     public void testUnmarshal() throws Exception {
         final String xml = "<Person><firstName>FOO</firstName><lastName>BAR</lastName></Person>";
         PersonType expected = new PersonType();

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java?rev=896302&r1=896301&r2=896302&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
Wed Jan  6 01:45:52 2010
@@ -18,16 +18,19 @@
 
 import java.io.File;
 
-import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.converter.jaxb.MessageDefinition;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class DumpToXmlTest extends ContextTestSupport {
+public class DumpToXmlTest extends CamelTestSupport {
     @Override
-    protected void setUp() throws Exception {
+    @Before
+    public void setUp() throws Exception {
         // Delete the dump directory
         File file = new File("target/camel/dump");
         file = file.getAbsoluteFile();
@@ -37,6 +40,7 @@
         super.setUp();
     }
 
+    @Test
     public void testDumplFilesToJaxb() throws Exception {
         // sleep to let the file and jaxb do its works
         Thread.sleep(5000);

Added: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java?rev=896302&view=auto
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
(added)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
Wed Jan  6 01:45:52 2010
@@ -0,0 +1,57 @@
+/**
+ * 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.test;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultExchange;
+
+/**
+ * A base class for a test which requires a {@link CamelContext} and
+ * a populated {@link Exchange}
+ *
+ * @version $Revision$
+ */
+public abstract class ExchangeTestSupport extends CamelTestSupport {
+    protected Exchange exchange;
+
+    /**
+     * A factory method to create an Exchange implementation
+     */
+    protected Exchange createExchange() {
+        return new DefaultExchange(context);
+    }
+
+    /**
+     * A strategy method to populate an exchange with some example values for use
+     * by language plugins
+     */
+    protected void populateExchange(Exchange exchange) {
+        Message in = exchange.getIn();
+        in.setHeader("foo", "abc");
+        in.setHeader("bar", 123);
+        in.setBody("<hello id='m123'>world!</hello>");
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        exchange = createExchange();
+        assertNotNull("No exchange created!", exchange);
+        populateExchange(exchange);
+    }
+}

Propchange: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/ExchangeTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java?rev=896302&view=auto
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
(added)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
Wed Jan  6 01:45:52 2010
@@ -0,0 +1,59 @@
+/**
+ * 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.test.junit4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+
+/**
+ * A base class for a test which requires a {@link CamelContext} and
+ * a populated {@link Exchange}
+ *
+ * @version $Revision$
+ */
+public abstract class ExchangeTestSupport extends CamelTestSupport {
+    protected Exchange exchange;
+
+    /**
+     * A factory method to create an Exchange implementation
+     */
+    protected Exchange createExchange() {
+        return new DefaultExchange(context);
+    }
+
+    /**
+     * A strategy method to populate an exchange with some example values for use
+     * by language plugins
+     */
+    protected void populateExchange(Exchange exchange) {
+        Message in = exchange.getIn();
+        in.setHeader("foo", "abc");
+        in.setHeader("bar", 123);
+        in.setBody("<hello id='m123'>world!</hello>");
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        exchange = createExchange();
+        assertNotNull("No exchange created!", exchange);
+        populateExchange(exchange);
+    }
+}

Propchange: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/junit4/ExchangeTestSupport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message