Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java view on Meta::CPAN
// check the status of the working copy
thisTest.checkStatus();
}
/**
* Test the basic property setting/getting functionality.
* @throws Throwable
*/
public void testBasicProperties() throws Throwable
{
OneTest thisTest = new OneTest();
WC wc = thisTest.getWc();
// Check getting properties the non-callback way
String itemPath = fileToSVNPath(new File(thisTest.getWCPath(),
"iota"),
false);
client.propertySet(itemPath, "abc", "def", false);
PropertyData[] properties = client.properties(itemPath);
PropertyData prop = properties[0];
assertEquals("abc", prop.getName());
assertEquals("def", prop.getValue());
wc.setItemPropStatus("iota", Status.Kind.modified);
thisTest.checkStatus();
// Check getting properties the callback way
itemPath = fileToSVNPath(new File(thisTest.getWCPath(),
"/A/B/E/alpha"),
false);
client.propertyCreate(itemPath, "cqcq", "qrz", false, false);
ProplistCallbackImpl callback = new ProplistCallbackImpl();
client.properties(itemPath, null, null, Depth.empty, null, callback);
Map propMap = callback.getProperties(itemPath);
Iterator it = propMap.keySet().iterator();
while (it.hasNext())
{
String key = (String) it.next();
assertEquals("cqcq", key);
assertEquals("qrz", (String) propMap.get(key));
}
wc.setItemPropStatus("A/B/E/alpha", Status.Kind.modified);
thisTest.checkStatus();
}
/**
* Test the basic SVNClient.update functionality.
* @throws Throwable
*/
public void testBasicUpdate() throws Throwable
{
// build the test setup. Used for the changes
OneTest thisTest = new OneTest();
// build the backup test setup. That is the one that will be updated
OneTest backupTest = thisTest.copy(".backup");
// modify A/mu
File mu = new File(thisTest.getWorkingCopy(), "A/mu");
PrintWriter muWriter = new PrintWriter(new FileOutputStream(mu, true));
muWriter.print("appended mu text");
muWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
thisTest.getWc().setItemContent("A/mu",
thisTest.getWc().getItemContent("A/mu") + "appended mu text");
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/mu",NodeKind.file,
CommitItemStateFlags.TextMods);
// modify A/D/G/rho
File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
PrintWriter rhoWriter =
new PrintWriter(new FileOutputStream(rho, true));
rhoWriter.print("new appended text for rho");
rhoWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
thisTest.getWc().setItemContent("A/D/G/rho",
thisTest.getWc().getItemContent("A/D/G/rho")
+ "new appended text for rho");
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/D/G/rho",NodeKind.file,
CommitItemStateFlags.TextMods);
// commit the changes
assertEquals("wrong revision number from commit",
client.commit(new String[]{thisTest.getWCPath()},
"log msg",
true),
2);
// check the status of the working copy
thisTest.checkStatus();
// update the backup test
assertEquals("wrong revision number from update",
client.update(backupTest.getWCPath(), null, true),
2);
// set the expected working copy layout for the backup test
backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
backupTest.getWc().setItemContent("A/mu",
backupTest.getWc().getItemContent("A/mu") + "appended mu text");
backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
backupTest.getWc().setItemContent("A/D/G/rho",
backupTest.getWc().getItemContent("A/D/G/rho")
+ "new appended text for rho");
// check the status of the working copy of the backup test
backupTest.checkStatus();
}
/**
* Test basic SVNClient.mkdir with URL parameter functionality.
* @throws Throwable
*/
public void testBasicMkdirUrl() throws Throwable
{
// build the test setup.
OneTest thisTest = new OneTest();
// create Y and Y/Z directories in the repository
addExpectedCommitItem(null, thisTest.getUrl(), "Y", NodeKind.none,
CommitItemStateFlags.Add);
addExpectedCommitItem(null, thisTest.getUrl(), "Y/Z", NodeKind.none,
CommitItemStateFlags.Add);
client.mkdir(new String[]{thisTest.getUrl() + "/Y",
thisTest.getUrl() + "/Y/Z"}, "log_msg");
// add the new directories the expected working copy layout
thisTest.getWc().addItem("Y", null);
thisTest.getWc().setItemWorkingCopyRevision("Y", 2);
thisTest.getWc().addItem("Y/Z", null);
thisTest.getWc().setItemWorkingCopyRevision("Y/Z", 2);
// update the working copy
assertEquals("wrong revision from update",
client.update(thisTest.getWCPath(), null, true),
2);
// check the status of the working copy
thisTest.checkStatus();
}
/**
* Test the {@link SVNClientInterface.copy()} API.
* @since 1.5
*/
public void testCopy()
throws SubversionException, IOException
{
OneTest thisTest = new OneTest();
WC wc = thisTest.getWc();
final Revision firstRevision = Revision.getInstance(1);
final Revision pegRevision = null; // Defaults to Revision.HEAD.
// Copy files from A/B/E to A/B/F.
String[] srcPaths = { "alpha", "beta" };
CopySource[] sources = new CopySource[srcPaths.length];
for (int i = 0; i < srcPaths.length; i++)
{
String fileName = srcPaths[i];
sources[i] =
new CopySource(new File(thisTest.getWorkingCopy(),
"A/B/E/" + fileName).getPath(),
firstRevision, pegRevision);
wc.addItem("A/B/F/" + fileName,
wc.getItemContent("A/B/E/" + fileName));
wc.setItemWorkingCopyRevision("A/B/F/" + fileName, 2);
src/subversion/subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java view on Meta::CPAN
return;
}
}
fail("Start revision: " + start + " was not in range: " + revisions[0] +
" : " + revisions[revisions.length - 1]);
}
/**
* Test the basic SVNClient.update functionality with concurrent
* changes in the repository and the working copy.
* @throws Throwable
*/
public void testBasicMergingUpdate() throws Throwable
{
// build the first working copy
OneTest thisTest = new OneTest();
// append 10 lines to A/mu
File mu = new File(thisTest.getWorkingCopy(), "A/mu");
PrintWriter muWriter = new PrintWriter(new FileOutputStream(mu, true));
String muContent = thisTest.getWc().getItemContent("A/mu");
for (int i = 2; i < 11; i++)
{
muWriter.print("\nThis is line " + i + " in mu");
muContent = muContent + "\nThis is line " + i + " in mu";
}
muWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
thisTest.getWc().setItemContent("A/mu", muContent);
addExpectedCommitItem(thisTest.getWorkingCopy().getAbsolutePath(),
thisTest.getUrl(), "A/mu", NodeKind.file,
CommitItemStateFlags.TextMods);
// append 10 line to A/D/G/rho
File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
PrintWriter rhoWriter =
new PrintWriter(new FileOutputStream(rho, true));
String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
for (int i = 2; i < 11; i++)
{
rhoWriter.print("\nThis is line " + i + " in rho");
rhoContent = rhoContent + "\nThis is line " + i + " in rho";
}
rhoWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
CommitItemStateFlags.TextMods);
// commit the changes
assertEquals("wrong revision number from commit",
client.commit(new String[]{thisTest.getWCPath()},
"log msg",
true),
2);
// check the status of the first working copy
thisTest.checkStatus();
// create a backup copy of the working copy
OneTest backupTest = thisTest.copy(".backup");
// change the last line of A/mu in the first working copy
muWriter = new PrintWriter(new FileOutputStream(mu, true));
muContent = thisTest.getWc().getItemContent("A/mu");
muWriter.print(" Appended to line 10 of mu");
muContent = muContent + " Appended to line 10 of mu";
muWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
thisTest.getWc().setItemContent("A/mu", muContent);
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/mu", NodeKind.file,
CommitItemStateFlags.TextMods);
// change the last line of A/mu in the first working copy
rhoWriter = new PrintWriter(new FileOutputStream(rho, true));
rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
rhoWriter.print(" Appended to line 10 of rho");
rhoContent = rhoContent + " Appended to line 10 of rho";
rhoWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
CommitItemStateFlags.TextMods);
// commit these changes to the repository
assertEquals("wrong revision number from commit",
client.commit(new String[]{thisTest.getWCPath()},
"log msg",
true),
3);
// check the status of the first working copy
thisTest.checkStatus();
// modify the first line of A/mu in the backup working copy
mu = new File(backupTest.getWorkingCopy(), "A/mu");
muWriter = new PrintWriter(new FileOutputStream(mu));
muWriter.print("This is the new line 1 in the backup copy of mu");
muContent = "This is the new line 1 in the backup copy of mu";
for (int i = 2; i < 11; i++)
{
muWriter.print("\nThis is line " + i + " in mu");
muContent = muContent + "\nThis is line " + i + " in mu";
}
muWriter.close();
backupTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
muContent = muContent + " Appended to line 10 of mu";
backupTest.getWc().setItemContent("A/mu", muContent);
backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
// modify the first line of A/D/G/rho in the backup working copy
rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
rhoWriter = new PrintWriter(new FileOutputStream(rho));
rhoWriter.print("This is the new line 1 in the backup copy of rho");
rhoContent = "This is the new line 1 in the backup copy of rho";
for (int i = 2; i < 11; i++)
{
rhoWriter.print("\nThis is line " + i + " in rho");
rhoContent = rhoContent + "\nThis is line " + i + " in rho";
}
rhoWriter.close();
backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
rhoContent = rhoContent + " Appended to line 10 of rho";
backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
// update the backup working copy
assertEquals("wrong revision number from update",
client.update(backupTest.getWCPath(), null, true),
3);
// check the status of the backup working copy
backupTest.checkStatus();
}
/**
* Test the basic SVNClient.update functionality with concurrent
* changes in the repository and the working copy that generate
* conflicts.
* @throws Throwable
*/
public void testBasicConflict() throws Throwable
{
// build the first working copy
OneTest thisTest = new OneTest();
// copy the first working copy to the backup working copy
OneTest backupTest = thisTest.copy(".backup");
// append a line to A/mu in the first working copy
File mu = new File(thisTest.getWorkingCopy(), "A/mu");
PrintWriter muWriter = new PrintWriter(new FileOutputStream(mu, true));
String muContent = thisTest.getWc().getItemContent("A/mu");
muWriter.print("\nOriginal appended text for mu");
muContent = muContent + "\nOriginal appended text for mu";
muWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
thisTest.getWc().setItemContent("A/mu", muContent);
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/mu", NodeKind.file,
CommitItemStateFlags.TextMods);
// append a line to A/D/G/rho in the first working copy
File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
PrintWriter rhoWriter =
new PrintWriter(new FileOutputStream(rho, true));
String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
rhoWriter.print("\nOriginal appended text for rho");
rhoContent = rhoContent + "\nOriginal appended text for rho";
rhoWriter.close();
thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
addExpectedCommitItem(thisTest.getWCPath(),
thisTest.getUrl(), "A/D/G/rho", NodeKind.file,
CommitItemStateFlags.TextMods);
// commit the changes in the first working copy
assertEquals("wrong revision number from commit",
client.commit(new String[]{thisTest.getWCPath()},
"log msg",
true),
2);
// test the status of the working copy after the commit
thisTest.checkStatus();
// append a different line to A/mu in the backup working copy
mu = new File(backupTest.getWorkingCopy(), "A/mu");
muWriter = new PrintWriter(new FileOutputStream(mu, true));
muWriter.print("\nConflicting appended text for mu");
muContent = "<<<<<<< .mine\nThis is the file 'mu'.\n"+
"Conflicting appended text for mu=======\n"+
"This is the file 'mu'.\n"+
"Original appended text for mu>>>>>>> .r2";
muWriter.close();
backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
backupTest.getWc().setItemContent("A/mu", muContent);
backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.conflicted);
backupTest.getWc().addItem("A/mu.r1", "");
backupTest.getWc().setItemNodeKind("A/mu.r1", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/mu.r1",
Status.Kind.unversioned);
backupTest.getWc().addItem("A/mu.r2", "");
backupTest.getWc().setItemNodeKind("A/mu.r2", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/mu.r2",
Status.Kind.unversioned);
backupTest.getWc().addItem("A/mu.mine", "");
backupTest.getWc().setItemNodeKind("A/mu.mine", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/mu.mine",
Status.Kind.unversioned);
// append a different line to A/D/G/rho in the backup working copy
rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
rhoWriter = new PrintWriter(new FileOutputStream(rho, true));
rhoWriter.print("\nConflicting appended text for rho");
rhoContent = "<<<<<<< .mine\nThis is the file 'rho'.\n"+
"Conflicting appended text for rho=======\n"+
"his is the file 'rho'.\n"+
"Original appended text for rho>>>>>>> .r2";
rhoWriter.close();
backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
backupTest.getWc().setItemTextStatus("A/D/G/rho",
Status.Kind.conflicted);
backupTest.getWc().addItem("A/D/G/rho.r1", "");
backupTest.getWc().setItemNodeKind("A/D/G/rho.r1", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/D/G/rho.r1",
Status.Kind.unversioned);
backupTest.getWc().addItem("A/D/G/rho.r2", "");
backupTest.getWc().setItemNodeKind("A/D/G/rho.r2", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/D/G/rho.r2",
Status.Kind.unversioned);
backupTest.getWc().addItem("A/D/G/rho.mine", "");
backupTest.getWc().setItemNodeKind("A/D/G/rho.mine", NodeKind.unknown);
backupTest.getWc().setItemTextStatus("A/D/G/rho.mine",
Status.Kind.unversioned);
// update the backup working copy from the repository
assertEquals("wrong revision number from update",
client.update(backupTest.getWCPath(), null, true),
2);
// check the status of the backup working copy
backupTest.checkStatus();
// flag A/mu as resolved
client.resolved(backupTest.getWCPath()+"/A/mu", false);
backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
backupTest.getWc().removeItem("A/mu.r1");
backupTest.getWc().removeItem("A/mu.r2");
backupTest.getWc().removeItem("A/mu.mine");
// flag A/D/G/rho as resolved
client.resolved(backupTest.getWCPath()+"/A/D/G/rho", false);
backupTest.getWc().setItemTextStatus("A/D/G/rho",
Status.Kind.modified);
backupTest.getWc().removeItem("A/D/G/rho.r1");
backupTest.getWc().removeItem("A/D/G/rho.r2");
backupTest.getWc().removeItem("A/D/G/rho.mine");
// check the status after the conflicts are flaged as resolved
backupTest.checkStatus();
}
/**
* Test the basic SVNClient.cleanup functionality.
* Without a way to force a lock, this test just verifies
* the method can be called succesfully.
* @throws Throwable
*/
public void testBasicCleanup() throws Throwable
{
// create a test working copy
OneTest thisTest = new OneTest();
// run cleanup
client.cleanup(thisTest.getWCPath());
}
/**
* Test the basic SVNClient.revert functionality.
* @throws Throwable
*/
public void testBasicRevert() throws Throwable
{
// create a test working copy
OneTest thisTest = new OneTest();
// modify A/B/E/beta
File file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
pw.print("Added some text to 'beta'.");
pw.close();
thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.modified);
// modify iota
file = new File(thisTest.getWorkingCopy(), "iota");
pw = new PrintWriter(new FileOutputStream(file, true));
pw.print("Added some text to 'iota'.");
pw.close();
thisTest.getWc().setItemTextStatus("iota", Status.Kind.modified);
// modify A/D/G/rho
file = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
pw = new PrintWriter(new FileOutputStream(file, true));
pw.print("Added some text to 'rho'.");
pw.close();
thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
// create new file A/D/H/zeta and add it to subversion
file = new File(thisTest.getWorkingCopy(), "A/D/H/zeta");
pw = new PrintWriter(new FileOutputStream(file, true));
pw.print("Added some text to 'zeta'.");
pw.close();
thisTest.getWc().addItem("A/D/H/zeta", "Added some text to 'zeta'.");
thisTest.getWc().setItemTextStatus("A/D/H/zeta", Status.Kind.added);
client.add(file.getAbsolutePath(), false);
// test the status of the working copy
thisTest.checkStatus();
src/subversion/subversion/bindings/javahl/tests/org/tigris/subversion/javahl/BasicTests.java view on Meta::CPAN
}
catch (ClientException e)
{
fail(e.getMessage());
}
}
};
client.notification2(notify);
// update the test to try to cancel an operation
try
{
client.update(thisTest.getWCPath(), null, true);
fail("missing exception for canceled operation");
}
catch (ClientException e)
{
// this is expected
}
}
public void testDataTransferProgressReport() throws Throwable
{
// ### FIXME: This isn't working over ra_local, because
// ### ra_local is not invoking the progress callback.
if (SVNTests.rootUrl.startsWith("file://"))
return;
// build the test setup
OneTest thisTest = new OneTest();
ProgressListener listener = new ProgressListener()
{
public void onProgress(ProgressEvent event)
{
// TODO: Examine the byte counts from "event".
throw new RuntimeException("Progress reported as expected");
}
};
client.setProgressListener(listener);
// Perform an update to exercise the progress notification.
try
{
client.update(thisTest.getWCPath(), null, true);
fail("No progress reported");
}
catch (RuntimeException progressReported)
{
}
}
/**
* Test the basic tree conflict functionality.
* @throws Throwable
*/
public void testTreeConflict() throws Throwable
{
// build the test setup. Used for the changes
OneTest thisTest = new OneTest();
WC wc = thisTest.getWc();
// build the backup test setup. That is the one that will be updated
OneTest tcTest = thisTest.copy(".tree-conflict");
// Move files from A/B/E to A/B/F.
String[] srcPaths = { "alpha" };
for (int i = 0; i < srcPaths.length; i++)
{
String fileName = srcPaths[i];
srcPaths[i] = new File(thisTest.getWorkingCopy(),
"A/B/E/" + fileName).getPath();
wc.addItem("A/B/F/" + fileName,
wc.getItemContent("A/B/E/" + fileName));
wc.setItemWorkingCopyRevision("A/B/F/" + fileName, 2);
addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(),
"A/B/F/" + fileName, NodeKind.file,
CommitItemStateFlags.Add |
CommitItemStateFlags.IsCopy);
wc.removeItem("A/B/E/" + fileName);
addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(),
"A/B/E/" + fileName, NodeKind.file,
CommitItemStateFlags.Delete);
}
client.move(srcPaths,
new File(thisTest.getWorkingCopy(), "A/B/F").getPath(),
null, false, true, false, null);
// Commit the changes, and check the state of the WC.
assertEquals("Unexpected WC revision number after commit",
client.commit(new String[] { thisTest.getWCPath() },
"Move files", true), 2);
thisTest.checkStatus();
// modify A/B/E/alpha in second working copy
File alpha = new File(tcTest.getWorkingCopy(), "A/B/E/alpha");
PrintWriter alphaWriter = new PrintWriter(new FileOutputStream(alpha, true));
alphaWriter.print("appended alpha text");
alphaWriter.close();
// update the tc test
assertEquals("wrong revision number from update",
client.update(tcTest.getWCPath(), null, true),
2);
// set the expected working copy layout for the tc test
tcTest.getWc().addItem("A/B/F/alpha",
tcTest.getWc().getItemContent("A/B/E/alpha"));
tcTest.getWc().setItemWorkingCopyRevision("A/B/F/alpha", 2);
// we expect the tree conflict to turn the existing item into
// a scheduled-add with history.
tcTest.getWc().setItemTextStatus("A/B/E/alpha", StatusKind.added);
tcTest.getWc().setItemTextStatus("A/B/F/alpha", StatusKind.normal);
// check the status of the working copy of the tc test
tcTest.checkStatus();
// get the Info2 of the tree conflict
MyInfoCallback callback = new MyInfoCallback();
client.info2(tcTest.getWCPath() + "/A/B/E/alpha", null,
null, Depth.unknown, null, callback);
ConflictDescriptor conflict = callback.getInfo().getConflictDescriptor();
assertNotNull("Conflict should not be null", conflict);
assertEquals(conflict.getSrcLeftVersion().getNodeKind(), NodeKind.file);
assertEquals(conflict.getSrcLeftVersion().getReposURL() + "/" +
conflict.getSrcLeftVersion().getPathInRepos(), tcTest.getUrl() + "/A/B/E/alpha");
assertEquals(conflict.getSrcLeftVersion().getPegRevision(), 1L);
if (conflict.getSrcRightVersion() != null)
{
assertEquals(conflict.getSrcRightVersion().getNodeKind(), NodeKind.none);
assertEquals(conflict.getSrcRightVersion().getReposURL(), tcTest.getUrl());
assertEquals(conflict.getSrcRightVersion().getPegRevision(), 2L);
}
}
/**
* Test tolerance of unversioned obstructions when adding paths with
* {@link org.tigris.subversion.javahl.SVNClient#checkout()},
* {@link org.tigris.subversion.javahl.SVNClient#update()}, and
* {@link org.tigris.subversion.javahl.SVNClient#doSwitch()}
* @throws IOException
* @throws SubversionException
*/
/*
This is currently commented out, because we don't have an XFail method
for JavaHL. The resolution is pending the result of issue #3680:
http://subversion.tigris.org/issues/show_bug.cgi?id=3680
public void testObstructionTolerance()
throws SubversionException, IOException
{
// build the test setup
OneTest thisTest = new OneTest();
File file;
PrintWriter pw;
// ----- TEST CHECKOUT -----
// Use export to make unversioned obstructions for a second
// WC checkout (deleting export target from previous tests
// first if it exists).
String secondWC = thisTest.getWCPath() + ".backup1";
removeDirOrFile(new File(secondWC));
client.doExport(thisTest.getUrl(), secondWC, null, false);
// Make an obstructing file that conflicts with add coming from repos
file = new File(secondWC, "A/B/lambda");
pw = new PrintWriter(new FileOutputStream(file));
pw.print("This is the conflicting obstructiong file 'lambda'.");
pw.close();
// Attempt to checkout backup WC without "--force"...
try
{
// ...should fail
client.checkout(thisTest.getUrl(), secondWC, null, null,
Depth.infinity, false, false);
fail("obstructed checkout should fail by default");
}
catch (ClientException expected)
{
}
// Attempt to checkout backup WC with "--force"
// so obstructions are tolerated
client.checkout(thisTest.getUrl(), secondWC, null, null,
Depth.infinity, false, true);
// Check the WC status, the only status should be a text
// mod to lambda. All the other obstructing files were identical
Status[] secondWCStatus = client.status(secondWC, true, false,
false, false, false);
if (!(secondWCStatus.length == 1 &&
secondWCStatus[0].getPath().endsWith("A/B/lambda") &&
secondWCStatus[0].getTextStatus() == StatusKind.modified &&
secondWCStatus[0].getPropStatus() == StatusKind.none))
{
fail("Unexpected WC status after co with " +
"unversioned obstructions");
}
// Make a third WC to test obstruction tolerance of sw and up.
OneTest backupTest = thisTest.copy(".backup2");
// ----- TEST UPDATE -----
// r2: Add a file A/D/H/nu
file = new File(thisTest.getWorkingCopy(), "A/D/H/nu");
pw = new PrintWriter(new FileOutputStream(file));
pw.print("This is the file 'nu'.");
pw.close();
client.add(file.getAbsolutePath(), false);
addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(),
"A/D/H/nu", NodeKind.file,
CommitItemStateFlags.TextMods +
CommitItemStateFlags.Add);
assertEquals("wrong revision number from commit",
client.commit(new String[] {thisTest.getWCPath()},
"log msg", true), 2);
thisTest.getWc().addItem("A/D/H/nu", "This is the file 'nu'.");
Status status = client.singleStatus(thisTest.getWCPath() +
"/A/D/H/nu",
false);
// Add an unversioned file A/D/H/nu to the backup WC
file = new File(backupTest.getWorkingCopy(), "A/D/H/nu");
pw = new PrintWriter(new FileOutputStream(file));
pw.print("This is the file 'nu'.");
pw.close();
// Attempt to update backup WC without "--force"
try
{
// obstructed update should fail
client.update(backupTest.getWCPath(), null, true);
fail("obstructed update should fail by default");
}
catch (ClientException expected)
{
}
// Attempt to update backup WC with "--force"
assertEquals("wrong revision from update",
client.update(backupTest.getWCPath(),
null, Depth.infinity, false, false, true),
2);
// ----- TEST SWITCH -----
// Add an unversioned file A/B/E/nu to the backup WC
// The file differs from A/D/H/nu
file = new File(backupTest.getWorkingCopy(), "A/B/E/nu");
pw = new PrintWriter(new FileOutputStream(file));
pw.print("This is yet another file 'nu'.");
pw.close();
// Add an unversioned file A/B/E/chi to the backup WC
// The file is identical to A/D/H/chi.
file = new File(backupTest.getWorkingCopy(), "A/B/E/chi");
pw = new PrintWriter(new FileOutputStream(file));
pw.print("This is the file 'chi'.");
pw.close();
// Attempt to switch A/B/E to A/D/H without "--force"
try
{
// obstructed switch should fail
client.doSwitch(backupTest.getWCPath() + "/A/B/E",
backupTest.getUrl() + "/A/D/H",
null, true);
fail("obstructed switch should fail by default");
}
catch (ClientException expected)
{
}
// Complete the switch using "--force" and check the status
client.doSwitch(backupTest.getWCPath() + "/A/B/E",
backupTest.getUrl() + "/A/D/H",
Revision.HEAD, Revision.HEAD, Depth.infinity,
false, false, true);
backupTest.getWc().setItemIsSwitched("A/B/E",true);
backupTest.getWc().removeItem("A/B/E/alpha");
backupTest.getWc().removeItem("A/B/E/beta");
backupTest.getWc().addItem("A/B/E/nu",
"This is yet another file 'nu'.");
backupTest.getWc().setItemTextStatus("A/B/E/nu", Status.Kind.modified);
backupTest.getWc().addItem("A/D/H/nu",
"This is the file 'nu'.");
backupTest.getWc().addItem("A/B/E/chi",
backupTest.getWc().getItemContent("A/D/H/chi"));
backupTest.getWc().addItem("A/B/E/psi",
backupTest.getWc().getItemContent("A/D/H/psi"));
backupTest.getWc().addItem("A/B/E/omega",
backupTest.getWc().getItemContent("A/D/H/omega"));
backupTest.checkStatus();
}*/
/**
* Test basic blame functionality. This test marginally tests blame
* correctness, mainly just that the blame APIs link correctly.
* @throws Throwable
* @since 1.5
*/
public void testBasicBlame() throws Throwable
{
OneTest thisTest = new OneTest();
// Test the old interface to be sure it still works
byte[] result = client.blame(thisTest.getWCPath() + "/iota", Revision
.getInstance(1), Revision.getInstance(1));
assertEquals(" 1 jrandom This is the file 'iota'.\n",
new String(result));
// Test the current interface
BlameCallbackImpl callback = new BlameCallbackImpl();
client.blame(thisTest.getWCPath() + "/iota", Revision.getInstance(1),
Revision.getInstance(1), callback);
assertEquals(1, callback.numberOfLines());
BlameCallbackImpl.BlameLine line = callback.getBlameLine(0);
if (line != null)
{
assertEquals(1, line.getRevision());
assertEquals("jrandom", line.getAuthor());
}
}
/**
* Test commit of arbitrary revprops.
* @throws Throwable
* @since 1.5
*/
@SuppressWarnings("unchecked")
public void testCommitRevprops() throws Throwable
{
class RevpropLogCallback implements LogMessageCallback
{
Map revprops;
public void singleMessage(ChangePath[] changedPaths,
long revision,
Map revprops,
boolean hasChildren)
{
this.revprops = revprops;
}
public Map getRevprops()
{
return revprops;
}
}
// build the test setup
OneTest thisTest = new OneTest();
( run in 0.976 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )