Author: davsclaus
Date: Wed Feb 24 08:11:56 2010
New Revision: 915717

URL: http://svn.apache.org/viewvc?rev=915717&view=rev
Log:
CAMEL-217: Added more tests.

Added:
    
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryAlotDataTest.java
      - copied, changed from r915673, 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java
Modified:
    camel/trunk/components/camel-hawtdb/pom.xml
    
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java

Modified: camel/trunk/components/camel-hawtdb/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/pom.xml?rev=915717&r1=915716&r2=915717&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/pom.xml (original)
+++ camel/trunk/components/camel-hawtdb/pom.xml Wed Feb 24 08:11:56 2010
@@ -15,96 +15,91 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
 
-  <modelVersion>4.0.0</modelVersion>
+    <modelVersion>4.0.0</modelVersion>
 
-  <parent>
-    <groupId>org.apache.camel</groupId>
-    <artifactId>camel-parent</artifactId>
-    <version>2.3-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>camel-hawtdb</artifactId>
-  <packaging>bundle</packaging>
-  <name>Camel :: HawtDB</name>
-  <description>Camel HawtDB Support</description>
-
-  <properties>
-         
<camel.osgi.export.pkg>org.apache.camel.component.hawtdb.*</camel.osgi.export.pkg>
-  </properties>
-
-  <repositories>
-    <repository>
-      <id>hawtdb-release</id>
-      <name>HawtDB Release Repository</name>
-      <url>http://hawtdb.fusesource.org/repo/release</url>
-      <snapshots>
-        <enabled>false</enabled>
-      </snapshots>
-      <releases>
-        <enabled>true</enabled>
-      </releases>
-    </repository>
-    <repository>
-      <id>hawtdb-snapshot</id>
-      <name>HawtDB Snapshot Repository</name>
-      <url>http://hawtdb.fusesource.org/repo/snapshot</url>
-      <snapshots>
-        <enabled>true</enabled>
-      </snapshots>
-      <releases>
-        <enabled>false</enabled>
-      </releases>
-    </repository>
-  </repositories>
-  <dependencies>
-
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.fusesource.hawtdb</groupId>
-      <artifactId>hawtdb</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-
-    <!-- testing -->
-    <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-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <!-- to allow Spring annotations (jmx) to be tested -->
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-context</artifactId>
-      <optional>true</optional>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-aop</artifactId>
-      <optional>true</optional>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>2.3-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-hawtdb</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: HawtDB</name>
+    <description>Camel HawtDB Support</description>
+
+    <properties>
+        
<camel.osgi.export.pkg>org.apache.camel.component.hawtdb.*</camel.osgi.export.pkg>
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>hawtdb-release</id>
+            <name>HawtDB Release Repository</name>
+            <url>http://hawtdb.fusesource.org/repo/release</url>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+        </repository>
+        <repository>
+            <id>hawtdb-snapshot</id>
+            <name>HawtDB Snapshot Repository</name>
+            <url>http://hawtdb.fusesource.org/repo/snapshot</url>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+        </repository>
+    </repositories>
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.fusesource.hawtdb</groupId>
+            <artifactId>hawtdb</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <!-- to allow Spring annotations (jmx) to be tested -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
 
 </project>

Copied: 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryAlotDataTest.java
 (from r915673, 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryAlotDataTest.java?p2=camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryAlotDataTest.java&p1=camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java&r1=915673&r2=915717&rev=915717&view=diff
==============================================================================
--- 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java
 (original)
+++ 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryAlotDataTest.java
 Wed Feb 24 08:11:56 2010
@@ -23,7 +23,7 @@
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class HawtDBAggregationRepositoryTest extends CamelTestSupport {
+public class HawtDBAggregationRepositoryAlotDataTest extends CamelTestSupport {
 
     private HawtDBFile hawtDBFile;
 
@@ -44,35 +44,61 @@
     }
 
     @Test
-    public void testOperations() {
+    public void testWithAlotOfDataSameKey() {
         HawtDBAggregationRepository<String> repo = new 
HawtDBAggregationRepository<String>();
         repo.setFile(hawtDBFile);
         repo.setName("repo1");
 
-        // Can't get something we have not put in...
-        Exchange actual = repo.get("missing");
-        assertEquals(null, actual);
-
-        // Store it..
-        Exchange exchange1 = new DefaultExchange(context);
-        exchange1.getIn().setBody("counter:1");
-        actual = repo.add("foo", exchange1);
-        assertEquals(null, actual);
+        for (int i = 0; i < 100; i++) {
+            Exchange exchange1 = new DefaultExchange(context);
+            exchange1.getIn().setBody("counter:" + i);
+            repo.add("foo", exchange1);
+        }
 
         // Get it back..
-        actual = repo.get("foo");
-        assertEquals("counter:1", actual.getIn().getBody());
+        Exchange actual = repo.get("foo");
+        assertEquals("counter:99", actual.getIn().getBody());
+    }
+
+    @Test
+    public void testWithAlotOfDataTwoKesy() {
+        HawtDBAggregationRepository<String> repo = new 
HawtDBAggregationRepository<String>();
+        repo.setFile(hawtDBFile);
+        repo.setName("repo1");
+
+        for (int i = 0; i < 100; i++) {
+            Exchange exchange1 = new DefaultExchange(context);
+            exchange1.getIn().setBody("counter:" + i);
+            String key = i % 2 == 0 ? "foo" : "bar";
+            repo.add(key, exchange1);
+        }
+
+        // Get it back..
+        Exchange actual = repo.get("foo");
+        assertEquals("counter:98", actual.getIn().getBody());
+
+        actual = repo.get("bar");
+        assertEquals("counter:99", actual.getIn().getBody());
+    }
+
+    @Test
+    public void testWithAlotOfDataWithDifferentKesy() {
+        HawtDBAggregationRepository<String> repo = new 
HawtDBAggregationRepository<String>();
+        repo.setFile(hawtDBFile);
+        repo.setName("repo1");
 
-        // Change it..
-        Exchange exchange2 = new DefaultExchange(context);
-        exchange2.getIn().setBody("counter:2");
-        actual = repo.add("foo", exchange2);
-        // the old one
-        assertEquals("counter:1", actual.getIn().getBody());
+        for (int i = 0; i < 100; i++) {
+            Exchange exchange1 = new DefaultExchange(context);
+            exchange1.getIn().setBody("counter:" + i);
+            String key = "key" + i;
+            repo.add(key, exchange1);
+        }
 
         // Get it back..
-        actual = repo.get("foo");
-        assertEquals("counter:2", actual.getIn().getBody());
+        for (int i = 0; i < 100; i++) {
+            Exchange actual = repo.get("key" + i);
+            assertEquals("counter:" + i, actual.getIn().getBody());
+        }
     }
 
-}
+}
\ No newline at end of file

Modified: 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java?rev=915717&r1=915716&r2=915717&view=diff
==============================================================================
--- 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java
 (original)
+++ 
camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepositoryTest.java
 Wed Feb 24 08:11:56 2010
@@ -73,6 +73,21 @@
         // Get it back..
         actual = repo.get("foo");
         assertEquals("counter:2", actual.getIn().getBody());
+
+        // now remove it
+        repo.remove("foo");
+        actual = repo.get("foo");
+        assertEquals(null, actual);
+
+        // add it again
+        exchange1 = new DefaultExchange(context);
+        exchange1.getIn().setBody("counter:3");
+        actual = repo.add("foo", exchange1);
+        assertEquals(null, actual);
+
+        // Get it back..
+        actual = repo.get("foo");
+        assertEquals("counter:3", actual.getIn().getBody());
     }
 
 }


Reply via email to