You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/08/01 07:03:19 UTC

svn commit: r561660 [2/2] - in /incubator/servicemix/trunk: core/servicemix-core/src/main/java/org/apache/servicemix/jbi/util/ core/servicemix-core/src/test/java/org/apache/servicemix/jbi/util/ deployables/serviceengines/servicemix-eip/src/main/java/or...

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparator.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparator.java?view=auto&rev=561660
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparator.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparator.java Tue Jul 31 22:03:17 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.servicemix.eip.support.resequence;
+
+public class TestComparator implements SequenceElementComparator<TestObject> {
+
+    public boolean predecessor(TestObject o1, TestObject o2) {
+        return (o2.getValue() - 1) == o1.getValue();
+    }
+
+    public boolean successor(TestObject o1, TestObject o2) {
+        return (o1.getValue() - 1) == o2.getValue();
+    }
+
+    public int compare(TestObject o1, TestObject o2) {
+        return Integer.valueOf(o1.getValue()).compareTo(o2.getValue());
+    }
+
+}

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparatorTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparatorTest.java?view=auto&rev=561660
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparatorTest.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestComparatorTest.java Tue Jul 31 22:03:17 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.servicemix.eip.support.resequence;
+
+import junit.framework.TestCase;
+
+public class TestComparatorTest extends TestCase {
+
+    private TestComparator c;
+    
+    private TestObject e1;
+    private TestObject e2;
+    private TestObject e3;
+    
+    public void setUp() {
+        c = new TestComparator();
+        e1 = new TestObject(3);
+        e2 = new TestObject(4);
+        e3 = new TestObject(7);
+    }
+    
+    public void tearDown() throws Exception {
+    }
+
+    public void testPredecessor() {
+        assertTrue(c.predecessor(e1, e2));
+        assertFalse(c.predecessor(e2, e1));
+        assertFalse(c.predecessor(e1, e3));
+        assertFalse(c.predecessor(e3, e1));
+        assertFalse(c.predecessor(e3, e3));
+    }
+
+    public void testSuccessor() {
+        assertTrue(c.successor(e2, e1));
+        assertFalse(c.successor(e1, e2));
+        assertFalse(c.successor(e3, e1));
+        assertFalse(c.successor(e1, e3));
+        assertFalse(c.successor(e3, e3));
+    }
+
+    public void testCompare() {
+        assertTrue(c.compare(e1, e2) < 0);
+        assertTrue(c.compare(e2, e1) > 0);
+        assertTrue(c.compare(e1, e3) < 0);
+        assertTrue(c.compare(e3, e1) > 0);
+        assertTrue(c.compare(e3, e3) == 0);
+    }
+    
+}

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestObject.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestObject.java?view=auto&rev=561660
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestObject.java (added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/support/resequence/TestObject.java Tue Jul 31 22:03:17 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.servicemix.eip.support.resequence;
+
+public class TestObject {
+
+    private int value;
+    
+    public TestObject(int value) {
+        this.value = value;
+    }
+    
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public String toString() {
+        return Integer.toString(value);
+    }
+    
+}