Author: jbellis
Date: Fri Mar 19 20:26:00 2010
New Revision: 925406

URL: http://svn.apache.org/viewvc?rev=925406&view=rev
Log:
move marshall compare tests into single class to avoid jvm startup overhead.  
patch by jbellis

Added:
    
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java
   (with props)
Removed:
    
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/AsciiTypeTest.java
    
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/BytesTypeTest.java
    
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/UTF8TypeTest.java

Added: 
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java?rev=925406&view=auto
==============================================================================
--- 
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java
 (added)
+++ 
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java
 Fri Mar 19 20:26:00 2010
@@ -0,0 +1,69 @@
+package org.apache.cassandra.db.marshal;
+/*
+ * 
+ * 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.
+ * 
+ */
+
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.lang.ArrayUtils;
+
+import org.junit.Test;
+
+public class TypeCompareTest
+{
+    @Test
+    public void testAscii()
+    {
+        AsciiType comparator = new AsciiType();
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
"asdf".getBytes()) < 0;
+        assert comparator.compare("asdf".getBytes(), 
ArrayUtils.EMPTY_BYTE_ARRAY) > 0;
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
ArrayUtils.EMPTY_BYTE_ARRAY) == 0;
+        assert comparator.compare("z".getBytes(), "a".getBytes()) > 0;
+        assert comparator.compare("a".getBytes(), "z".getBytes()) < 0;
+        assert comparator.compare("asdf".getBytes(), "asdf".getBytes()) == 0;
+        assert comparator.compare("asdz".getBytes(), "asdf".getBytes()) > 0;
+    }
+
+    @Test
+    public void testBytes()
+    {
+        BytesType comparator = new BytesType();
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
"asdf".getBytes()) < 0;
+        assert comparator.compare("asdf".getBytes(), 
ArrayUtils.EMPTY_BYTE_ARRAY) > 0;
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
ArrayUtils.EMPTY_BYTE_ARRAY) == 0;
+        assert comparator.compare("z".getBytes(), "a".getBytes()) > 0;
+        assert comparator.compare("a".getBytes(), "z".getBytes()) < 0;
+        assert comparator.compare("asdf".getBytes(), "asdf".getBytes()) == 0;
+        assert comparator.compare("asdz".getBytes(), "asdf".getBytes()) > 0;
+    }
+
+    @Test
+    public void testUTF8() throws UnsupportedEncodingException
+    {
+        UTF8Type comparator = new UTF8Type();
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
"asdf".getBytes()) < 0;
+        assert comparator.compare("asdf".getBytes(), 
ArrayUtils.EMPTY_BYTE_ARRAY) > 0;
+        assert comparator.compare(ArrayUtils.EMPTY_BYTE_ARRAY, 
ArrayUtils.EMPTY_BYTE_ARRAY) == 0;
+        assert comparator.compare("z".getBytes("UTF-8"), 
"a".getBytes("UTF-8")) > 0;
+        assert comparator.compare("z".getBytes("UTF-8"), 
"z".getBytes("UTF-8")) == 0;
+        assert comparator.compare("a".getBytes("UTF-8"), 
"z".getBytes("UTF-8")) < 0;
+    }
+}

Propchange: 
cassandra/branches/cassandra-0.6/test/unit/org/apache/cassandra/db/marshal/TypeCompareTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to