jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1407101 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
Date Thu, 08 Nov 2012 14:38:08 GMT
Author: mduerig
Date: Thu Nov  8 14:38:08 2012
New Revision: 1407101

URL: http://svn.apache.org/viewvc?rev=1407101&view=rev
Log:
OAK-417: Refactor/reimplement TreeImpl.getStatus and TreeImpl.getPropertyStatus to take advantage
of the underlying NodeBuilder
refactor TypeCodes: test case

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
  (with props)

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java?rev=1407101&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
Thu Nov  8 14:38:08 2012
@@ -0,0 +1,72 @@
+/*
+ * 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.jackrabbit.oak.kernel;
+
+import javax.jcr.PropertyType;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TypeCodesTest {
+
+    @Test
+    public void testEncode() {
+        assertEquals("str:foo", TypeCodes.encode(PropertyType.STRING, "foo"));
+        assertEquals("bin:", TypeCodes.encode(PropertyType.BINARY, ""));
+        assertEquals("und:foo", TypeCodes.encode(PropertyType.UNDEFINED, "foo"));
+    }
+
+    @Test
+    public void testSplit() {
+        assertEquals(3, TypeCodes.split("str:foo"));
+        assertEquals(3, TypeCodes.split("str:"));
+        assertEquals(-1, TypeCodes.split("foo"));
+        assertEquals(-1, TypeCodes.split(""));
+    }
+
+    @Test
+    public void testDecodeType() {
+        String strFoo = "str:foo";
+        assertEquals(PropertyType.STRING, TypeCodes.decodeType(TypeCodes.split(strFoo), strFoo));
+
+        String str = "str:";
+        assertEquals(PropertyType.STRING, TypeCodes.decodeType(TypeCodes.split(str), str));
+
+        String any = "any";
+        assertEquals(PropertyType.UNDEFINED, TypeCodes.decodeType(TypeCodes.split(any), any));
+
+        String empty = "";
+        assertEquals(PropertyType.UNDEFINED, TypeCodes.decodeType(TypeCodes.split(empty),
empty));
+    }
+
+    @Test
+    public void testDecodeName() {
+        String strFoo = "str:foo";
+        assertEquals("foo", TypeCodes.decodeName(TypeCodes.split(strFoo), strFoo));
+
+        String str = "str:";
+        assertEquals("", TypeCodes.decodeName(TypeCodes.split(str), str));
+
+        String any = "any";
+        assertEquals("any", TypeCodes.decodeName(TypeCodes.split(any), any));
+
+        String empty = "";
+        assertEquals("", TypeCodes.decodeName(TypeCodes.split(empty), empty));
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/TypeCodesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message