public void testCreateAterRemoveCheckOldContent() throws Exception
{
ManageableRepository newRepository = null;
try
{
RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
RepositoryEntry repoEntry = helper.createRepositoryEntry(DatabaseStructureType.SINGLE, null, null, true);
try
{
Class
.forName("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");
List<SimpleParameterEntry> cacheParams = new ArrayList<SimpleParameterEntry>();
cacheParams.add(new SimpleParameterEntry("infinispan-configuration",
"conf/standalone/test-infinispan-config.xml"));
CacheEntry cacheEntry = new CacheEntry(cacheParams);
cacheEntry
.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan.ISPNCacheWorkspaceStorageCache");
cacheEntry.setEnabled(true);
List<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())
{
if (ws.getContainer().hasParameter("source-name"))
{
ws.getContainer().addParameter(new SimpleParameterEntry("source-name", newDatasourceName));
}
if (ws.getLockManager().hasParameter("infinispan-cl-cache.jdbc.datasource"))
{
ws.getLockManager().addParameter(new SimpleParameterEntry("infinispan-cl-cache.jdbc.datasource", newDatasourceName));
}
}
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 =