jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r931484 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: JackrabbitRepositoryStub.java TestContentLoader.java
Date Wed, 07 Apr 2010 09:54:04 GMT
Author: jukka
Date: Wed Apr  7 09:54:03 2010
New Revision: 931484

URL: http://svn.apache.org/viewvc?rev=931484&view=rev
Log:
JCR-2568: extract test content loading from JackrabbitRepositoryStub

Some cleanup

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=931484&r1=931483&r2=931484&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Wed Apr  7 09:54:03 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -24,29 +23,16 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.security.Principal;
 import java.security.acl.Group;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Properties;
-import java.util.Map;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.PropertyType;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-import javax.jcr.nodetype.NodeType;
-import javax.jcr.retention.RetentionPolicy;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
-import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
-import org.apache.jackrabbit.core.retention.RetentionPolicyImpl;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 import org.apache.jackrabbit.test.RepositoryStubException;
@@ -73,11 +59,6 @@ public class JackrabbitRepositoryStub ex
         "org.apache.jackrabbit.repository.home";
 
     /**
-     * The encoding of the test resources.
-     */
-    private static final String ENCODING = "UTF-8";
-
-    /**
      * Repository settings.
      */
     private final Properties settings;
@@ -200,7 +181,7 @@ public class JackrabbitRepositoryStub ex
                 repo = createRepository(dir, xml);
                 Session session = repo.login(superuser);
                 try {
-                    TestContentLoader loader = new TestContentLoader(ENCODING, JackrabbitRepositoryStub.class.getClassLoader());
+                    TestContentLoader loader = new TestContentLoader();
                     loader.loadTestContent(session);
                 } finally {
                     session.logout();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java?rev=931484&r1=931483&r2=931484&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/TestContentLoader.java
Wed Apr  7 09:54:03 2010
@@ -42,17 +42,10 @@ import org.apache.jackrabbit.core.retent
  */
 public class TestContentLoader {
 
-    private String encoding;
-    private ClassLoader classLoader;
-
-    public TestContentLoader(String encoding, ClassLoader classLoader) {
-        this.encoding = encoding;
-        this.classLoader = classLoader;
-    }
-
-    private InputStream getResource(String name) {
-        return classLoader.getResourceAsStream(name);
-    }
+    /**
+     * The encoding of the test resources.
+     */
+    private static final String ENCODING = "UTF-8";
 
     public void loadTestContent(Session session) throws RepositoryException, IOException
{
         JackrabbitWorkspace workspace =
@@ -66,7 +59,8 @@ public class TestContentLoader {
         JackrabbitNodeTypeManager manager =
             (JackrabbitNodeTypeManager) workspace.getNodeTypeManager();
         if (!manager.hasNodeType("test:versionable")) {
-            InputStream xml = getResource("test-nodetypes.xml");
+            InputStream xml =
+                TestContentLoader.class.getResourceAsStream("test-nodetypes.xml");
             try {
                 manager.registerNodeTypes(xml, JackrabbitNodeTypeManager.TEXT_XML);
             } finally {
@@ -156,11 +150,11 @@ public class TestContentLoader {
         Node resource = node.addNode("myResource", "nt:resource");
         // nt:resource not longer referenceable since JCR 2.0
         resource.addMixin("mix:referenceable");
-        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:encoding", ENCODING);
         resource.setProperty("jcr:mimeType", "text/plain");
         resource.setProperty(
                 "jcr:data",
-                new ByteArrayInputStream("Hello w\u00F6rld.".getBytes(encoding)));
+                new ByteArrayInputStream("Hello w\u00F6rld.".getBytes(ENCODING)));
         resource.setProperty("jcr:lastModified", Calendar.getInstance());
 
         Node resReference = getOrAddNode(node, "reference");
@@ -243,7 +237,7 @@ public class TestContentLoader {
         getOrAddNode(node, prefix + "MultiNoBin").setProperty(name, texts);
 
         Node resource = getOrAddNode(node, prefix + "MultiBin");
-        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:encoding", ENCODING);
         resource.setProperty("jcr:mimeType", "text/plain");
         String[] values =
             new String[] { "SGVsbG8gd8O2cmxkLg==", "SGVsbG8gd8O2cmxkLg==" };
@@ -253,9 +247,9 @@ public class TestContentLoader {
         getOrAddNode(node, prefix + "NoBin").setProperty(name,  "text 1");
 
         resource = getOrAddNode(node, "invalidBin");
-        resource.setProperty("jcr:encoding", encoding);
+        resource.setProperty("jcr:encoding", ENCODING);
         resource.setProperty("jcr:mimeType", "text/plain");
-        byte[] bytes = "Hello w\u00F6rld.".getBytes(encoding);
+        byte[] bytes = "Hello w\u00F6rld.".getBytes(ENCODING);
         resource.setProperty(name, new ByteArrayInputStream(bytes));
         resource.setProperty("jcr:lastModified", Calendar.getInstance());
     }



Mime
View raw message