jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r761665 - in /jackrabbit/commons/jcr-rmi/trunk/it/src/test: java/org/apache/jackrabbit/rmi/it/RepositoryServer.java java/org/apache/jackrabbit/rmi/it/RepositoryTest.java resources/log4j.properties
Date Fri, 03 Apr 2009 13:16:32 GMT
Author: jukka
Date: Fri Apr  3 13:16:31 2009
New Revision: 761665

URL: http://svn.apache.org/viewvc?rev=761665&view=rev
Log:
JCRRMI-14: Integration tests for JCR-RMI

Basic smoke tests.

Added:
    jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java
  (with props)
    jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java
  (with props)
    jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties   (with props)

Added: jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java?rev=761665&view=auto
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java
(added)
+++ jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java
Fri Apr  3 13:16:31 2009
@@ -0,0 +1,91 @@
+/*
+ * 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.rmi.it;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.server.RemoteObject;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitServerAdapterFactory;
+import org.apache.jackrabbit.rmi.remote.RemoteRepository;
+import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+
+public class RepositoryServer {
+
+    private static RepositoryImpl server;
+
+    private static RemoteRepository remote;
+
+    private static Repository client;
+
+    public static Repository getRepositoryServer() {
+        return server;
+    }
+
+    public static Repository getRepositoryClient() {
+        return client;
+    }
+
+    @BeforeSuite
+    public static void startRepositoryServer() throws Exception {
+        InputStream xml =
+            RepositoryImpl.class.getResourceAsStream("repository.xml");
+        try {
+            RepositoryConfig config = RepositoryConfig.create(
+                    xml, new File("target", "repository").getPath());
+            server = RepositoryImpl.create(config);
+
+            RemoteAdapterFactory raf = new JackrabbitServerAdapterFactory();
+            remote = raf.getRemoteRepository(server);
+
+            // Make sure that the remote reference survives serialization
+            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(buffer);
+            oos.writeObject(RemoteObject.toStub(remote));
+            oos.close();
+
+            ObjectInputStream ois = new ObjectInputStream(
+                    new ByteArrayInputStream(buffer.toByteArray()));
+            LocalAdapterFactory laf = new JackrabbitClientAdapterFactory();
+            client = laf.getRepository((RemoteRepository) ois.readObject());
+            ois.close();
+        } finally {
+            xml.close();
+        }
+    }
+
+    @AfterSuite
+    public static void stopRepositoryServer() {
+        client = null;
+        remote = null;
+        server.shutdown();
+        server = null;
+    }
+
+}

Propchange: jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java?rev=761665&view=auto
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java
(added)
+++ jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java
Fri Apr  3 13:16:31 2009
@@ -0,0 +1,56 @@
+/*
+ * 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.rmi.it;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Simple remote repository access tests.
+ */
+public class RepositoryTest {
+
+    @Test
+    public void testRepositoryDescriptors() {
+        Repository server = RepositoryServer.getRepositoryServer();
+        Repository client = RepositoryServer.getRepositoryClient();
+
+        String[] keys = client.getDescriptorKeys();
+        Assert.assertTrue(keys != null && keys.length > 0);
+        for (int i = 0; i < keys.length; i++) {
+            Assert.assertEquals(
+                    client.getDescriptor(keys[i]),
+                    server.getDescriptor(keys[i]));
+        }
+    }
+
+    @Test
+    public void testSimpleLoginLogout() throws RepositoryException {
+        Repository repository = RepositoryServer.getRepositoryClient();
+        Session session = repository.login();
+        try {
+            Assert.assertEquals(session.getRootNode().getPath(), "/");
+        } finally {
+            session.logout();
+        }
+    }
+
+}

Propchange: jackrabbit/commons/jcr-rmi/trunk/it/src/test/java/org/apache/jackrabbit/rmi/it/RepositoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties?rev=761665&view=auto
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties (added)
+++ jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties Fri Apr  3 13:16:31
2009
@@ -0,0 +1,25 @@
+#  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.
+
+# Set root logger level to DEBUG and its only appender to file.
+log4j.rootLogger=INFO, file
+
+# 'file' is set to be a FileAppender.
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=target/jcr.log
+
+# 'file' uses PatternLayout.
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m
(%F, line %L)\n

Propchange: jackrabbit/commons/jcr-rmi/trunk/it/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message