[exo-jcr-commits] exo-jcr SVN: r1178 - in jcr/branches/1.12.0-JBCCACHE: applications and 18 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Dec 25 05:44:27 EST 2009
Author: areshetnyak
Date: 2009-12-25 05:44:26 -0500 (Fri, 25 Dec 2009)
New Revision: 1178
Added:
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/services/
jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/test/java/org/exoplatform/services/jcr/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml
jcr/branches/1.12.0-JBCCACHE/pom.xml
Log:
EXOJCR-330 : Add cluster.test.client and use it. Add functional cluster tests form branche 1.12.0-JBC.
Added: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,68 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>jcr-parent</artifactId>
+ <version>1.12.0-JBCCACHE-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+
+ <name>eXo JCR :: Cluster :: Test Client</name>
+ <description>Cluster test client</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.ext</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.commons</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
Added: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.HttpHeaders;
+
+import org.exoplatform.common.http.client.HTTPConnection;
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.common.http.client.HttpHeaderElement;
+import org.exoplatform.common.http.client.HttpOutputStream;
+import org.exoplatform.common.http.client.ModuleException;
+import org.exoplatform.common.http.client.NVPair;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class JCRWebdavConnection extends HTTPConnection
+{
+ private String realm;
+
+ private String user;
+
+ private String pass;
+
+ private String workspacePath;
+
+ public JCRWebdavConnection(String host, int port, String user, String password, String realm, String workspacePath)
+ {
+ super(host, port);
+
+ this.user = user;
+ this.pass = password;
+ this.realm = realm;
+ this.workspacePath = workspacePath;
+
+ addBasicAuthorization(this.realm, this.user, this.pass);
+ }
+
+ public void addNode(String name, byte[] data) throws IOException, ModuleException
+ {
+ Put(workspacePath + name, data).getStatusCode();
+ }
+
+ public void addNode(String name, String nodeType, byte[] data) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair("File-NodeType", nodeType);
+ Put(workspacePath + name, data).getStatusCode();
+ }
+
+ public HTTPResponse addNode(String name, HttpOutputStream stream) throws IOException, ModuleException
+ {
+ return Put(workspacePath + name, stream);
+ }
+
+ public void removeNode(String name) throws IOException, ModuleException
+ {
+ Delete(workspacePath + name).getStatusCode();
+ }
+
+ /*public void getNode(String name) throws IOException, ModuleException
+ {
+ Get(workspacePath + name).getStatusCode();
+ }*/
+
+ public HTTPResponse getNode(String name) throws IOException, ModuleException
+ {
+ HTTPResponse response = Get(workspacePath + name);
+ response.getStatusCode();
+ return response;
+ }
+
+
+ public void addProperty(String nodeName, String property) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:propertyupdate xmlns:D='DAV:'>" + "<D:set>" + "<D:prop>" + "<"
+ + property + ">value</" + property + ">" + "</D:prop>" + "</D:set>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers).getStatusCode();
+ }
+
+ public void setProperty(String nodeName, String property, String value) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:propertyupdate xmlns:D='DAV:'>" + "<D:set>" + "<D:prop>" + "<"
+ + property + ">" + value + "</" + property + ">" + "</D:prop>" + "</D:set>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ HTTPResponse response = ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers);
+ response.getStatusCode();
+
+ }
+
+ public void removeProperty(String nodeName, String property) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>"
+ + "<D:propertyupdate xmlns:D='DAV:' xmlns:Z='http://www.w3.com/standards/z39.50/'>" + "<D:remove>"
+ + "<D:prop><" + property + "/></D:prop>" + "</D:remove>" + "</D:propertyupdate>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ ExtensionMethod("PROPPATCH", workspacePath + nodeName, xmlBody.getBytes(), headers).getStatusCode();
+ }
+
+ public String lock(String nodeName) throws IOException, ModuleException
+ {
+ String xmlBody =
+ "<?xml version='1.0' encoding='utf-8' ?>" + "<D:lockinfo xmlns:D='DAV:'>" + "<D:lockscope>" + "<D:exclusive/>"
+ + "</D:lockscope>" + "<D:locktype>" + "<D:write/>" + "</D:locktype>" + "<D:owner>owner</D:owner>"
+ + "</D:lockinfo>";
+
+ NVPair[] headers = new NVPair[2];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));
+
+ HTTPResponse response = ExtensionMethod("LOCK", workspacePath + nodeName, xmlBody.getBytes(), headers);
+
+ response.getStatusCode();
+ StringBuffer resp = new StringBuffer(new String(response.getData(), "UTF-8"));
+
+ final String lockPrffix = "opaquelocktoken:";
+
+ int pos = resp.lastIndexOf(lockPrffix);
+
+ String lockToken = resp.substring(pos + lockPrffix.length(), pos + lockPrffix.length() + 32);
+
+ return lockToken;
+ }
+
+ public void unlock(String nodeName, String lockToken) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[3];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+ headers[2] = new NVPair(ExtHttpHeaders.LOCKTOKEN, "<" + lockToken + ">");
+
+ HTTPResponse response = ExtensionMethod("UNLOCK", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void addVersionControl(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ // headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("VERSION-CONTROL", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void checkIn(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("CHECKIN", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void checkOut(String nodeName) throws IOException, ModuleException
+ {
+ NVPair[] headers = new NVPair[1];
+ headers[0] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString("".length()));
+
+ HTTPResponse response = ExtensionMethod("CHECKOUT", workspacePath + nodeName, "".getBytes(), headers);
+ response.getStatusCode();
+ }
+
+ public void addDir(String path) throws IOException, ModuleException
+ {
+ MkCol(workspacePath + path).getStatusCode();
+ }
+
+ public void restore(String node, String version) throws IOException, ModuleException
+ {
+ NVPair[] query = new NVPair[1];
+ query[0] = new NVPair("version", version);
+ Get(workspacePath + node, query).getStatusCode();
+ }
+
+}
\ No newline at end of file
Property changes on: jcr/branches/1.12.0-JBCCACHE/applications/cluster.test.client/src/main/java/org/exoplatform/services/jcr/cluster/JCRWebdavConnection.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml 2009-12-25 09:13:17 UTC (rev 1177)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -167,6 +167,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- TCK binaries and deps for repo stub, some eXo API test -->
<dependency>
<groupId>org.jboss.cache</groupId>
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.common.http.client.CookieModule;
+import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Random;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public abstract class BaseClusteringFunctionalTest extends TestCase
+{
+ protected JCRWebdavConnection connection1;
+
+ protected JCRWebdavConnection connection2;
+
+ protected JCRWebdavConnection connection3;
+
+ protected JCRWebdavConnection connection4;
+
+ private String host = "localhost";
+
+ private int port1 = 8081;//8080;
+
+ private int port2 = 8082;
+
+ private int port3 = 8083;
+
+ private int port4 = 8084;
+
+ private String realm = "eXo REST services";
+
+ private String user = "root";
+
+ private String password = "exo";
+
+ private String workspacePath = "/rest/jcr/repository/production/";
+
+ protected String nodeName;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ CookieModule.setCookiePolicyHandler(null);
+ connection1 = new JCRWebdavConnection(host, port1, user, password, realm, workspacePath);
+ connection2 = new JCRWebdavConnection(host, port2, user, password, realm, workspacePath);
+ connection3 = new JCRWebdavConnection(host, port3, user, password, realm, workspacePath);
+ connection4 = new JCRWebdavConnection(host, port4, user, password, realm, workspacePath);
+
+ nodeName = generateUniqueName("removed_node_over_webdav");
+ }
+
+ public String generateUniqueName(String prefix)
+ {
+ return prefix + "-" + Math.random();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ connection1.removeNode(nodeName);
+ connection1.stop();
+ }
+
+ protected File createBLOBTempFile(String prefix, int sizeInKb) throws IOException
+ {
+ // create test file
+ byte[] data = new byte[1024]; // 1Kb
+
+ File testFile = File.createTempFile(prefix, ".tmp");
+ FileOutputStream tempOut = new FileOutputStream(testFile);
+ Random random = new Random();
+
+ for (int i = 0; i < sizeInKb; i++)
+ {
+ random.nextBytes(data);
+ tempOut.write(data);
+ }
+ tempOut.close();
+ testFile.deleteOnExit(); // delete on test exit
+ return testFile;
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/BaseClusteringFunctionalTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.common.http.client.HttpOutputStream;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Random;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
+ * @version $Id$
+ */
+public class WebdavAddBLOBTest extends BaseClusteringFunctionalTest
+{
+
+ /**
+ * Since blob stored in memory we can not use really big data.
+ */
+ private int sizeInMb = 5;
+
+ public void testAddBLOB() throws Exception
+ {
+ // make a test blob
+ byte[] data = new byte[sizeInMb * 1024 * 1024];
+ Random random = new Random();
+ random.nextBytes(data);
+
+ // add node with blob data
+ HttpOutputStream stream = new HttpOutputStream();
+ HTTPResponse response = connection1.addNode(nodeName, stream);
+ loadStream(stream, new ByteArrayInputStream(data));
+ stream.close();
+ response.getStatusCode();
+
+ // check results
+ // cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ byte[] respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ respData = response.getData();
+ assertEquals(data.length, respData.length);
+ assertTrue(java.util.Arrays.equals(data, respData));
+
+ }
+
+ protected void loadStream(HttpOutputStream stream, InputStream in) throws IOException
+ {
+ byte[] buf = new byte[1024]; // 1Kb
+
+ int readed = 0;
+ while ((readed = in.read(buf)) != -1)
+ {
+ stream.write(buf, 0, readed);
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddBLOBTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class WebdavAddNodeTest extends BaseClusteringFunctionalTest
+{
+
+ public void testAddNode() throws Exception
+ {
+ // add node
+ connection1.addNode(nodeName, "_data_".getBytes());
+
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ assertTrue("_data_".equals(new String(response.getData())));
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(200, response2.getStatusCode());
+ assertTrue("_data_".equals(new String(response2.getData())));
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(200, response3.getStatusCode());
+ assertTrue("_data_".equals(new String(response3.getData())));
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(200, response4.getStatusCode());
+ assertTrue("_data_".equals(new String(response4.getData())));
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavAddNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
+ * @version $Id$
+ */
+public class WebdavMoveNodeTest extends BaseClusteringFunctionalTest
+{
+ public void testMoveNode() throws Exception
+ {
+ String newNodeName = nodeName + "new";
+
+ // add node
+ connection1.addNode(nodeName, "".getBytes());
+ // check is node exist
+ // cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ HTTPResponse response2 = connection2.getNode(nodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ HTTPResponse response3 = connection3.getNode(nodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ HTTPResponse response4 = connection4.getNode(nodeName);
+ assertEquals(200, response4.getStatusCode());
+
+ // move node on cluster-node3
+
+ response = connection3.Move(nodeName, newNodeName);
+ response.getStatusCode();
+
+ // check is node not exist
+ // cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(nodeName);
+ assertEquals(404, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(nodeName);
+ assertEquals(404, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(nodeName);
+ assertEquals(404, response4.getStatusCode());
+
+ // check is node exist
+ // cluster-node1
+ response = connection1.getNode(newNodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // cluster-node2
+ response2 = connection2.getNode(newNodeName);
+ assertEquals(200, response2.getStatusCode());
+
+ // cluster-node3
+ response3 = connection3.getNode(newNodeName);
+ assertEquals(200, response3.getStatusCode());
+
+ // cluster-node4
+ response4 = connection4.getNode(newNodeName);
+ assertEquals(200, response4.getStatusCode());
+ }
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavMoveNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java 2009-12-25 10:44:26 UTC (rev 1178)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.cluster.functional;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.BaseClusteringFunctionalTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class WebdavRemoveNodeTest extends BaseClusteringFunctionalTest
+{
+ public void testRemoveNode() throws Exception
+ {
+ // add test node
+ connection1.addNode(nodeName, "".getBytes());
+
+ // check is exist cluster-node1
+ HTTPResponse response = connection1.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+ //cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(200, response.getStatusCode());
+
+ // remove node on cluster-node2
+ connection2.removeNode(nodeName);
+
+ // check cluster-node1
+ response = connection1.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node2
+ response = connection2.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node3
+ response = connection3.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ // cluster-node4
+ response = connection4.getNode(nodeName);
+ assertEquals(404, response.getStatusCode());
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/functional/WebdavRemoveNodeTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBCCACHE/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/pom.xml 2009-12-25 09:13:17 UTC (rev 1177)
+++ jcr/branches/1.12.0-JBCCACHE/pom.xml 2009-12-25 10:44:26 UTC (rev 1178)
@@ -67,6 +67,7 @@
<module>applications/java/exo.jcr.applications.rest</module>
<module>applications/java/exo.jcr.ear</module>
<module>applications/java/exo.jcr.applications.backupconsole</module>
+ <module>applications/cluster.test.client</module>
<module>packaging/module</module>
</modules>
@@ -178,6 +179,11 @@
<artifactId>exo.jcr.framework.ftpclient</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.jcr</groupId>
+ <artifactId>exo.jcr.component.cluster.test.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.fckeditor</artifactId>
More information about the exo-jcr-commits
mailing list