public void testCreateAterRemoveCheckOldContent() throws Exception
{
ManageableRepository newRepository = null;
try
{
RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, null, true);
try
{
Class
.forName("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");
ArrayList cacheParams = new ArrayList();
cacheParams.add(new SimpleParameterEntry("infinispan-configuration",
"conf/standalone/cluster/test-infinispan-config.xml"));
cacheParams.add(new SimpleParameterEntry("jgroups-configuration", "conf/udp-mux-v3.xml"));
cacheParams.add(new SimpleParameterEntry("infinispan-cluster-name", "JCR-cluster-Test"));
cacheParams.add(new SimpleParameterEntry("use-distributed-cache", "false"));
CacheEntry cacheEntry = new CacheEntry(cacheParams);
cacheEntry
.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");
cacheEntry.setEnabled(true);
ArrayList<WorkspaceEntry> wsList = repoEntry.getWorkspaceEntries();
wsList.get(0).setCache(cacheEntry);
repoEntry.setWorkspaceEntries(wsList);
}
catch (ClassNotFoundException e)
{
}
service.createRepository(repoEntry);
service.getConfig().retain();
ManageableRepository repository = service.getRepository(repoEntry.getName());
// add content
Session session =
repository.login(new CredentialsImpl("admin", "admin".toCharArray()), repository.getConfiguration()
.getSystemWorkspaceName());
session.getRootNode().addNode("test");
session.save();
session.logout();
// copy repository configuration
RepositoryEntry repositoryEntry = helper.copyRepositoryEntry(repository.getConfiguration());
String newDatasourceName = helper.createDatasource();
for (WorkspaceEntry ws : repositoryEntry.getWorkspaceEntries())
{
List<SimpleParameterEntry> parameters = ws.getContainer().getParameters();
for (int i = 0; i <= parameters.size(); i++)
{
SimpleParameterEntry spe = parameters.get(i);
if (spe.getName().equals("source-name"))
{
parameters.add(i, new SimpleParameterEntry(spe.getName(), newDatasourceName));
break;
}
}
}
service.removeRepository(repository.getConfiguration().getName());
try
{
service.getRepository(repository.getConfiguration().getName());
fail();
}
catch (Exception e)
{
}
// create new repository
service.createRepository(repositoryEntry);
service.getConfig().retain();
newRepository = service.getRepository(repositoryEntry.getName());
Session newSession = null;
try
{
newSession =