[exo-jcr-commits] exo-jcr SVN: r4635 - in jcr/trunk/exo.jcr.component.ext: src/main/java/org/exoplatform/services/jcr/ext/repository and 8 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jul 15 07:51:25 EDT 2011
Author: tolusha
Date: 2011-07-15 07:51:25 -0400 (Fri, 15 Jul 2011)
New Revision: 4635
Added:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterRdbmsWorkspaceInitializer.java
Removed:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/DummyAction.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/DenyAccessManager.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/TesterRdbmsWorkspaceInitializer.java
Modified:
jcr/trunk/exo.jcr.component.ext/pom.xml
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/AccessContextTest.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/load/TestLoadBackup.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/SessionDataManagerTestWrapper.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-1443: Review tests in jcr-ext project
Modified: jcr/trunk/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/pom.xml 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/pom.xml 2011-07-15 11:51:25 UTC (rev 4635)
@@ -178,20 +178,8 @@
<configuration>
<argLine>${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
<includes>
- <include>**/actions/*Test.java</include>
- <include>**/metadata/*Test.java</include>
- <include>**/owner/*Test.java</include>
- <include>**/registry/*Test.java</include>
- <include>**/app/*Test.java</include>
- <include>**/resource/*Test.java</include>
- <include>**/groovy/*Test.java</include>
- <include>**/replication/*.java</include>
- <include>**/replication/external/*.java</include>
- <include>**/replication/async/**/*.java</include>
- <include>**/backup/load/TestLoadBackup.java</include>
- <include>**/backup/*.java</include>
- <include>**/backup/server/*.java</include>
- <include>**/repository/creation/*.java</include>
+ <include>org/exoplatform/services/jcr/ext/**/Test*.java</include>
+ <include>org/exoplatform/services/jcr/ext/**/*Test.java</include>
</includes>
<excludes>
<exclude>**/BaseStandaloneTest.java</exclude>
@@ -199,12 +187,10 @@
<exclude>**/backup/BaseRDBMSBackupTest.java</exclude>
<exclude>**/backup/TestBackupScheduler.java</exclude>
<exclude>**/backup/TestBackupRestart.java</exclude>
- <exclude>**/replication/*.java</exclude>
- <exclude>**/replication/external/*.java</exclude>
- <exclude>**/replication/external/BaseTestCaseChecker.java</exclude>
- <exclude>**/access/*.java</exclude>
+ <exclude>**/backup/load/TestLoadBackup.java*</exclude>
+ <exclude>**/replication/**</exclude>
<exclude>**/LocalStorageMultithreadTest.java</exclude>
- <include>**/repository/creation/cluster.java</include>
+ <include>**/repository/creation/cluster/**</include>
</excludes>
</configuration>
</plugin>
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryService.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -389,9 +389,14 @@
}
}
- repositoryService.removeRepository(repositoryName);
- repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
- return Response.ok().build();
+ if (repositoryService.canRemoveRepository(repositoryName))
+ {
+ repositoryService.removeRepository(repositoryName);
+ repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
+ return Response.ok().build();
+ }
+ return Response.status(Status.CONFLICT).entity("Can't remove repository " + repositoryName)
+ .cacheControl(NO_CACHE).build();
}
catch (RepositoryException e)
{
@@ -450,7 +455,7 @@
{
repository.removeWorkspace(workspaceName);
repositoryService.getConfig().retain(); // save configuration to persistence (file or persister)
- return Response.noContent().build();
+ return Response.ok().build();
}
return Response.status(Status.CONFLICT).entity(
"Can't remove workspace " + workspaceName + " in repository " + repositoryName).cacheControl(NO_CACHE)
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/DummyAction.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/DummyAction.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/DummyAction.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-package org.exoplatform.services.jcr.ext;
-
-import org.apache.commons.chain.Context;
-import org.exoplatform.services.command.action.Action;
-
-/**
- * Created by The eXo Platform SAS .
- *
- * @author Gennady Azarenkov
- * @version $Id: DummyAction.java 12004 2007-01-17 12:03:57Z geaz $
- */
-
-public class DummyAction implements Action
-{
-
- public boolean execute(Context ctx) throws Exception
- {
- System.out.println("EXECUTE !!! ");
- return false;
- }
-
-}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/AccessContextTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/AccessContextTest.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/AccessContextTest.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -18,28 +18,19 @@
*/
package org.exoplatform.services.jcr.ext.access;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ObjectParameter;
import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
-import org.exoplatform.services.jcr.impl.ext.action.ActionConfiguration;
-import org.exoplatform.services.jcr.impl.ext.action.AddActionsPlugin;
-import org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog;
-import org.exoplatform.services.jcr.impl.ext.action.AddActionsPlugin.ActionsConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
-import javax.jcr.AccessDeniedException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.RepositoryException;
-import javax.jcr.Value;
/**
* @author <a href="mailto:Sergey.Kabashnyuk at gmail.com">Sergey Kabashnyuk</a>
@@ -54,75 +45,6 @@
private final static int THREAD_COUNT = 300;
- @Override
- public void setUp() throws Exception
- {
-
- super.setUp();
- setContextAction();
- }
-
- private void setContextAction()
- {
- SessionActionCatalog catalog =
- (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
- ActionConfiguration ac =
- new ActionConfiguration("org.exoplatform.services.jcr.ext.access.SetAccessControlContextAction",
- "addProperty,changeProperty,removeProperty,read", null, true, null, null);
- List actionsList = new ArrayList();
- ActionsConfig actions = new ActionsConfig();
- actions.setActions(actionsList);
- actionsList.add(ac);
- InitParams params = new InitParams();
- ObjectParameter op = new ObjectParameter();
- op.setObject(actions);
- op.setName("actions");
- params.addParameter(op);
-
- AddActionsPlugin aap = new AddActionsPlugin(params);
- catalog.clear();
- catalog.addPlugin(aap);
- };
-
- public void testSetAccessContext() throws RepositoryException
- {
- setContextAction();
- Node testNode = root.addNode("test");
- session.save();
- testNode.setProperty("p1", 9);
- assertEquals(9, testNode.getProperty("p1").getValue().getLong());
-
- testNode.setProperty("p1", 10);
- session.save();
- testNode.setProperty("p1", (Value)null);
- session.save();
- }
-
- public void testDenyAccessMenager() throws RepositoryException
- {
- Node tNode = root.addNode("testNode");
- tNode.setProperty("deny", "value");
- session.save();
- try
- {
- tNode.getProperty("deny");
- fail("AccessDeniedException scheduled to be");
- }
- catch (AccessDeniedException e)
- {
- // Ok
- }
- SessionImpl sysSession = repository.getSystemSession();
- try
- {
- sysSession.getRootNode().getNode("testNode").getProperty("deny");
- }
- catch (AccessDeniedException e)
- {
- fail("AccessDeniedException ");
- }
- }
-
public void testAccessMenedgerContextMultiThread() throws RepositoryException, InterruptedException
{
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/DenyAccessManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/DenyAccessManager.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/access/DenyAccessManager.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -1,80 +0,0 @@
-/*
- * 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.
- */
-package org.exoplatform.services.jcr.ext.access;
-
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.access.AccessManager;
-import org.exoplatform.services.jcr.access.SystemIdentity;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.core.ItemImpl;
-import org.exoplatform.services.jcr.observation.ExtendedEvent;
-import org.exoplatform.services.security.Identity;
-
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="mailto:Sergey.Kabashnyuk at gmail.com">Sergey Kabashnyuk</a>
- * @version $Id: DenyAccessManager.java 14111 2008-05-12 15:04:28Z gazarenkov $
- */
-public class DenyAccessManager extends AccessManager
-{
- private String denyName = "";
-
- public DenyAccessManager(RepositoryEntry config, WorkspaceEntry wsConfig) throws RepositoryException,
- RepositoryConfigurationException
- {
- super(config, wsConfig);
- this.denyName = wsConfig.getAccessManager().getParameterValue("name");
-
- if (log.isDebugEnabled())
- log.debug("DenyAccessManager created");
- }
-
- @Override
- public boolean hasPermission(AccessControlList acl, String[] permission, Identity user)
- {
- if (super.hasPermission(acl, permission, user))
- {
- if (user.getUserId().equals("root") || user.getUserId().equals(SystemIdentity.SYSTEM)
- || user.getUserId().equals("admin"))
- return true;
-
- if (context() != null)
- {
- int ivent = ((Integer)context().get("event")).intValue();
- if (ivent == ExtendedEvent.READ)
- {
- ItemImpl curItem = (ItemImpl)context().get("currentItem");
-
- if (curItem != null && curItem.getInternalName().getAsString().indexOf(denyName) > -1)
- {
- if (log.isDebugEnabled())
- log.debug("DenyAccessManager permission deny by rool name='" + denyName + "'");
- return false;
- }
- }
- }
- else
- log.warn("Context = null");
- }
- return false;
- }
-}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestRdbmsWorkspaceInitializer.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -24,11 +24,11 @@
import org.exoplatform.services.jcr.ext.backup.impl.rdbms.FullBackupJob;
import org.exoplatform.services.jcr.ext.backup.impl.rdbms.RdbmsWorkspaceInitializer;
import org.exoplatform.services.jcr.impl.core.SysViewWorkspaceInitializer;
-import org.exoplatform.services.jcr.impl.core.TesterRdbmsWorkspaceInitializer;
import org.exoplatform.services.jcr.impl.core.query.SystemSearchManager;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
+import org.exoplatform.services.jcr.util.TesterRdbmsWorkspaceInitializer;
import java.io.File;
import java.net.URL;
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/load/TestLoadBackup.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/load/TestLoadBackup.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/load/TestLoadBackup.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -141,12 +141,9 @@
Thread.sleep(10 * 1000);
- System.out.println(" ============ BACKUP START ============");
-
// backup
File backDir = new File("target/backup/ws1");
backDir.mkdirs();
- BackupChain bch = null;
backupManagerImpl.start();
@@ -156,10 +153,8 @@
config.setBackupType(BACKUP_TYPE);
config.setBackupDir(backDir);
- backupManagerImpl.startBackup(config);
+ BackupChain bch = backupManagerImpl.startBackup(config);
- bch = backupManagerImpl.findBackup(REPOSITORY_NAME_SINGLE_DB, WORKSPACE_NAME);
-
// wait till full backup will be stopped
while (bch.getFullBackupState() != BackupJob.FINISHED)
{
@@ -167,18 +162,11 @@
Thread.sleep(30);
}
- System.out.println(" ============ FULL BACKUP FINISHED ============");
-
if (BACKUP_TYPE == BackupManager.FULL_AND_INCREMENTAL)
{
Thread.sleep(5 * 1000);
}
- // for (Thread thread : threads)
- // {
- // thread.interrupt();
- // }
-
if (BACKUP_TYPE == BackupManager.FULL_AND_INCREMENTAL)
{
Thread.sleep(5 * 1000);
@@ -195,8 +183,6 @@
}
Thread.sleep(10 * 1000);
- System.out.println(" ============ BACKUP FINISHED ============");
-
// restore
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back", "jdbcjcr_to_repository_restore_singel_db");
@@ -205,8 +191,6 @@
{
BackupChainLog bchLog = new BackupChainLog(backLog);
- System.out.println(" ============ RESTORE START ============");
-
assertNotNull(bchLog.getStartedTime());
assertNotNull(bchLog.getFinishedTime());
@@ -233,8 +217,6 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- System.out.println(" ============ CHECKING INTEGRITY ============");
-
checkIntegrity((NodeImpl)repositoryService.getRepository(REPOSITORY_NAME_SINGLE_DB).login(credentials, "ws1back")
.getRootNode());
}
@@ -276,7 +258,6 @@
// backup
File backDir = new File("target/backup/ws1");
backDir.mkdirs();
- BackupChain bch = null;
backupManagerImpl.start();
@@ -288,12 +269,9 @@
Thread.sleep(5 * 1000);
- System.out.println(" ============ BACKUP START ============");
- backupManagerImpl.startBackup(config);
+ BackupChain bch = backupManagerImpl.startBackup(config);
- bch = backupManagerImpl.findBackup(REPOSITORY_NAME_SINGLE_DB, WORKSPACE_NAME);
-
// wait till full backup will be stopped
while (bch.getFullBackupState() != BackupJob.FINISHED)
{
@@ -310,16 +288,12 @@
fail("Can't get fullBackup chain");
}
- System.out.println(" ============ BACKUP FINISHED ============");
-
// restore
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
{
BackupChainLog bchLog = new BackupChainLog(backLog);
- System.out.println(" ============ RESTORE START ============");
-
assertNotNull(bchLog.getStartedTime());
assertNotNull(bchLog.getFinishedTime());
@@ -346,8 +320,6 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- System.out.println(" ============ CHECKING INTEGRITY ============");
-
checkIntegrity((NodeImpl)repositoryService.getRepository(REPOSITORY_NAME_SINGLE_DB)
.login(credentials, WORKSPACE_NAME)
.getRootNode());
@@ -380,7 +352,6 @@
// backup
File backDir = new File("target/backup/db7");
backDir.mkdirs();
- RepositoryBackupChain bch = null;
backupManagerImpl.start();
@@ -391,12 +362,8 @@
Thread.sleep(5 * 1000);
- System.out.println(" ============ BACKUP START ============");
+ RepositoryBackupChain bch = backupManagerImpl.startBackup(config);
- backupManagerImpl.startBackup(config);
-
- bch = backupManagerImpl.findRepositoryBackup(REPOSITORY_NAME_SINGLE_DB);
-
// wait till full backup will be stopped
while (bch.getState() != BackupJob.FINISHED)
{
@@ -409,16 +376,12 @@
backupManagerImpl.stopBackup(bch);
}
- System.out.println(" ============ BACKUP FINISHED ============");
-
// restore
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
{
RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
- System.out.println(" ============ RESTORE START ============");
-
assertNotNull(bchLog.getStartedTime());
assertNotNull(bchLog.getFinishedTime());
@@ -446,8 +409,6 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- System.out.println(" ============ CHECKING INTEGRITY ============");
-
for (String wsName : repositoryService.getRepository(REPOSITORY_NAME_SINGLE_DB).getWorkspaceNames())
{
checkIntegrity((NodeImpl)repositoryService.getRepository(REPOSITORY_NAME_SINGLE_DB).login(credentials, wsName)
@@ -492,7 +453,6 @@
// backup
File backDir = new File("target/backup/ws1");
backDir.mkdirs();
- BackupChain bch = null;
backupManagerImpl.start();
@@ -504,12 +464,8 @@
Thread.sleep(5 * 1000);
- System.out.println(" ============ BACKUP START ============");
+ BackupChain bch = backupManagerImpl.startBackup(config);
- backupManagerImpl.startBackup(config);
-
- bch = backupManagerImpl.findBackup(REPOSITORY_NAME_MULTI_DB, WORKSPACE_NAME);
-
// wait till full backup will be stopped
while (bch.getFullBackupState() != BackupJob.FINISHED)
{
@@ -526,16 +482,12 @@
fail("Can't get fullBackup chain");
}
- System.out.println(" ============ BACKUP FINISHED ============");
-
// restore
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
{
BackupChainLog bchLog = new BackupChainLog(backLog);
- System.out.println(" ============ RESTORE START ============");
-
assertNotNull(bchLog.getStartedTime());
assertNotNull(bchLog.getFinishedTime());
@@ -562,8 +514,6 @@
fail("There are no backup files in " + backDir.getAbsolutePath());
}
- System.out.println(" ============ CHECKING INTEGRITY ============");
-
checkIntegrity((NodeImpl)repositoryService.getRepository(REPOSITORY_NAME_MULTI_DB)
.login(credentials, WORKSPACE_NAME)
.getRootNode());
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/RestRepositoryServiceTest.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -18,29 +18,19 @@
*/
package org.exoplatform.services.jcr.ext.repository;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.jcr.NoSuchWorkspaceException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.ws.rs.core.MultivaluedMap;
-
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.CredentialsImpl;
+import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
import org.exoplatform.services.jcr.ext.app.SessionProviderService;
import org.exoplatform.services.jcr.ext.app.ThreadLocalSessionProviderService;
import org.exoplatform.services.jcr.ext.backup.ContainerRequestUserRole;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
+import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
import org.exoplatform.services.rest.RequestHandler;
import org.exoplatform.services.rest.impl.ContainerResponse;
import org.exoplatform.services.rest.impl.InputHeadersMap;
@@ -56,6 +46,18 @@
import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
import org.exoplatform.ws.frameworks.json.value.JsonValue;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.ws.rs.core.MultivaluedMap;
+
/**
* Created by The eXo Platform SAS.
*
@@ -69,6 +71,8 @@
{
private String REST_REPOSITORY_SERVICE_PATH = RestRepositoryService.Constants.BASE_URL;
+ protected TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
+
private RequestHandler handler;
public void setUp() throws Exception
@@ -337,7 +341,7 @@
cres = new ContainerResponse(responseWriter);
handler.handleRequest(creq, cres);
- assertEquals(204, cres.getStatus());
+ assertEquals(200, cres.getStatus());
try
{
@@ -352,8 +356,10 @@
public void testRemoveRepository() throws Exception
{
- String wsName = "ws";
- String repoName = "db2";
+ ManageableRepository repository = helper.createRepository(container, true, null);
+
+ String wsName = repository.getConfiguration().getSystemWorkspaceName();
+ String repoName = repository.getConfiguration().getName();
Session session =
repositoryService.getRepository(repoName).login(new CredentialsImpl("root", "exo".toCharArray()), wsName);
@@ -363,7 +369,7 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
- new ContainerRequestUserRole("POST", new URI(REST_REPOSITORY_SERVICE_PATH
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ RestRepositoryService.Constants.OperationType.REMOVE_REPOSITORY + "/" + repoName + "/false/"),
new URI(""), null, new InputHeadersMap(headers));
@@ -375,7 +381,7 @@
//remove with prepare close sessions
creq =
- new ContainerRequestUserRole("POST", new URI(REST_REPOSITORY_SERVICE_PATH
+ new ContainerRequestUserRole("GET", new URI(REST_REPOSITORY_SERVICE_PATH
+ RestRepositoryService.Constants.OperationType.REMOVE_REPOSITORY + "/" + repoName + "/true/"),
new URI(""), null, new InputHeadersMap(headers));
@@ -383,7 +389,7 @@
cres = new ContainerResponse(responseWriter);
handler.handleRequest(creq, cres);
- assertEquals(204, cres.getStatus());
+ assertEquals(200, cres.getStatus());
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/SessionDataManagerTestWrapper.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/SessionDataManagerTestWrapper.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/SessionDataManagerTestWrapper.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.dataflow.session.SessionChangesLog;
/**
Deleted: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/TesterRdbmsWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/TesterRdbmsWorkspaceInitializer.java 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/impl/core/TesterRdbmsWorkspaceInitializer.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-package org.exoplatform.services.jcr.impl.core;
-
-import org.exoplatform.services.jcr.RepositoryService;
-import org.exoplatform.services.jcr.access.AccessManager;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.ext.backup.impl.rdbms.RdbmsWorkspaceInitializer;
-import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
-import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
-import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 04.12.2006
- *
- * For testing purpose
- *
- * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id: SessionDataManagerTestWrapper.java 11907 2008-03-13 15:36:21Z ksm $
- */
-public class TesterRdbmsWorkspaceInitializer extends RdbmsWorkspaceInitializer
-{
-
- public TesterRdbmsWorkspaceInitializer(WorkspaceEntry config, RepositoryEntry repConfig,
- CacheableWorkspaceDataManager dataManager, NamespaceRegistryImpl namespaceRegistry,
- LocationFactory locationFactory, NodeTypeManagerImpl nodeTypeManager, ValueFactoryImpl valueFactory,
- AccessManager accessManager, RepositoryService repositoryService, FileCleanerHolder cleanerHolder)
- throws RepositoryConfigurationException,
- PathNotFoundException, RepositoryException
- {
- super(config, repConfig, dataManager, namespaceRegistry, locationFactory, nodeTypeManager, valueFactory,
- accessManager, repositoryService, cleanerHolder);
- }
-
- @Override
- public void fullRdbmsRestore() throws RepositoryException
- {
- super.fullRdbmsRestore();
- }
-
-}
Added: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterRdbmsWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterRdbmsWorkspaceInitializer.java (rev 0)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterRdbmsWorkspaceInitializer.java 2011-07-15 11:51:25 UTC (rev 4635)
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+package org.exoplatform.services.jcr.util;
+
+import org.exoplatform.services.jcr.RepositoryService;
+import org.exoplatform.services.jcr.access.AccessManager;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.ext.backup.impl.rdbms.RdbmsWorkspaceInitializer;
+import org.exoplatform.services.jcr.impl.core.LocationFactory;
+import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
+import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 04.12.2006
+ *
+ * For testing purpose
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id: SessionDataManagerTestWrapper.java 11907 2008-03-13 15:36:21Z ksm $
+ */
+public class TesterRdbmsWorkspaceInitializer extends RdbmsWorkspaceInitializer
+{
+
+ public TesterRdbmsWorkspaceInitializer(WorkspaceEntry config, RepositoryEntry repConfig,
+ CacheableWorkspaceDataManager dataManager, NamespaceRegistryImpl namespaceRegistry,
+ LocationFactory locationFactory, NodeTypeManagerImpl nodeTypeManager, ValueFactoryImpl valueFactory,
+ AccessManager accessManager, RepositoryService repositoryService, FileCleanerHolder cleanerHolder)
+ throws RepositoryConfigurationException,
+ PathNotFoundException, RepositoryException
+ {
+ super(config, repConfig, dataManager, namespaceRegistry, locationFactory, nodeTypeManager, valueFactory,
+ accessManager, repositoryService, cleanerHolder);
+ }
+
+ @Override
+ public void fullRdbmsRestore() throws RepositoryException
+ {
+ super.fullRdbmsRestore();
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-07-15 08:14:35 UTC (rev 4634)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-07-15 11:51:25 UTC (rev 4635)
@@ -409,33 +409,9 @@
<object type="org.exoplatform.services.jcr.impl.ext.action.AddActionsPlugin$ActionsConfig">
<field name="actions">
<collection type="java.util.ArrayList">
- <!-- an example
<value>
<object type="org.exoplatform.services.jcr.impl.ext.action.ActionConfiguration">
<field name="eventTypes">
- <string>addNode</string>
- </field>
- <field name="path">
- <string>/test</string>
- </field>
- <field name="isDeep">
- <boolean>true</boolean>
- </field>
- <field name="nodeTypes">
- <string>nt:unstructured</string>
- </field>
- <field name="workspace">
- <string>production</string>
- </field>
- <field name="actionClassName">
- <string>org.exoplatform.services.jcr.ext.DummyAction</string>
- </field>
- </object>
- </value>
- -->
- <value>
- <object type="org.exoplatform.services.jcr.impl.ext.action.ActionConfiguration">
- <field name="eventTypes">
<string>addProperty,changeProperty</string>
</field>
<field name="path">
More information about the exo-jcr-commits
mailing list