You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/18 09:44:22 UTC
svn commit: r816504 - in
/camel/trunk/camel-core/src/test/java/org/apache/camel:
impl/DefaultExchangeHolderTest.java impl/MainSupportTest.java
processor/ValidatingProcessorTest.java
Author: davsclaus
Date: Fri Sep 18 07:44:22 2009
New Revision: 816504
URL: http://svn.apache.org/viewvc?rev=816504&view=rev
Log:
MR-187: Added unit tests
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java (with props)
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java (with props)
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java?rev=816504&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java Fri Sep 18 07:44:22 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.impl;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+
+/**
+ * @version $Revision$
+ */
+public class DefaultExchangeHolderTest extends ContextTestSupport {
+
+ public void testMarshal() throws Exception {
+ DefaultExchangeHolder holder = createHolder();
+ assertNotNull(holder);
+ }
+
+ public void testUnmarshal() throws Exception {
+ Exchange exchange = new DefaultExchange(context);
+
+ DefaultExchangeHolder.unmarshal(exchange, createHolder());
+ assertEquals("Hello World", exchange.getIn().getBody());
+ assertEquals("Bye World", exchange.getOut().getBody());
+ assertEquals(123, exchange.getIn().getHeader("foo"));
+ assertEquals(444, exchange.getProperty("bar"));
+ }
+
+ private DefaultExchangeHolder createHolder() {
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody("Hello World");
+ exchange.getIn().setHeader("foo", 123);
+ exchange.setProperty("bar", 444);
+ exchange.getOut().setBody("Bye World");
+ return DefaultExchangeHolder.marshal(exchange);
+ }
+
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultExchangeHolderTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java?rev=816504&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java Fri Sep 18 07:44:22 2009
@@ -0,0 +1,56 @@
+/**
+ * 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.impl;
+
+import java.util.Map;
+import javax.xml.bind.JAXBException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.view.ModelFileGenerator;
+
+/**
+ * @version $Revision$
+ */
+public class MainSupportTest extends ContextTestSupport {
+
+ private class MyMainSupport extends MainSupport {
+
+ protected ProducerTemplate findOrCreateCamelTemplate() {
+ return context.createProducerTemplate();
+ }
+
+ protected Map<String, CamelContext> getCamelContextMap() {
+ return null;
+ }
+
+ protected ModelFileGenerator createModelFileGenerator() throws JAXBException {
+ return null;
+ }
+ }
+
+ public void testMainSupport() throws Exception {
+ MyMainSupport my = new MyMainSupport();
+ my.run(new String[]{"-d", "1s"});
+ }
+
+ public void testMainSupportHelp() throws Exception {
+ MyMainSupport my = new MyMainSupport();
+ my.run(new String[]{"-h"});
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/MainSupportTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java?rev=816504&r1=816503&r2=816504&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidatingProcessorTest.java Fri Sep 18 07:44:22 2009
@@ -23,6 +23,7 @@
import org.apache.camel.ValidationException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.validation.NoXmlBodyValidationException;
import org.apache.camel.processor.validation.SchemaValidationException;
import org.apache.camel.processor.validation.ValidatingProcessor;
@@ -76,6 +77,20 @@
assertMockEndpointsSatisfied();
}
+ public void testNoXMLBody() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:invalid");
+ mock.expectedMessageCount(1);
+
+ try {
+ template.sendBody("direct:start", null);
+ fail("Should have thrown a RuntimeCamelException");
+ } catch (RuntimeCamelException e) {
+ assertIsInstanceOf(NoXmlBodyValidationException.class, e.getCause());
+ }
+
+ assertMockEndpointsSatisfied();
+ }
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {