jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1390351 - in /jackrabbit/oak/trunk/oak-mongomk: ./ src/main/java/org/apache/jackrabbit/mongomk/command/ src/main/java/org/apache/jackrabbit/mongomk/model/ src/main/java/org/apache/jackrabbit/mongomk/query/ src/main/java/org/apache/jackrabb...
Date Wed, 26 Sep 2012 09:37:19 GMT
Author: jukka
Date: Wed Sep 26 09:37:18 2012
New Revision: 1390351

URL: http://svn.apache.org/viewvc?rev=1390351&view=rev
Log:
OAK-337: Update MongoMK's logger

Patch by Mete Atamel

Added:
    jackrabbit/oak/trunk/oak-mongomk/src/test/resources/logback-test.xml
Modified:
    jackrabbit/oak/trunk/oak-mongomk/pom.xml
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongo.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongo.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/CommitCommandInstructionVisitor.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQuery.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQuery.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQuery.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/QueryUtils.java
    jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/BaseMongoTest.java
    jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java

Modified: jackrabbit/oak/trunk/oak-mongomk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/pom.xml?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-mongomk/pom.xml Wed Sep 26 09:37:18 2012
@@ -26,7 +26,8 @@
   <parent>
     <groupId>org.apache.jackrabbit</groupId>
     <artifactId>oak-parent</artifactId>
-    <version>0.5-SNAPSHOT</version>
+    <version>0.6-SNAPSHOT</version>
+    <relativePath>../oak-parent/pom.xml</relativePath>
   </parent>
 
   <artifactId>oak-mongomk</artifactId>
@@ -50,9 +51,9 @@
 
     <!-- Logging -->
     <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-      <version>1.2.16</version>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.6.4</version>
     </dependency>
 
     <!-- Other -->
@@ -84,6 +85,12 @@
       <version>3.1</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+        <groupId>ch.qos.logback</groupId>
+        <artifactId>logback-classic</artifactId>
+        <version>1.0.1</version>
+        <scope>test</scope>
+    </dependency>
 
   </dependencies>
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongo.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongo.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongo.java
Wed Sep 26 09:37:18 2012
@@ -36,7 +36,8 @@ import org.apache.jackrabbit.mongomk.que
 import org.apache.jackrabbit.mongomk.query.SaveAndSetHeadRevisionQuery;
 import org.apache.jackrabbit.mongomk.query.SaveCommitQuery;
 import org.apache.jackrabbit.mongomk.query.SaveNodesQuery;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.mongodb.BasicDBObject;
 import com.mongodb.DBCollection;
@@ -51,7 +52,7 @@ import com.mongodb.WriteResult;
  */
 public class CommitCommandMongo extends AbstractCommand<String> {
 
-    private static final Logger logger = Logger.getLogger(CommitCommandMongo.class);
+    private static final Logger logger = LoggerFactory.getLogger(CommitCommandMongo.class);
 
     private final Commit commit;
     private final MongoConnection mongoConnection;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongo.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongo.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongo.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/command/GetNodesCommandMongo.java
Wed Sep 26 09:37:18 2012
@@ -32,7 +32,8 @@ import org.apache.jackrabbit.mongomk.que
 import org.apache.jackrabbit.mongomk.query.FetchValidCommitsQuery;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A {@code Command} for getting nodes from {@code MongoDB}.
@@ -45,7 +46,7 @@ public class GetNodesCommandMongo extend
         private static final long serialVersionUID = 8155418280936077632L;
     }
 
-    private static final Logger LOG = Logger.getLogger(GetNodesCommandMongo.class);
+    private static final Logger LOG = LoggerFactory.getLogger(GetNodesCommandMongo.class);
 
     private final MongoConnection mongoConnection;
     private final String path;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/CommitCommandInstructionVisitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/CommitCommandInstructionVisitor.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/CommitCommandInstructionVisitor.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/model/CommitCommandInstructionVisitor.java
