You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/05/01 13:42:45 UTC

svn commit: r652479 - in /activemq/camel/trunk: ./ apache-camel/ apache-camel/src/main/descriptors/ components/ components/camel-hamcrest/ components/camel-hamcrest/src/ components/camel-hamcrest/src/main/ components/camel-hamcrest/src/main/java/ compo...

Author: jstrachan
Date: Thu May  1 04:42:44 2008
New Revision: 652479

URL: http://svn.apache.org/viewvc?rev=652479&view=rev
Log:
added a little library of hamcrest assertions folks can use in their unit testing of camel routes

Added:
    activemq/camel/trunk/components/camel-hamcrest/
    activemq/camel/trunk/components/camel-hamcrest/pom.xml   (with props)
    activemq/camel/trunk/components/camel-hamcrest/src/
    activemq/camel/trunk/components/camel-hamcrest/src/main/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/
    activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java   (with props)
    activemq/camel/trunk/components/camel-hamcrest/src/test/
    activemq/camel/trunk/components/camel-hamcrest/src/test/java/
    activemq/camel/trunk/components/camel-hamcrest/src/test/java/org/
    activemq/camel/trunk/components/camel-hamcrest/src/test/java/org/apache/
    activemq/camel/trunk/components/camel-hamcrest/src/test/java/org/apache/camel/
    activemq/camel/trunk/components/camel-hamcrest/src/test/java/org/apache/camel/hamcrest/
    activemq/camel/trunk/components/camel-hamcrest/src/test/resources/
Modified:
    activemq/camel/trunk/apache-camel/pom.xml
    activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml
    activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml
    activemq/camel/trunk/components/pom.xml
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/pom.xml?rev=652479&r1=652478&r2=652479&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/pom.xml (original)
+++ activemq/camel/trunk/apache-camel/pom.xml Thu May  1 04:42:44 2008
@@ -85,6 +85,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-hamcrest</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-http</artifactId>
     </dependency>
     <dependency>

Modified: activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml?rev=652479&r1=652478&r2=652479&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml (original)
+++ activemq/camel/trunk/apache-camel/src/main/descriptors/unix-bin.xml Thu May  1 04:42:44 2008
@@ -101,6 +101,7 @@
         <include>org.apache.camel:camel-cxf</include>
         <include>org.apache.camel:camel-ftp</include>
         <include>org.apache.camel:camel-groovy</include>
+        <include>org.apache.camel:camel-hamcrest</include>
         <include>org.apache.camel:camel-http</include>
         <include>org.apache.camel:camel-ibatis</include>
         <include>org.apache.camel:camel-irc</include>

Modified: activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml?rev=652479&r1=652478&r2=652479&view=diff
==============================================================================
--- activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml (original)
+++ activemq/camel/trunk/apache-camel/src/main/descriptors/windows-bin.xml Thu May  1 04:42:44 2008
@@ -107,6 +107,7 @@
         <include>org.apache.camel:camel-cxf</include>
         <include>org.apache.camel:camel-ftp</include>
         <include>org.apache.camel:camel-groovy</include>
+        <include>org.apache.camel:camel-hamcrest</include>
         <include>org.apache.camel:camel-http</include>
         <include>org.apache.camel:camel-ibatis</include>
         <include>org.apache.camel:camel-irc</include>

Added: activemq/camel/trunk/components/camel-hamcrest/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-hamcrest/pom.xml?rev=652479&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-hamcrest/pom.xml (added)
+++ activemq/camel/trunk/components/camel-hamcrest/pom.xml Thu May  1 04:42:44 2008
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.4-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-hamcrest</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: JUnit</name>
+  <description>Camel Hamcrest support</description>
+
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.hamcrest.*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-all</artifactId>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/camel/trunk/components/camel-hamcrest/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java?rev=652479&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java (added)
+++ activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java Thu May  1 04:42:44 2008
@@ -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.hamcrest;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+
+/**
+ * A set of useful assertions you can use when testing
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class Assertions {
+
+    /**
+     * Performs the assertion that the given value is an instance of the specified type
+     *
+     * @param value the value to be compared
+     * @param type  the type to assert
+     * @return the value cast as the type
+     * @throws AssertionError if the instance is not of the correct type
+     */
+    public static <T> T assertInstanceOf(Object value, Class<T> type) {
+        assertThat(value, instanceOf(type));
+        return type.cast(value);
+    }
+
+    /**
+     * Performs the assertion that the given value is an instance of the specified type
+     *
+     * @param message the description of the value
+     * @param value   the value to be compared
+     * @param type    the type to assert
+     * @return the value cast as the type
+     * @throws AssertionError if the instance is not of the correct type
+     */
+    public static <T> T assertInstanceOf(String message, Object value, Class<T> type) {
+        assertThat(message, value, instanceOf(type));
+        return type.cast(value);
+    }
+}

Propchange: activemq/camel/trunk/components/camel-hamcrest/src/main/java/org/apache/camel/hamcrest/Assertions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/pom.xml?rev=652479&r1=652478&r2=652479&view=diff
==============================================================================
--- activemq/camel/trunk/components/pom.xml (original)
+++ activemq/camel/trunk/components/pom.xml Thu May  1 04:42:44 2008
@@ -41,6 +41,7 @@
     <module>camel-cxf</module>
     <module>camel-ftp</module>
     <module>camel-groovy</module>
+    <module>camel-hamcrest</module>
     <module>camel-http</module>
     <module>camel-ibatis</module>
     <module>camel-irc</module>

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=652479&r1=652478&r2=652479&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Thu May  1 04:42:44 2008
@@ -265,6 +265,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-hamcrest</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-http</artifactId>
         <version>${project.version}</version>
       </dependency>