camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7102 Fixed the broken JUnit classes for testing authentication in camel-jcr with thanks to Gregor
Date Thu, 02 Jan 2014 03:48:31 GMT
CAMEL-7102 Fixed the broken JUnit classes for testing authentication in camel-jcr with thanks
to Gregor


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/68fc1ac8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/68fc1ac8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/68fc1ac8

Branch: refs/heads/master
Commit: 68fc1ac87e4cb5be8b3192b16ec2dd03e038de0a
Parents: 99c4af4
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Jan 2 11:44:52 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Jan 2 11:44:52 2014 +0800

----------------------------------------------------------------------
 components/camel-jcr/pom.xml                       | 11 +++++++++++
 .../component/jcr/AuthTokenLoginFailureTest.java   |  2 --
 .../camel/component/jcr/JcrAuthTestBase.java       | 17 ++++++++---------
 .../component/jcr/JcrAuthTokenWithLoginTest.java   |  5 +++--
 .../camel/component/jcr/JcrRouteTestSupport.java   |  1 +
 5 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/68fc1ac8/components/camel-jcr/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jcr/pom.xml b/components/camel-jcr/pom.xml
index 13a54c9..327f714 100644
--- a/components/camel-jcr/pom.xml
+++ b/components/camel-jcr/pom.xml
@@ -80,4 +80,15 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+     <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <forkMode>pertest</forkMode>
+        </configuration>
+     </plugin>
+    </plugins>
+  </build>
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/68fc1ac8/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/AuthTokenLoginFailureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/AuthTokenLoginFailureTest.java
b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/AuthTokenLoginFailureTest.java
index 406bf2c..7309510 100644
--- a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/AuthTokenLoginFailureTest.java
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/AuthTokenLoginFailureTest.java
@@ -22,13 +22,11 @@ import javax.jcr.SimpleCredentials;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class AuthTokenLoginFailureTest extends JcrAuthTestBase {
 
     @Test
-    @Ignore("Fails with some error")
     public void testCreateNodeWithAuthentication() throws Exception {
         Exchange exchange = createExchangeWithBody("<message>hello!</message>");
         Exchange out = template.send("direct:a", exchange);

http://git-wip-us.apache.org/repos/asf/camel/blob/68fc1ac8/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTestBase.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTestBase.java
b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTestBase.java
index 2389455..42c721a 100644
--- a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTestBase.java
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTestBase.java
@@ -47,7 +47,7 @@ public abstract class JcrAuthTestBase extends CamelTestSupport {
     @Override
     @Before
     public void setUp() throws Exception {
-        deleteDirectory("target/repository");
+        deleteDirectory("target/repository_with_auth");
         super.setUp();
     }
 
@@ -71,20 +71,19 @@ public abstract class JcrAuthTestBase extends CamelTestSupport {
             user = userManager.createUser("test", "quatloos");
         }
         // set up permissions
-        String permissionsPath = session.getRootNode().getPath();
+        String path = session.getRootNode().getPath();
         AccessControlManager accessControlManager = session
                 .getAccessControlManager();
         AccessControlPolicyIterator acls = accessControlManager
-                .getApplicablePolicies(permissionsPath);
+                .getApplicablePolicies(path);
+        AccessControlList acl = null;
         if (acls.hasNext()) {
-            AccessControlList acl = (AccessControlList) acls.nextAccessControlPolicy();
-            acl.addAccessControlEntry(user.getPrincipal(), accessControlManager
-                    .getSupportedPrivileges(permissionsPath));
-            accessControlManager.setPolicy(permissionsPath, acl);
+            acl = (AccessControlList) acls.nextAccessControlPolicy();
         } else {
-            throw new Exception("could not set access control for path "
-                    + permissionsPath);
+            acl = (AccessControlList) accessControlManager.getPolicies(path)[0];
         }
+        acl.addAccessControlEntry(user.getPrincipal(), accessControlManager.getSupportedPrivileges(path));
+        accessControlManager.setPolicy(path, acl);
 
         session.save();
         session.logout();

http://git-wip-us.apache.org/repos/asf/camel/blob/68fc1ac8/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTokenWithLoginTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTokenWithLoginTest.java
b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTokenWithLoginTest.java
index e1dee1a..0d2aa77 100644
--- a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTokenWithLoginTest.java
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrAuthTokenWithLoginTest.java
@@ -16,21 +16,22 @@
  */
 package org.apache.camel.component.jcr;
 
+import javax.jcr.LoginException;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JcrAuthTokenWithLoginTest extends JcrAuthTestBase {
 
     @Test
-    @Ignore("Fails with some error")
     public void testCreateNodeWithAuthentication() throws Exception {
         Exchange exchange = createExchangeWithBody("<message>hello!</message>");
         Exchange out = template.send("direct:a", exchange);
         assertNotNull(out);
         String uuid = out.getOut().getBody(String.class);
         assertNull("Expected body to be null, found JCR node UUID", uuid);
+        assertTrue("Wrong exception type", out.getException() instanceof LoginException);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/68fc1ac8/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTestSupport.java
b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTestSupport.java
index f9fbfe6..be22df0 100644
--- a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTestSupport.java
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTestSupport.java
@@ -38,6 +38,7 @@ public abstract class JcrRouteTestSupport extends CamelTestSupport {
     @Override
     @Before
     public void setUp() throws Exception {
+        deleteDirectory("target/repository_with_auth");
         deleteDirectory("target/repository");
         super.setUp();
     }


Mime
View raw message