Wed Sep 26 09:37:18 2012
@@ -50,18 +50,14 @@ public class CommitCommandInstructionVis
 
     @Override
     public void visit(AddNodeInstruction instruction) {
-// Old code
-//        String path = instruction.getPath();
-//        getStagedNode(path);
-//        if (!PathUtils.denotesRoot(path)) {
-//            String parentPath = PathUtils.getParentPath(path);
-//            NodeMongo parentNode = getStagedNode(parentPath);
-//            parentNode.addChild(PathUtils.getName(path));
-//        }
-
         String path = instruction.getPath();
         getStagedNode(path);
+
         String nodeName = PathUtils.getName(path);
+        if (nodeName.isEmpty()) {
+            return;
+        }
+
         String parentNodePath = PathUtils.getParentPath(path);
         NodeMongo parent = null;
         if (!PathUtils.denotesRoot(parentNodePath)) {
@@ -213,8 +209,11 @@ public class CommitCommandInstructionVis
     public void visit(RemoveNodeInstruction instruction) {
         String path = instruction.getPath();
         String parentPath = PathUtils.getParentPath(path);
-        NodeMongo parentNode = getStagedNode(parentPath);
-        // [Mete] What if there is no such child?
+        NodeMongo parentNode = getStoredNode(parentPath);
+        String childName = PathUtils.getName(path);
+        if (!parentNode.childExists(childName)) {
+            throw new RuntimeException(path);
+        }
         parentNode.removeChild(PathUtils.getName(path));
     }
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQuery.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQuery.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesByPathAndDepthQuery.java
Wed Sep 26 09:37:18 2012
@@ -22,7 +22,8 @@ import java.util.regex.Pattern;
 import org.apache.jackrabbit.mongomk.MongoConnection;
 import org.apache.jackrabbit.mongomk.model.NodeMongo;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
@@ -35,7 +36,9 @@ import com.mongodb.QueryBuilder;
  * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
  */
 public class FetchNodesByPathAndDepthQuery extends AbstractQuery<List<NodeMongo>>
{
-    private static final Logger LOG = Logger.getLogger(FetchNodesByPathAndDepthQuery.class);
+
+    private static final Logger LOG = LoggerFactory.getLogger(FetchNodesByPathAndDepthQuery.class);
+
     private final int depth;
     private final String path;
     private final String revisionId;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQuery.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQuery.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchNodesForRevisionQuery.java
Wed Sep 26 09:37:18 2012
@@ -24,7 +24,8 @@ import java.util.Set;
 import org.apache.jackrabbit.mongomk.MongoConnection;
 import org.apache.jackrabbit.mongomk.model.NodeMongo;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
@@ -37,7 +38,9 @@ import com.mongodb.QueryBuilder;
  * @author <a href="mailto:pmarx@adobe.com>Philipp Marx</a>
  */
 public class FetchNodesForRevisionQuery extends AbstractQuery<List<NodeMongo>>
{
-    private static final Logger LOG = Logger.getLogger(FetchNodesForRevisionQuery.class);
+
+    private static final Logger LOG = LoggerFactory.getLogger(FetchNodesForRevisionQuery.class);
+
     private final Set<String> paths;
     private final String revisionId;
 

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQuery.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQuery.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQuery.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/FetchValidCommitsQuery.java
Wed Sep 26 09:37:18 2012
@@ -25,7 +25,8 @@ import java.util.Map;
 import org.apache.jackrabbit.mongomk.MongoConnection;
 import org.apache.jackrabbit.mongomk.model.CommitMongo;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
@@ -40,7 +41,7 @@ import com.mongodb.QueryBuilder;
 public class FetchValidCommitsQuery extends AbstractQuery<List<CommitMongo>>
{
 
     private static final int LIMITLESS = 0;
-    private static final Logger LOG = Logger.getLogger(FetchValidCommitsQuery.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FetchValidCommitsQuery.class);
 
     private final String fromRevisionId;
     private String toRevisionId;

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/QueryUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/QueryUtils.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/QueryUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/query/QueryUtils.java
Wed Sep 26 09:37:18 2012
@@ -22,7 +22,8 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.jackrabbit.mongomk.model.NodeMongo;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.mongodb.DBCursor;
 
@@ -33,7 +34,7 @@ import com.mongodb.DBCursor;
  */
 public class QueryUtils {
 
-    private static final Logger LOG = Logger.getLogger(QueryUtils.class);
+    private static final Logger LOG = LoggerFactory.getLogger(QueryUtils.class);
 
     /**
      * Reads nodes from the given {@link DBCursor} and add them to the returned list if their
revision id is contained

Modified: jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/main/java/org/apache/jackrabbit/mongomk/util/MongoUtil.java
Wed Sep 26 09:37:18 2012
@@ -35,6 +35,10 @@ import com.mongodb.DBObject;
 @SuppressWarnings("javadoc")
 public class MongoUtil {
 
+    public static final String INITIAL_COMMIT_MESSAGE = "This is an autogenerated initial
commit";
+    public static final String INITIAL_COMMIT_PATH = "";
+    public static final String INITIAL_COMMIT_DIFF = "+/ : {}";
+
     public static void clearCommitCollection(MongoConnection mongoConnection) {
         DBCollection commitCollection = mongoConnection.getCommitCollection();
         commitCollection.drop();
@@ -66,9 +70,9 @@ public class MongoUtil {
         CommitMongo commit = new CommitMongo();
         commit.setAffectedPaths(Arrays.asList(new String[] { "/" }));
         commit.setBaseRevId(0L);
-        commit.setDiff("+/ : {}");
-        commit.setMessage("This is an autogenerated initial commit");
-        commit.setPath("");
+        commit.setDiff(INITIAL_COMMIT_DIFF);
+        commit.setMessage(INITIAL_COMMIT_MESSAGE);
+        commit.setPath(INITIAL_COMMIT_PATH);
         commit.setRevisionId(0L);
         commitCollection.insert(commit);
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/BaseMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/BaseMongoTest.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/BaseMongoTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/BaseMongoTest.java
Wed Sep 26 09:37:18 2012
@@ -21,7 +21,6 @@ import java.util.Properties;
 
 import org.apache.jackrabbit.mongomk.MongoConnection;
 import org.apache.jackrabbit.mongomk.util.MongoUtil;
-import org.apache.log4j.BasicConfigurator;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -40,7 +39,6 @@ public class BaseMongoTest {
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        BasicConfigurator.configure();
         createDefaultMongoConnection();
         MongoAssert.setMongoConnection(mongoConnection);
     }

Modified: jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java?rev=1390351&r1=1390350&r2=1390351&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/command/CommitCommandMongoTest.java
Wed Sep 26 09:37:18 2012
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.mongomk.imp
 import org.apache.jackrabbit.mongomk.impl.model.CommitImpl;
 import org.apache.jackrabbit.mongomk.impl.model.RemoveNodeInstructionImpl;
 import org.apache.jackrabbit.mongomk.scenario.SimpleNodeScenario;
+import org.apache.jackrabbit.mongomk.util.MongoUtil;
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.junit.Assert;
 import org.junit.Ignore;
@@ -230,7 +231,6 @@ public class CommitCommandMongoTest exte
     }
 
     @Test
-    @Ignore // FIXME
     public void removeNonExistentNode() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("/", "a"));
@@ -368,18 +368,18 @@ public class CommitCommandMongoTest exte
     }
 
     @Test
-    @Ignore /// FIXME
     public void rootNodeHasEmptyRootPath() throws Exception {
         List<Instruction> instructions = new LinkedList<Instruction>();
         instructions.add(new AddNodeInstructionImpl("", "/"));
 
-        Commit commit = new CommitImpl("", "+/ : {}", "This is the root commit", instructions);
+        Commit commit = new CommitImpl(MongoUtil.INITIAL_COMMIT_PATH, MongoUtil.INITIAL_COMMIT_DIFF,
+                MongoUtil.INITIAL_COMMIT_MESSAGE, instructions);
         CommitCommandMongo command = new CommitCommandMongo(mongoConnection, commit);
         String revisionId = command.execute();
-
         Assert.assertNotNull(revisionId);
-        MongoAssert.assertNodesExist("",
-                NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId)));
+
+        Node expected = NodeBuilder.build(String.format("{ \"/#%1$s\" : {} }", revisionId));
+        MongoAssert.assertNodesExist(MongoUtil.INITIAL_COMMIT_PATH, expected);
     }
 
     @Test

Added: jackrabbit/oak/trunk/oak-mongomk/src/test/resources/logback-test.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mongomk/src/test/resources/logback-test.xml?rev=1390351&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-mongomk/src/test/resources/logback-test.xml (added)
+++ jackrabbit/oak/trunk/oak-mongomk/src/test/resources/logback-test.xml Wed Sep 26 09:37:18
2012
@@ -0,0 +1,39 @@
+<!--
+   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.
+  -->
+<configuration>
+
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="file" class="ch.qos.logback.core.FileAppender">
+        <file>target/unit-tests.log</file>
+        <encoder>
+            <pattern>%date{HH:mm:ss.SSS} %-5level %-40([%thread] %F:%L) %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <!--
+        <appender-ref ref="console"/>
+        -->
+        <appender-ref ref="file"/>
+    </root>
+
+</configuration>



Mime
View raw message