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 2010/09/14 10:44:32 UTC
svn commit: r996793 -
/camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java
Author: davsclaus
Date: Tue Sep 14 08:44:32 2010
New Revision: 996793
URL: http://svn.apache.org/viewvc?rev=996793&view=rev
Log:
Added unit test
Added:
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java
- copied, changed from r996754, camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBExchangeSerializationTest.java
Copied: camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java (from r996754, camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBExchangeSerializationTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java?p2=camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java&p1=camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBExchangeSerializationTest.java&r1=996754&r2=996793&rev=996793&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBExchangeSerializationTest.java (original)
+++ camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBGetNotFoundTest.java Tue Sep 14 08:44:32 2010
@@ -17,14 +17,13 @@
package org.apache.camel.component.hawtdb;
import java.io.File;
-import java.util.Date;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
-public class HawtDBExchangeSerializationTest extends CamelTestSupport {
+public class HawtDBGetNotFoundTest extends CamelTestSupport {
private HawtDBFile hawtDBFile;
@@ -45,47 +44,38 @@ public class HawtDBExchangeSerialization
}
@Test
- public void testExchangeSerialization() {
+ public void testGetNotFound() {
HawtDBAggregationRepository repo = new HawtDBAggregationRepository();
repo.setHawtDBFile(hawtDBFile);
repo.setRepositoryName("repo1");
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody("Hello World");
- exchange.getIn().setHeader("name", "Claus");
- exchange.getIn().setHeader("number", 123);
- exchange.setProperty("quote", "Camel rocks");
-
- Date now = new Date();
- exchange.getIn().setHeader("date", now);
-
- repo.add(context, "foo", exchange);
-
- Exchange actual = repo.get(context, "foo");
- assertEquals("Hello World", actual.getIn().getBody());
- assertEquals("Claus", actual.getIn().getHeader("name"));
- assertEquals(123, actual.getIn().getHeader("number"));
- Date date = actual.getIn().getHeader("date", Date.class);
- assertNotNull(date);
- assertEquals(now.getTime(), date.getTime());
- // we do not serialize properties to avoid storing all kind of not needed information
- assertNull(actual.getProperty("quote"));
- assertSame(context, actual.getContext());
-
- // change something
- exchange.getIn().setBody("Bye World");
- exchange.getIn().setHeader("name", "Hiram");
- exchange.getIn().removeHeader("date");
-
- repo.add(context, "foo", exchange);
-
- actual = repo.get(context, "foo");
- assertEquals("Bye World", actual.getIn().getBody());
- assertEquals("Hiram", actual.getIn().getHeader("name"));
- assertEquals(123, actual.getIn().getHeader("number"));
- date = actual.getIn().getHeader("date", Date.class);
- assertNull(date);
- assertSame(context, actual.getContext());
+
+ Exchange out = repo.get(context, exchange.getExchangeId());
+ assertNull("Should not find exchange", out);
+ }
+
+ @Test
+ public void testPutAndGetNotFound() {
+ HawtDBAggregationRepository repo = new HawtDBAggregationRepository();
+ repo.setHawtDBFile(hawtDBFile);
+ repo.setRepositoryName("repo1");
+
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getIn().setBody("Hello World");
+ log.info("Created " + exchange.getExchangeId());
+
+ repo.add(context, exchange.getExchangeId(), exchange);
+ Exchange out = repo.get(context, exchange.getExchangeId());
+ assertNotNull("Should find exchange", out);
+
+ Exchange exchange2 = new DefaultExchange(context);
+ exchange2.getIn().setBody("Bye World");
+ log.info("Created " + exchange2.getExchangeId());
+
+ Exchange out2 = repo.get(context, exchange2.getExchangeId());
+ assertNull("Should not find exchange", out2);
}
}
\ No newline at end of file