mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Merged V2.9 to HEAD
9543: Merged V2.2 to V2.9 9338: Restructure AVM tests 9348: AVM - add expected "compare" diffs to existing unit tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
fd3a6d6e97
commit
10240e71f4
@ -61,5 +61,39 @@
|
||||
<property name="refreshStubOnConnectFailure">
|
||||
<value>true</value>
|
||||
</property>
|
||||
</bean>
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- NameMatcher beans for filtering what shows up as different in compares. -->
|
||||
<bean id="excludeRegexMatcher" class="org.alfresco.util.RegexNameMatcher">
|
||||
<property name="patterns">
|
||||
<!--
|
||||
NOTE: Regexes are implicitly anchored with ^ and $ in this context.
|
||||
-->
|
||||
<list>
|
||||
<value>.*/#[^/]*</value> <!-- A leaf starting with '#' -->
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="excludeExtensionMatcher" class="org.alfresco.repo.avm.util.FileExtensionNameMatcher">
|
||||
<property name="extensions">
|
||||
<list>
|
||||
<value>.o</value>
|
||||
<value>.bak</value>
|
||||
<value>.tmp</value>
|
||||
<value>~</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="globalPathExcluder" class="org.alfresco.util.OrCompositeNameMatcher">
|
||||
<property name="matchers">
|
||||
<list>
|
||||
<ref bean="excludeExtensionMatcher"/>
|
||||
<ref bean="excludeRegexMatcher"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
170
source/java/org/alfresco/repo/avm/AVMServiceIndexTest.java
Normal file
170
source/java/org/alfresco/repo/avm/AVMServiceIndexTest.java
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.search.IndexMode;
|
||||
import org.alfresco.repo.search.Indexer;
|
||||
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
|
||||
/**
|
||||
* Test AVMService indexing
|
||||
*/
|
||||
public class AVMServiceIndexTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test async indexing.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAsyncIndex() throws Exception
|
||||
{
|
||||
// Make sure the slate is clean ...
|
||||
UserTransaction tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
if (fService.getStore("avmAsynchronousTest") != null)
|
||||
{
|
||||
assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
assertFalse(fIndexingInterceptor.hasIndexBeenCreated("bananaStoreWoof"));
|
||||
}
|
||||
else
|
||||
{
|
||||
assertFalse(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
}
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef("avmAsynchronousTest");
|
||||
Indexer indexer = fIndexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.deleteIndex("avmAsynchronousTest", IndexMode.SYNCHRONOUS);
|
||||
}
|
||||
tx.commit();
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("bananaStoreWoof"));
|
||||
assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
// TODO: Suspend and resume indexing in case we are really unlucky and hit an index before we expect it.
|
||||
|
||||
SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
|
||||
ResultSet results;
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
assertFalse(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
|
||||
assertEquals(IndexMode.ASYNCHRONOUS, fIndexingInterceptor.getIndexMode("avmAsynchronousTest"));
|
||||
assertEquals(IndexMode.SYNCHRONOUS, fIndexingInterceptor.getIndexMode("main"));
|
||||
assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 0));
|
||||
assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 1));
|
||||
assertFalse(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 2));
|
||||
tx.commit();
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
Thread.sleep(180000);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(4, results.length());
|
||||
results.close();
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
Thread.sleep(180000);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(4, results.length());
|
||||
results.close();
|
||||
}
|
||||
}
|
843
source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java
Normal file
843
source/java/org/alfresco/repo/avm/AVMServiceLocalTest.java
Normal file
@ -0,0 +1,843 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.repo.avm.util.RemoteBulkLoader;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Local unit tests of AVM (AVMSyncService & AVMService)
|
||||
*/
|
||||
public class AVMServiceLocalTest extends TestCase
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(AVMServiceLocalTest.class);
|
||||
|
||||
/**
|
||||
* The AVMRemote - can be local (AVMRemoteLocal) or remote (AVMRemote)
|
||||
*/
|
||||
protected static AVMRemote fService;
|
||||
|
||||
/**
|
||||
* The AVMSyncService - can be local (AVMSyncService) or remote (AVMSyncServiceRemote)
|
||||
*/
|
||||
protected static AVMSyncService fSyncService;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
*/
|
||||
protected static FileSystemXmlApplicationContext fContext;
|
||||
|
||||
protected static NameMatcher excluder;
|
||||
|
||||
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
if (fContext == null)
|
||||
{
|
||||
// local (embedded) test setup
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/application-context.xml");
|
||||
fService = (AVMRemote)fContext.getBean("avmRemote");
|
||||
fSyncService = (AVMSyncService)fContext.getBean("AVMSyncService");
|
||||
excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
|
||||
|
||||
AuthenticationService authService = (AuthenticationService)fContext.getBean("AuthenticationService");
|
||||
authService.authenticate("admin", "admin".toCharArray());
|
||||
}
|
||||
|
||||
if (fService.getStore("main") == null)
|
||||
{
|
||||
fService.createStore("main");
|
||||
}
|
||||
if (fService.getStore("layer") == null)
|
||||
{
|
||||
fService.createStore("layer");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
fService.purgeStore("main");
|
||||
fService.purgeStore("layer");
|
||||
}
|
||||
|
||||
public void testGetAPath() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createStore("test2932");
|
||||
fService.createDirectory("test2932:/", "a");
|
||||
fService.createFile("test2932:/a", "foo.txt").close();
|
||||
AVMNodeDescriptor found = fService.lookup(-1, "test2932:/a/foo.txt");
|
||||
Pair<Integer, String> path = fService.getAPath(found);
|
||||
assertEquals(path.getSecond(), "test2932:/a/foo.txt");
|
||||
explorePaths("test2932:/");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("test2932");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a simple hello world test.
|
||||
*/
|
||||
public void testSimple()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = fService.getStores();
|
||||
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
if (logger.isDebugEnabled()) { logger.debug(store); }
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
protected void explorePaths(String path) throws Exception
|
||||
{
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(-1, path);
|
||||
for (Map.Entry<String, AVMNodeDescriptor> entry : listing.entrySet())
|
||||
{
|
||||
Pair<Integer, String> childPath = fService.getAPath(entry.getValue());
|
||||
if (logger.isDebugEnabled()) { logger.debug(childPath); }
|
||||
if (entry.getValue().isDirectory())
|
||||
{
|
||||
explorePaths(entry.getValue().getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reading and writing.
|
||||
*/
|
||||
public void testReadWrite()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create a test store.
|
||||
fService.createStore("test2933");
|
||||
// Create a directory.
|
||||
fService.createDirectory("test2933:/", "a");
|
||||
// Write out a file.
|
||||
OutputStream out =
|
||||
fService.createFile("test2933:/a", "foo.txt");
|
||||
byte [] buff = "This is a plain old text file.\n".getBytes();
|
||||
out.write(buff);
|
||||
buff = "It contains text.\n".getBytes();
|
||||
out.write(buff);
|
||||
out.close();
|
||||
// Read back that file.
|
||||
InputStream in =
|
||||
fService.getFileInputStream(-1, "test2933:/a/foo.txt");
|
||||
buff = new byte[1024];
|
||||
assertEquals(49, in.read(buff));
|
||||
if (logger.isDebugEnabled()) { logger.debug(new String(buff)); }
|
||||
assertEquals(-1, in.read(buff));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("test2933");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Another test of reading.
|
||||
*/
|
||||
public void testRead()
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createStore("froo");
|
||||
// Create a file.
|
||||
byte [] buff = new byte[64];
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
buff[i] = (byte)i;
|
||||
}
|
||||
OutputStream out =
|
||||
fService.createFile("froo:/", "foo.dat");
|
||||
out.write(buff, 32, 32);
|
||||
out.close();
|
||||
// Read it back in.
|
||||
InputStream in =
|
||||
fService.getFileInputStream(-1, "froo:/foo.dat");
|
||||
buff = new byte[1024];
|
||||
assertEquals(32, in.read(buff));
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("froo");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a call that should return null;
|
||||
*/
|
||||
public void testErrorState()
|
||||
{
|
||||
try
|
||||
{
|
||||
assertNull(fService.lookup(-1, "main:/fizz/fazz"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test update to branch
|
||||
*/
|
||||
public void testSimpleUpdateBR()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create a store.
|
||||
fService.createStore("froo");
|
||||
// Create a directory.
|
||||
fService.createDirectory("froo:/", "a");
|
||||
// Create a file.
|
||||
fService.createFile("froo:/a", "foo").close();
|
||||
// Create another store.
|
||||
fService.createStore("broo");
|
||||
// Create a branch.
|
||||
fService.createBranch(-1, "froo:/a", "broo:/", "a");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fService.createFile("froo:/a", "bar").close();
|
||||
diffs = fSyncService.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[froo:/a/bar[-1] > broo:/a/bar[-1]]", diffs.toString());
|
||||
// Update.
|
||||
fSyncService.update(diffs, null, false, false, false, false, "flippy", "Stuff");
|
||||
diffs = fSyncService.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("broo");
|
||||
fService.purgeStore("froo");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update to layered directory
|
||||
*/
|
||||
public void testSimpleUpdateLD() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.createLayeredDirectory("main:/", "layer:/", "layer");
|
||||
|
||||
// Create a directory.
|
||||
fService.createDirectory("layer:/layer", "b");
|
||||
// Create a file.
|
||||
fService.createFile("layer:/layer/b", "foo").close();
|
||||
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/layer/b[-1] > main:/b[-1]]", diffs.toString());
|
||||
fService.createSnapshot("layer", null, null);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("main", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer:/layer", "main:/");
|
||||
recursiveList("layer");
|
||||
recursiveList("main");
|
||||
fService.createStore("layer2");
|
||||
fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer");
|
||||
|
||||
// Create a directory.
|
||||
fService.createDirectory("layer2:/layer/", "c");
|
||||
// Create a file.
|
||||
fService.createFile("layer2:/layer/c", "foo").close();
|
||||
|
||||
fService.createSnapshot("layer2", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer2:/layer/c[-1] > layer:/layer/c[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer2:/layer", "layer:/layer");
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/layer/c[-1] > main:/c[-1]]", diffs.toString());
|
||||
recursiveList("layer2");
|
||||
recursiveList("layer");
|
||||
recursiveList("main");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("layer2");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test bulk update (using layered directory).
|
||||
*/
|
||||
public void testBulkUpdateLD() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
RemoteBulkLoader loader = new RemoteBulkLoader();
|
||||
loader.setAvmRemoteService(fService);
|
||||
|
||||
fService.createLayeredDirectory("main:/", "layer:/", "layer");
|
||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer:/layer");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/layer/bootstrap[-1] > main:/bootstrap[-1]]", diffs.toString());
|
||||
fService.createSnapshot("layer", null, null);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("main", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer:/layer", "main:/");
|
||||
recursiveList("layer");
|
||||
recursiveList("main");
|
||||
fService.createStore("layer2");
|
||||
fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer");
|
||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer2:/layer/bootstrap");
|
||||
fService.createSnapshot("layer2", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer2:/layer/bootstrap/bootstrap[-1] > layer:/layer/bootstrap/bootstrap[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer2:/layer", "layer:/layer");
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/layer/bootstrap/bootstrap[-1] > main:/bootstrap/bootstrap[-1]]", diffs.toString());
|
||||
recursiveList("layer2");
|
||||
recursiveList("layer");
|
||||
recursiveList("main");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("layer2");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the flatten operation, with a little bit of compare and update.
|
||||
*/
|
||||
public void testFlatten() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
// Change some stuff.
|
||||
fService.createFile("main:/layer/b", "fig").close();
|
||||
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
// Do a compare.
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/layer", -1, "main:/a", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[main:/layer/b/c/foo[-1] > main:/a/b/c/foo[-1], main:/layer/b/fig[-1] > main:/a/b/fig[-1]]", diffs.toString());
|
||||
// Update.
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
recursiveList("main");
|
||||
// Flatten.
|
||||
fSyncService.flatten("main:/layer", "main:/a");
|
||||
recursiveList("main");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test partial flatten.
|
||||
*/
|
||||
public void testPartialFlatten() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
fService.getFileOutputStream("layer:/a/b/c/foo").close();
|
||||
fService.createFile("layer:/a/b", "bing").close();
|
||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b");
|
||||
assertTrue(b.isLayeredDirectory());
|
||||
AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c");
|
||||
assertTrue(c.isPlainDirectory());
|
||||
diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[layer:/a/b/bing[-1] > main:/a/b/bing[-1]]", diffs.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test AVMSyncService resetLayer.
|
||||
*/
|
||||
public void testResetLayer() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createFile("main:/layer", "figs").close();
|
||||
assertFalse(recursiveContents("main:/a", -1, true).equals(recursiveContents("main:/layer", -1, true)));
|
||||
recursiveList("main");
|
||||
fSyncService.resetLayer("main:/layer");
|
||||
assertEquals(recursiveContents("main:/a", -1, true), recursiveContents("main:/layer", -1, true));
|
||||
recursiveList("main");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test AVMSyncService update.
|
||||
*/
|
||||
public void testUpdate() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
// Try branch to branch update.
|
||||
fService.createBranch(-1, "main:/a", "main:/", "abranch");
|
||||
fService.createFile("main:/abranch", "monkey").close();
|
||||
fService.createFile("main:/abranch", "#foo").close();
|
||||
fService.createFile("main:/abranch", "figs.tmp").close();
|
||||
fService.getFileOutputStream("main:/abranch/b/c/foo").close();
|
||||
recursiveList("main");
|
||||
List<AVMDifference> cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
assertEquals(2, cmp.size());
|
||||
assertEquals("[main:/abranch/b/c/foo[-1] > main:/a/b/c/foo[-1], main:/abranch/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(), fService.lookup(-1, "main:/a/monkey").getId());
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/b/c/foo").getId(), fService.lookup(-1, "main:/a/b/c/foo").getId());
|
||||
// Try updating a deletion.
|
||||
fService.removeNode("main:/abranch", "monkey");
|
||||
recursiveList("main");
|
||||
cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
assertEquals(1, cmp.size());
|
||||
assertEquals("[main:/abranch/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(), fService.lookup(-1, "main:/a/monkey", true).getId());
|
||||
// Try one that should fail.
|
||||
fService.createFile("main:/abranch", "monkey").close();
|
||||
cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
assertEquals(1, cmp.size());
|
||||
assertEquals("[main:/abranch/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/abranch/monkey", AVMDifference.NEWER));
|
||||
try
|
||||
{
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fail();
|
||||
}
|
||||
catch (AVMSyncException se)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
// Get synced again by doing an override older.
|
||||
recursiveList("main");
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/abranch/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, true, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), fService.lookup(-1, "main:/abranch/monkey", true).getId());
|
||||
// Cleanup for layered tests.
|
||||
fService.purgeStore("main");
|
||||
fService.createStore("main");
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createFile("main:/layer", "monkey").close();
|
||||
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
assertEquals(2, cmp.size());
|
||||
assertEquals("[main:/layer/b/c/foo[-1] > main:/a/b/c/foo[-1], main:/layer/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
recursiveList("main");
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/layer/monkey").getId(), fService.lookup(-1, "main:/a/monkey").getId());
|
||||
assertEquals(fService.lookup(-1, "main:/layer/b/c/foo").getId(), fService.lookup(-1, "main:/a/b/c/foo").getId());
|
||||
// Try updating a deletion.
|
||||
fService.removeNode("main:/layer", "monkey");
|
||||
recursiveList("main");
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
assertEquals(1, cmp.size());
|
||||
assertEquals("[main:/layer/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/layer/monkey", true).getId(), fService.lookup(-1, "main:/a/monkey", true).getId());
|
||||
// Try one that should fail.
|
||||
fService.createFile("main:/layer", "monkey").close();
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
assertEquals(1, cmp.size());
|
||||
assertEquals("[main:/layer/monkey[-1] > main:/a/monkey[-1]]", cmp.toString());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/layer/monkey", AVMDifference.NEWER));
|
||||
try
|
||||
{
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fail();
|
||||
}
|
||||
catch (AVMSyncException se)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
// Get synced again by doing an override older.
|
||||
recursiveList("main");
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/layer/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, true, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
recursiveList("main");
|
||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), fService.lookup(-1, "main:/layer/monkey", true).getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an update forces a snapshot on the source.
|
||||
*/
|
||||
public void testUpdateSnapshot() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("branch");
|
||||
fService.createBranch(-1, "main:/", "branch:/", "branch");
|
||||
// Modify some things in the branch.
|
||||
fService.createFile("branch:/branch/a/b", "fing").close();
|
||||
fService.getFileOutputStream("branch:/branch/a/b/c/foo").close();
|
||||
fService.removeNode("branch:/branch/a/b/c", "bar");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||
assertEquals(3, diffs.size());
|
||||
assertEquals("[branch:/branch/a/b/c/bar[-1] > main:/a/b/c/bar[-1], branch:/branch/a/b/c/foo[-1] > main:/a/b/c/foo[-1], branch:/branch/a/b/fing[-1] > main:/a/b/fing[-1]]", diffs.toString());
|
||||
// Now update.
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fService.getFileOutputStream("branch:/branch/a/b/fing").close();
|
||||
assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() != fService.lookup(-1, "main:/a/b/fing").getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("branch");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a noodle update.
|
||||
*/
|
||||
public void testNoodleUpdate() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("staging");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[main:/a[-1] > staging:/a[-1], main:/d[-1] > staging:/d[-1]]", diffs.toString());
|
||||
List<AVMDifference> noodle = new ArrayList<AVMDifference>();
|
||||
noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo", AVMDifference.NEWER));
|
||||
noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d", AVMDifference.NEWER));
|
||||
fSyncService.update(noodle, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[main:/a/b/c/bar[-1] > staging:/a/b/c/bar[-1]]", diffs.toString());
|
||||
assertEquals("main:/a/b/c/bar", diffs.get(0).getSourcePath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fService.purgeStore("staging");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void testRename6() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
fService.rename("layer:/a/b", "c", "layer:/a/b", "z");
|
||||
recursiveContents("layer:/");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[layer:/a/b/c[-1] > main:/a/b/c[-1], layer:/a/b/z[-1] > main:/a/b/z[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
recursiveContents("layer:/");
|
||||
recursiveContents("main:/");
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
recursiveContents("layer:/");
|
||||
recursiveContents("main:/");
|
||||
fService.createFile("layer:/a/b/z", "fudge").close();
|
||||
fService.rename("layer:/a/b", "z", "layer:/a/b", "y");
|
||||
recursiveContents("layer:/");
|
||||
diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[layer:/a/b/y[-1] > main:/a/b/y[-1], layer:/a/b/z[-1] > main:/a/b/z[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
recursiveContents("layer:/");
|
||||
recursiveContents("main:/");
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
recursiveContents("layer:/");
|
||||
recursiveContents("main:/");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected void recursiveContents(String path)
|
||||
{
|
||||
String contentsStr = recursiveContents(path, -1, true);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(contentsStr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the recursive contents of the given path and version.
|
||||
* @param path
|
||||
* @param version
|
||||
* @return A string representation of the contents.
|
||||
*/
|
||||
protected String recursiveContents(String path, int version, boolean followLinks)
|
||||
{
|
||||
String val = recursiveList(path, version, 0, followLinks);
|
||||
return val.substring(val.indexOf('\n'));
|
||||
}
|
||||
|
||||
protected void recursiveList(String store)
|
||||
{
|
||||
String list = recursiveList(store, -1, true);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(store+":");
|
||||
logger.debug(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to write a recursive listing of an AVMStore at a given version.
|
||||
* @param repoName The name of the AVMStore.
|
||||
* @param version The version to look under.
|
||||
*/
|
||||
protected String recursiveList(String repoName, int version, boolean followLinks)
|
||||
{
|
||||
return recursiveList(repoName + ":/", version, 0, followLinks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive list the given path.
|
||||
* @param path The path.
|
||||
* @param version The version.
|
||||
* @param indent The current indent level.
|
||||
*/
|
||||
protected String recursiveList(String path, int version, int indent, boolean followLinks)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < indent; i++)
|
||||
{
|
||||
builder.append(' ');
|
||||
}
|
||||
builder.append(path.substring(path.lastIndexOf('/') + 1));
|
||||
builder.append(' ');
|
||||
AVMNodeDescriptor desc = fService.lookup(version, path, true);
|
||||
builder.append(desc.toString());
|
||||
builder.append('\n');
|
||||
if (desc.getType() == AVMNodeType.PLAIN_DIRECTORY ||
|
||||
(desc.getType() == AVMNodeType.LAYERED_DIRECTORY && followLinks))
|
||||
{
|
||||
String basename = path.endsWith("/") ? path : path + "/";
|
||||
Map<String, AVMNodeDescriptor> listing = fService.getDirectoryListing(version, path);
|
||||
for (String name : listing.keySet())
|
||||
{
|
||||
if (logger.isDebugEnabled()) { logger.debug(name); }
|
||||
builder.append(recursiveList(basename + name, version, indent + 2, followLinks));
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup a basic tree.
|
||||
*/
|
||||
protected void setupBasicTree()
|
||||
throws IOException
|
||||
{
|
||||
fService.createDirectory("main:/", "a");
|
||||
fService.createDirectory("main:/a", "b");
|
||||
fService.createDirectory("main:/a/b", "c");
|
||||
fService.createDirectory("main:/", "d");
|
||||
fService.createDirectory("main:/d", "e");
|
||||
fService.createDirectory("main:/d/e", "f");
|
||||
|
||||
|
||||
OutputStream out = fService.createFile("main:/a/b/c", "foo");
|
||||
byte [] buff = "I am main:/a/b/c/foo".getBytes();
|
||||
out.write(buff);
|
||||
out.close();
|
||||
|
||||
/*
|
||||
fService.createFile("main:/a/b/c", "foo").close();
|
||||
ContentWriter writer = fService.getContentWriter("main:/a/b/c/foo");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("I am main:/a/b/c/foo");
|
||||
*/
|
||||
|
||||
out = fService.createFile("main:/a/b/c", "bar");
|
||||
buff = "I am main:/a/b/c/bar".getBytes();
|
||||
out.write(buff);
|
||||
out.close();
|
||||
|
||||
/*
|
||||
fService.createFile("main:/a/b/c", "bar").close();
|
||||
writer = fService.getContentWriter("main:/a/b/c/bar");
|
||||
// Force a conversion
|
||||
writer.setEncoding("UTF-16");
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
writer.putContent("I am main:/a/b/c/bar");
|
||||
*/
|
||||
|
||||
fService.createSnapshot("main", null, null);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -32,10 +31,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.transaction.RollbackException;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.AccessControlListDAO;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
@ -66,13 +65,9 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.odmg.DSet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Specifically test AVM permissions with the updated ACL schema
|
||||
*
|
||||
@ -533,7 +528,8 @@ public class AVMServicePermissionsTest extends TestCase
|
||||
avmService.createSnapshot(storeName + "-layer-base", "store", "store");
|
||||
|
||||
List<AVMDifference> diffs = avmSyncService.compare(-1, storeName + "-layer-base:/layer-to-base", -1, storeName + ":/base", null);
|
||||
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("["+storeName+"-layer-base:/layer-to-base/update-dir[-1] > "+storeName+":/base/update-dir[-1]]", diffs.toString());
|
||||
avmSyncService.update(diffs, null, false, false, false, false, "A", "A");
|
||||
|
||||
desc = avmService.lookup(-1, storeName + ":/base/update-dir");
|
||||
@ -615,7 +611,8 @@ public class AVMServicePermissionsTest extends TestCase
|
||||
avmService.createSnapshot(storeName + "-layer-base", "store", "store");
|
||||
|
||||
List<AVMDifference> diffs = avmSyncService.compare(-1, storeName + "-layer-base:/layer-to-base", -1, storeName + ":/base", null);
|
||||
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("["+storeName+"-layer-base:/layer-to-base/update-dir[-1] > "+storeName+":/base/update-dir[-1]]", diffs.toString());
|
||||
avmSyncService.update(diffs, null, false, false, false, false, "A", "A");
|
||||
|
||||
desc = avmService.lookup(-1, storeName + ":/base/update-dir");
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.repo.remote.ClientTicketHolder;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Remote system tests of AVM (AVMSyncService & AVMService) - requires running repo
|
||||
*/
|
||||
public class AVMServiceRemoteSystemTest extends AVMServiceLocalTest
|
||||
{
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
if (fContext == null)
|
||||
{
|
||||
// remote (non-embedded) test setup
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/remote-avm-test-context.xml");
|
||||
fService = (AVMRemote)fContext.getBean("avmRemote");
|
||||
fSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
|
||||
excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
|
||||
|
||||
AuthenticationService authService = (AuthenticationService)fContext.getBean("authenticationService");
|
||||
authService.authenticate("admin", "admin".toCharArray());
|
||||
String ticket = authService.getCurrentTicket();
|
||||
((ClientTicketHolder)fContext.getBean("clientTicketHolder")).setTicket(ticket);
|
||||
}
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -37,8 +37,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.config.JNDIConstants;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMModel;
|
||||
@ -51,14 +49,9 @@ import org.alfresco.repo.avm.actions.SimpleAVMSubmitAction;
|
||||
import org.alfresco.repo.avm.util.BulkLoader;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.search.IndexMode;
|
||||
import org.alfresco.repo.search.Indexer;
|
||||
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
|
||||
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
import org.alfresco.service.cmr.avm.AVMCycleException;
|
||||
import org.alfresco.service.cmr.avm.AVMException;
|
||||
@ -68,15 +61,10 @@ import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avm.LayeringDescriptor;
|
||||
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentEvent;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
|
||||
import org.alfresco.service.cmr.avm.deploy.DeploymentService;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncException;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.remote.RepoRemote;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.CrossRepositoryCopyService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@ -92,7 +80,6 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.NameMatcher;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
@ -116,6 +103,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.createFile("SandBox:/www/TestFolder", "test1").close();
|
||||
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "SandBox:/www", -1, "StagingArea:/www", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[SandBox:/www/TestFolder[-1] > StagingArea:/www/TestFolder[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, true, true, false, false, "one", "one");
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
fSyncService.flatten("SandBox:/www", "StagingArea:/www");
|
||||
@ -129,6 +118,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.removeNode("SandBox:/www/TestFolder");
|
||||
|
||||
diffs = fSyncService.compare(-1, "SandBox:/www", -1, "StagingArea:/www", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[SandBox:/www/TestFolder[-1] > StagingArea:/www/TestFolder[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, true, true, false, false, "one", "one");
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
fSyncService.flatten("SandBox:/www", "StagingArea:/www");
|
||||
@ -141,6 +132,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.createFile("SandBox:/www/TestFolder", "test1").close();
|
||||
|
||||
diffs = fSyncService.compare(-1, "SandBox:/www", -1, "StagingArea:/www", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[SandBox:/www/TestFolder[-1] > StagingArea:/www/TestFolder[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, true, true, false, false, "one", "one");
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
fSyncService.flatten("SandBox:/www", "StagingArea:/www");
|
||||
@ -199,42 +192,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
public void testRename6() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("layer");
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
fService.rename("layer:/a/b", "c", "layer:/a/b", "z");
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
System.out.println(diffs);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
System.out.println(recursiveContents("main:/", -1, true));
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
System.out.println(recursiveContents("main:/", -1, true));
|
||||
fService.createFile("layer:/a/b/z", "fudge").close();
|
||||
fService.rename("layer:/a/b", "z", "layer:/a/b", "y");
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
diffs = fSyncService.compare(-1, "layer:/a", -1, "main:/a", null);
|
||||
System.out.println(diffs);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
System.out.println(recursiveContents("main:/", -1, true));
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
System.out.println(recursiveContents("layer:/", -1, true));
|
||||
System.out.println(recursiveContents("main:/", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public void testSpacesInStoreNames() throws Exception
|
||||
{
|
||||
try
|
||||
@ -262,7 +219,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.createDirectory("user:/a/b", "newdir");
|
||||
fService.createFile("user:/a/b/newdir", "bibble.txt").close();
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "user:/a", -1, "sandbox:/a", null);
|
||||
System.out.println(diffs);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[user:/a/b/newdir[-1] > sandbox:/a/b/newdir[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
AVMNodeDescriptor dir = fService.lookup(-1, "user:/a/b/newdir");
|
||||
List<Pair<Integer, String>> paths = fService.getHeadPaths(dir);
|
||||
@ -295,6 +253,8 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
authService.authenticateAsGuest();
|
||||
// assertEquals(0, fLockingService.getUsersLocks("admin").size());
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
|
||||
assertEquals(2, diffs.size());
|
||||
assertEquals("[main:/a[-1] > test:/a[-1], main:/d[-1] > test:/d[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
RetryingTransactionHelper.RetryingTransactionCallback<Object> cb = new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||
{
|
||||
@ -1265,10 +1225,12 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
|
||||
assertEquals("[branch:/a/b/c/foo[-1] > main:/a/b/c/foo[-1]]", diffs.toString());
|
||||
fService.createFile("branch:/a/b/c", "foo").close();
|
||||
diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
|
||||
assertEquals("[branch:/a/b/c/foo[-1] > main:/a/b/c/foo[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.removeNode("branch:/a/b/c/bar");
|
||||
fService.createFile("branch:/a/b/c", "pismo").close();
|
||||
@ -1276,6 +1238,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
diffs = fSyncService.compare(-1, "branch:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals(AVMDifference.NEWER, diffs.get(0).getDifferenceCode());
|
||||
assertEquals("[branch:/a/b/c/bar[-1] > main:/a/b/c/bar[-1]]", diffs.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -1775,35 +1738,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test partial flatten.
|
||||
*/
|
||||
public void testPartialFlatten() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("layer");
|
||||
fService.createLayeredDirectory("main:/a", "layer:/", "a");
|
||||
fService.getFileOutputStream("layer:/a/b/c/foo").close();
|
||||
fService.createFile("layer:/a/b", "bing").close();
|
||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
diffs.add(new AVMDifference(-1, "layer:/a/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fSyncService.flatten("layer:/a", "main:/a");
|
||||
AVMNodeDescriptor b = fService.lookup(-1, "layer:/a/b");
|
||||
assertTrue(b.isLayeredDirectory());
|
||||
AVMNodeDescriptor c = fService.lookup(-1, "layer:/a/b/c");
|
||||
assertTrue(c.isPlainDirectory());
|
||||
assertEquals(1, fSyncService.compare(-1, "layer:/a", -1, "main:/a", null).size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getIndirection.
|
||||
*/
|
||||
@ -1842,10 +1776,12 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[area:/a/b/c/foo[-1] > main:/a/b/c/foo[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.getFileOutputStream("area:/a/b/c/bar").close();
|
||||
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[area:/a/b/c/bar[-1] > main:/a/b/c/bar[-1]]", diffs.toString());
|
||||
final ActionImpl action = new ActionImpl(null, GUID.generate(), AVMRevertListAction.NAME);
|
||||
List<String> paths = new ArrayList<String>();
|
||||
paths.add("area:/a/b");
|
||||
@ -1889,10 +1825,12 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.getFileOutputStream("area:/a/b/c/foo").close();
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[area:/a/b/c/foo[-1] > main:/a/b/c/foo[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.getFileOutputStream("area:/a/b/c/bar").close();
|
||||
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[area:/a/b/c/bar[-1] > main:/a/b/c/bar[-1]]", diffs.toString());
|
||||
final ActionImpl action = new ActionImpl(null, GUID.generate(), AVMUndoSandboxListAction.NAME);
|
||||
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
|
||||
versionPaths.add(new Pair<Integer, String>(-1, "area:/a/b/c/bar"));
|
||||
@ -1962,32 +1900,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a noodle update.
|
||||
*/
|
||||
public void testNoodleUpdate() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("staging");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||
assertEquals(2, diffs.size());
|
||||
List<AVMDifference> noodle = new ArrayList<AVMDifference>();
|
||||
noodle.add(new AVMDifference(-1, "main:/a/b/c/foo", -1, "staging:/a/b/c/foo", AVMDifference.NEWER));
|
||||
noodle.add(new AVMDifference(-1, "main:/d", -1, "staging:/d", AVMDifference.NEWER));
|
||||
fSyncService.update(noodle, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "main:/", -1, "staging:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("main:/a/b/c/bar", diffs.get(0).getSourcePath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the SimpleAVMSubmitAction.
|
||||
*/
|
||||
@ -2010,6 +1922,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
fService.removeNode("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/bar");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, "foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null);
|
||||
assertEquals(3, diffs.size());
|
||||
assertEquals("[area:/www/a/b/c/bar[-1] > foo-staging:/www/a/b/c/bar[-1], area:/www/a/b/c/foo[-1] > foo-staging:/www/a/b/c/foo[-1], area:/www/figs[-1] > foo-staging:/www/figs[-1]]", diffs.toString());
|
||||
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction) fContext.getBean("simple-avm-submit");
|
||||
class TxnWork implements RetryingTransactionCallback<Object>
|
||||
{
|
||||
@ -2215,11 +2128,13 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
List<AVMDifference> diffs = fSyncService.compare(version1, "source:/", -1, "dest:/", null);
|
||||
fService.createSnapshot("dest", null, null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[source:/bootstrap[1] > dest:/bootstrap[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(version1, "source:/", -1, "dest:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
assertEquals("[source:/extension[2] > dest:/extension[-1]]", diffs.toString());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("dest", null, null);
|
||||
diffs = fSyncService.compare(version2, "source:/", -1, "dest:/", null);
|
||||
@ -2232,36 +2147,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that an update forces a snapshot on the source.
|
||||
*/
|
||||
public void testUpdateSnapshot() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createStore("branch");
|
||||
fService.createBranch(-1, "main:/", "branch:/", "branch");
|
||||
// Modify some things in the branch.
|
||||
fService.createFile("branch:/branch/a/b", "fing").close();
|
||||
fService.getFileOutputStream("branch:/branch/a/b/c/foo").close();
|
||||
fService.removeNode("branch:/branch/a/b/c", "bar");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||
assertEquals(3, diffs.size());
|
||||
// Now update.
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fService.getFileOutputStream("branch:/branch/a/b/fing").close();
|
||||
assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() != fService.lookup(-1, "main:/a/b/fing").getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that branching forces a snapshot on the source repository.
|
||||
*/
|
||||
@ -2282,93 +2167,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test bulk update.
|
||||
*/
|
||||
public void testBulkUpdate() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
BulkLoader loader = new BulkLoader();
|
||||
loader.setAvmService(fService);
|
||||
fService.createStore("layer");
|
||||
fService.createLayeredDirectory("main:/", "layer:/", "layer");
|
||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer:/layer");
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
fService.createSnapshot("layer", null, null);
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("main", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer:/layer", "main:/");
|
||||
System.out.println("Layer:");
|
||||
System.out.println(recursiveList("layer", -1, true));
|
||||
System.out.println("Main:");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
fService.createStore("layer2");
|
||||
fService.createLayeredDirectory("layer:/layer", "layer2:/", "layer");
|
||||
loader.recursiveLoad("config/alfresco/bootstrap", "layer2:/layer/bootstrap");
|
||||
fService.createSnapshot("layer2", null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(1, diffs.size());
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
diffs = fSyncService.compare(-1, "layer2:/layer", -1, "layer:/layer", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fSyncService.flatten("layer2:/layer", "layer:/layer");
|
||||
diffs = fSyncService.compare(-1, "layer:/layer", -1, "main:/", null);
|
||||
assertEquals(1, diffs.size());
|
||||
System.out.println("Layer2:");
|
||||
System.out.println(recursiveList("layer2", -1, true));
|
||||
System.out.println("Layer:");
|
||||
System.out.println(recursiveList("layer", -1, true));
|
||||
System.out.println("Main:");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the flatten operation, with a little bit of compare and update.
|
||||
*/
|
||||
public void testFlatten() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// Change some stuff.
|
||||
fService.createFile("main:/layer/b", "fig").close();
|
||||
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// Do a compare.
|
||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/layer", -1, "main:/a", null);
|
||||
for (AVMDifference diff : diffs)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
// Update.
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
// Flatten.
|
||||
fSyncService.flatten("main:/layer", "main:/a");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test of Descriptor indirection field.
|
||||
*/
|
||||
@ -2397,155 +2196,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test AVMSyncService update.
|
||||
*/
|
||||
public void testUpdate() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
NameMatcher excluder = (NameMatcher) fContext.getBean("globalPathExcluder");
|
||||
setupBasicTree();
|
||||
// Try branch to branch update.
|
||||
fService.createBranch(-1, "main:/a", "main:/", "abranch");
|
||||
fService.createFile("main:/abranch", "monkey").close();
|
||||
fService.createFile("main:/abranch", "#foo").close();
|
||||
fService.createFile("main:/abranch", "figs.tmp").close();
|
||||
fService.getFileOutputStream("main:/abranch/b/c/foo").close();
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
List<AVMDifference> cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(2, cmp.size());
|
||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(), fService.lookup(-1, "main:/a/monkey").getId());
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/b/c/foo").getId(), fService.lookup(-1, "main:/a/b/c/foo").getId());
|
||||
// Try updating a deletion.
|
||||
fService.removeNode("main:/abranch", "monkey");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(1, cmp.size());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/abranch/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(), fService.lookup(-1, "main:/a/monkey", true).getId());
|
||||
// Try one that should fail.
|
||||
fService.createFile("main:/abranch", "monkey").close();
|
||||
cmp = fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(1, cmp.size());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/abranch/monkey", AVMDifference.NEWER));
|
||||
try
|
||||
{
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fail();
|
||||
}
|
||||
catch (AVMSyncException se)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
// Get synced again by doing an override older.
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/abranch/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, true, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/abranch", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), fService.lookup(-1, "main:/abranch/monkey", true).getId());
|
||||
// Cleanup for layered tests.
|
||||
fService.purgeStore("main");
|
||||
fService.createStore("main");
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createFile("main:/layer", "monkey").close();
|
||||
fService.getFileOutputStream("main:/layer/b/c/foo").close();
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(2, cmp.size());
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/b/c/foo", -1, "main:/a/b/c/foo", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/layer/monkey").getId(), fService.lookup(-1, "main:/a/monkey").getId());
|
||||
assertEquals(fService.lookup(-1, "main:/layer/b/c/foo").getId(), fService.lookup(-1, "main:/a/b/c/foo").getId());
|
||||
// Try updating a deletion.
|
||||
fService.removeNode("main:/layer", "monkey");
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(1, cmp.size());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/layer/monkey", -1, "main:/a/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/layer/monkey", true).getId(), fService.lookup(-1, "main:/a/monkey", true).getId());
|
||||
// Try one that should fail.
|
||||
fService.createFile("main:/layer", "monkey").close();
|
||||
cmp = fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder);
|
||||
for (AVMDifference diff : cmp)
|
||||
{
|
||||
System.out.println(diff);
|
||||
}
|
||||
assertEquals(1, cmp.size());
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/layer/monkey", AVMDifference.NEWER));
|
||||
try
|
||||
{
|
||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||
fail();
|
||||
}
|
||||
catch (AVMSyncException se)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
// Get synced again by doing an override older.
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
diffs.clear();
|
||||
diffs.add(new AVMDifference(-1, "main:/a/monkey", -1, "main:/layer/monkey", AVMDifference.NEWER));
|
||||
fSyncService.update(diffs, null, false, false, false, true, null, null);
|
||||
assertEquals(0, fSyncService.compare(-1, "main:/layer", -1, "main:/a", excluder).size());
|
||||
fService.createSnapshot("main", null, null);
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(), fService.lookup(-1, "main:/layer/monkey", true).getId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test link AVMService call.
|
||||
*/
|
||||
@ -5516,158 +5166,4 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test AVMSyncService resetLayer.
|
||||
*/
|
||||
public void testResetLayer() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
setupBasicTree();
|
||||
fService.createLayeredDirectory("main:/a", "main:/", "layer");
|
||||
fService.createFile("main:/layer", "figs").close();
|
||||
assertFalse(recursiveContents("main:/a", -1, true).equals(recursiveContents("main:/layer", -1, true)));
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
fSyncService.resetLayer("main:/layer");
|
||||
assertEquals(recursiveContents("main:/a", -1, true), recursiveContents("main:/layer", -1, true));
|
||||
System.out.println(recursiveList("main", -1, true));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test async indexing.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testAsyncIndex() throws Exception
|
||||
{
|
||||
// Make sure the slate is clean ...
|
||||
UserTransaction tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
if (fService.getStore("avmAsynchronousTest") != null)
|
||||
{
|
||||
assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
assertTrue(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
assertFalse(fIndexingInterceptor.hasIndexBeenCreated("bananaStoreWoof"));
|
||||
}
|
||||
else
|
||||
{
|
||||
assertFalse(fIndexingInterceptor.hasIndexBeenCreated("avmAsynchronousTest"));
|
||||
}
|
||||
StoreRef storeRef = AVMNodeConverter.ToStoreRef("avmAsynchronousTest");
|
||||
Indexer indexer = fIndexerAndSearcher.getIndexer(storeRef);
|
||||
if (indexer instanceof AVMLuceneIndexer)
|
||||
{
|
||||
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
|
||||
avmIndexer.deleteIndex("avmAsynchronousTest", IndexMode.SYNCHRONOUS);
|
||||
}
|
||||
tx.commit();
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("bananaStoreWoof"));
|
||||
assertEquals(-1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
// TODO: Suspend and resume indexing in case we are really unlucky and hit an index before we expect it.
|
||||
|
||||
SearchService searchService = fIndexerAndSearcher.getSearcher(storeRef, true);
|
||||
ResultSet results;
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(0, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
assertFalse(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
|
||||
assertEquals(IndexMode.ASYNCHRONOUS, fIndexingInterceptor.getIndexMode("avmAsynchronousTest"));
|
||||
assertEquals(IndexMode.SYNCHRONOUS, fIndexingInterceptor.getIndexMode("main"));
|
||||
assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 0));
|
||||
assertTrue(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 1));
|
||||
assertFalse(fIndexingInterceptor.isSnapshotIndexed("avmAsynchronousTest", 2));
|
||||
tx.commit();
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
Thread.sleep(180000);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(4, results.length());
|
||||
results.close();
|
||||
|
||||
tx = fTransactionService.getUserTransaction();
|
||||
tx.begin();
|
||||
assertEquals(1, fIndexingInterceptor.getLastIndexedSnapshot("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDate("avmAsynchronousTest"));
|
||||
assertTrue(fIndexingInterceptor.isIndexUpToDateAndSearchable("avmAsynchronousTest"));
|
||||
tx.commit();
|
||||
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.purgeStore("avmAsynchronousTest");
|
||||
fService.createStore("avmAsynchronousTest");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
fService.createDirectory("avmAsynchronousTest:/", "a");
|
||||
fService.createDirectory("avmAsynchronousTest:/a", "b");
|
||||
fService.createDirectory("avmAsynchronousTest:/a/b", "c");
|
||||
fService.createSnapshot("avmAsynchronousTest", null, null);
|
||||
|
||||
Thread.sleep(180000);
|
||||
|
||||
results = searchService.query(storeRef, "lucene", "PATH:\"//.\"");
|
||||
assertEquals(4, results.length());
|
||||
results.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,255 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.remote.ClientTicketHolder;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Tests of Remote interface to AVM.
|
||||
* @author britt
|
||||
*/
|
||||
public class AVMTestRemote extends TestCase
|
||||
{
|
||||
/**
|
||||
* The AVMRemote.
|
||||
*/
|
||||
private AVMRemote fAVMRemote;
|
||||
|
||||
/**
|
||||
* The Sync service.
|
||||
*/
|
||||
private AVMSyncService fAVMSync;
|
||||
|
||||
/**
|
||||
* The Authentication Service.
|
||||
*/
|
||||
private AuthenticationService fAuthService;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
*/
|
||||
private FileSystemXmlApplicationContext fContext;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/remote-avm-test-context.xml");
|
||||
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
|
||||
fAVMSync = (AVMSyncService)fContext.getBean("avmSyncService");
|
||||
fAuthService = (AuthenticationService)fContext.getBean("authenticationService");
|
||||
fAuthService.authenticate("admin", "admin".toCharArray());
|
||||
String ticket = fAuthService.getCurrentTicket();
|
||||
((ClientTicketHolder)fContext.getBean("clientTicketHolder")).setTicket(ticket);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = fAVMRemote.getStores();
|
||||
for (AVMStoreDescriptor desc : stores)
|
||||
{
|
||||
fAVMRemote.purgeStore(desc.getName());
|
||||
}
|
||||
fContext.close();
|
||||
}
|
||||
|
||||
public void testGetAPath()
|
||||
throws Exception
|
||||
{
|
||||
fAVMRemote.createStore("test2932");
|
||||
fAVMRemote.createDirectory("test2932:/", "a");
|
||||
fAVMRemote.createFile("test2932:/a", "foo.txt").close();
|
||||
AVMNodeDescriptor found = fAVMRemote.lookup(-1, "test2932:/a/foo.txt");
|
||||
Pair<Integer, String> path = fAVMRemote.getAPath(found);
|
||||
assertEquals(path.getSecond(), "test2932:/a/foo.txt");
|
||||
explorePaths("test2932:/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a simple hello world test.
|
||||
*/
|
||||
public void testSimple()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = fAVMRemote.getStores();
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
System.out.println(store);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void explorePaths(String path)
|
||||
throws Exception
|
||||
{
|
||||
Map<String, AVMNodeDescriptor> listing = fAVMRemote.getDirectoryListing(-1, path);
|
||||
for (Map.Entry<String, AVMNodeDescriptor> entry : listing.entrySet())
|
||||
{
|
||||
Pair<Integer, String> childPath = fAVMRemote.getAPath(entry.getValue());
|
||||
System.out.println(childPath);
|
||||
if (entry.getValue().isDirectory())
|
||||
{
|
||||
explorePaths(entry.getValue().getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reading and writing.
|
||||
*/
|
||||
public void testReadWrite()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create a test store.
|
||||
fAVMRemote.createStore("test2933");
|
||||
// Create a directory.
|
||||
fAVMRemote.createDirectory("test2933:/", "a");
|
||||
// Write out a file.
|
||||
OutputStream out =
|
||||
fAVMRemote.createFile("test2933:/a", "foo.txt");
|
||||
byte [] buff = "This is a plain old text file.\n".getBytes();
|
||||
out.write(buff);
|
||||
buff = "It contains text.\n".getBytes();
|
||||
out.write(buff);
|
||||
out.close();
|
||||
// Read back that file.
|
||||
InputStream in =
|
||||
fAVMRemote.getFileInputStream(-1, "test2933:/a/foo.txt");
|
||||
buff = new byte[1024];
|
||||
assertEquals(49, in.read(buff));
|
||||
System.out.print(new String(buff));
|
||||
assertEquals(-1, in.read(buff));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Another test of reading.
|
||||
*/
|
||||
public void testRead()
|
||||
{
|
||||
try
|
||||
{
|
||||
fAVMRemote.createStore("froo");
|
||||
// Create a file.
|
||||
byte [] buff = new byte[64];
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
buff[i] = (byte)i;
|
||||
}
|
||||
OutputStream out =
|
||||
fAVMRemote.createFile("froo:/", "foo.dat");
|
||||
out.write(buff, 32, 32);
|
||||
out.close();
|
||||
// Read it back in.
|
||||
InputStream in =
|
||||
fAVMRemote.getFileInputStream(-1, "froo:/foo.dat");
|
||||
buff = new byte[1024];
|
||||
assertEquals(32, in.read(buff));
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a call that should return null;
|
||||
*/
|
||||
public void testErrorState()
|
||||
{
|
||||
try
|
||||
{
|
||||
assertNull(fAVMRemote.lookup(-1, "main:/fizz/fazz"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.err);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the sync service.
|
||||
*/
|
||||
public void testSyncService()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create a store.
|
||||
fAVMRemote.createStore("froo");
|
||||
// Create a directory.
|
||||
fAVMRemote.createDirectory("froo:/", "a");
|
||||
// Create a file.
|
||||
fAVMRemote.createFile("froo:/a", "foo").close();
|
||||
// Create another store.
|
||||
fAVMRemote.createStore("broo");
|
||||
// Create a branch.
|
||||
fAVMRemote.createBranch(-1, "froo:/a", "broo:/", "a");
|
||||
List<AVMDifference> diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
fAVMRemote.createFile("froo:/a", "bar").close();
|
||||
diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(1, diffs.size());
|
||||
// Update.
|
||||
fAVMSync.update(diffs, null, false, false, false, false, "flippy", "Stuff");
|
||||
diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a", null);
|
||||
assertEquals(0, diffs.size());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -31,10 +31,12 @@ import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.avm.AVMRemoteLocal;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
@ -44,7 +46,7 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public class BulkLoader
|
||||
{
|
||||
private AVMService fService;
|
||||
private AVMRemote fService;
|
||||
|
||||
private int fPropertyCount = 0;
|
||||
|
||||
@ -60,6 +62,17 @@ public class BulkLoader
|
||||
* @param service
|
||||
*/
|
||||
public void setAvmService(AVMService service)
|
||||
{
|
||||
fService = new AVMRemoteLocal();
|
||||
((AVMRemoteLocal)fService).setAvmService(service);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the AVMService.
|
||||
* @param service
|
||||
*/
|
||||
protected void setAvmRemoteService(AVMRemote service)
|
||||
{
|
||||
fService = service;
|
||||
}
|
||||
|
41
source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java
Normal file
41
source/java/org/alfresco/repo/avm/util/RemoteBulkLoader.java
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
|
||||
package org.alfresco.repo.avm.util;
|
||||
|
||||
import org.alfresco.service.cmr.remote.AVMRemote;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class RemoteBulkLoader extends BulkLoader
|
||||
{
|
||||
/**
|
||||
* Set the AVMService.
|
||||
* @param service
|
||||
*/
|
||||
public void setAvmRemoteService(AVMRemote service)
|
||||
{
|
||||
super.setAvmRemoteService(service);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user