Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/javahl/tests/org/apache/subversion/javahl/WC.java view on Meta::CPAN
* the repository.
*/
public void setItemReposLastCmtDate(String path, long date)
{
items.get(path).reposLastCmtDate = date;
}
/**
* Set the youngest committed node kind of an out of date item at
* <code>path</code>.
* @param path The path to set the last node kind for.
* @param revision The last node kind for <code>path</code> known
* to the repository.
*/
public void setItemReposKind(String path, NodeKind nodeKind)
{
items.get(path).reposKind = nodeKind;
}
/**
* Set the youngest committed rev, author, date, and node kind of an
* out of date item at <code>path</code>.
*
* @param path The path to set the repos info for.
* @param revision The last revision number.
* @param revision The last author.
* @param date The last date.
* @param nodeKind The last node kind.
*/
public void setItemOODInfo(String path, long revision, String author,
long date, NodeKind nodeKind)
{
this.setItemReposLastCmtRevision(path, revision);
this.setItemReposLastCmtAuthor(path, author);
this.setItemReposLastCmtDate(path, date);
this.setItemReposKind(path, nodeKind);
}
/**
* Copy an expected working copy state
* @return the copy of the exiting object
*/
public WC copy()
{
WC c = new WC();
for (Item item : items.values())
{
item.copy(c);
}
return c;
}
/**
* Check the result of a single file SVNClient.list call
* @param tested the result array
* @param singleFilePath the path to be checked
* @throws Exception
*/
void check(DirEntry[] tested, String singleFilePath)
{
Assert.assertEquals("not a single dir entry", 1, tested.length);
Item item = items.get(singleFilePath);
Assert.assertNotNull("not found in working copy", item);
Assert.assertNotNull("not a file", item.myContent);
Assert.assertEquals("state says file, working copy not",
tested[0].getNodeKind(),
item.nodeKind == null ? NodeKind.file : item.nodeKind);
}
/**
* Check the result of a directory SVNClient.list call
* @param tested the result array
* @param basePath the path of the directory
* @param recursive the recursive flag of the call
* @throws Exception
*/
void check(DirEntry[] tested, String basePath, boolean recursive)
{
// clear the touched flag of all items
for (Item item : items.values())
{
item.touched = false;
}
// normalize directory path
if (basePath != null && basePath.length() > 0)
{
basePath += '/';
}
else
{
basePath = "";
}
// check all returned DirEntry's
for (DirEntry entry : tested)
{
String name = basePath + entry.getPath();
Item item = items.get(name);
Assert.assertNotNull("null paths won't be found in working copy",
item);
if (item.myContent != null)
{
Assert.assertEquals("Expected '" + entry + "' to be file",
entry.getNodeKind(),
item.nodeKind == null ? NodeKind.file : item.nodeKind);
}
else
{
Assert.assertEquals("Expected '" + entry + "' to be dir",
entry.getNodeKind(),
item.nodeKind == null ? NodeKind.dir : item.nodeKind);
}
item.touched = true;
}
// all items should have been in items, should had their touched flag
// set
for (Item item : items.values())
{
if (!item.touched)
{
if (item.myPath.startsWith(basePath) &&
!item.myPath.equals(basePath))
{
// Non-recursive checks will fail here.
Assert.assertFalse("Expected path '" + item.myPath +
"' not found in dir entries",
recursive);
// Look deeper under the tree.
boolean found = false;
for (DirEntry entry : tested)
{
if (entry.getNodeKind() == NodeKind.dir)
{
if (item.myPath.startsWith(basePath +
entry.getPath()))
{
found = true;
break;
}
}
}
Assert.assertTrue("Expected path '" + item.myPath +
"' not found in dir entries", found);
}
}
}
}
/**
* Check the result of a SVNClient.status() versus the expected
* state. Does not extract "out of date" information from the
* repository.
*
* @param tested the result to be tested
* @param workingCopyPath the path of the working copy
* @throws IOException If there is a problem finding or reading
* the WC.
* @see #check(Status[], String, boolean)
*/
void check(Status[] tested, String workingCopyPath)
throws IOException
{
check(tested, workingCopyPath, false);
}
/**
* Check the result of a SVNClient.status() versus the expected state.
*
* @param tested The result to be tested.
* @param workingCopyPath The path of the working copy.
* @param checkRepos Whether to compare the "out of date" statii.
* @throws IOException If there is a problem finding or reading
* the WC.
*/
void check(Status[] tested, String workingCopyPath, boolean checkRepos)
throws IOException
{
// clear the touched flag of all items
for (Item item : items.values())
{
item.touched = false;
}
String normalizeWCPath =
workingCopyPath.replace(File.separatorChar, '/');
// check all result Staus object
for (Status status : tested)
{
String path = status.getPath();
Assert.assertTrue("status path starts not with working copy path",
path.startsWith(normalizeWCPath));
// we calculate the relative path to the working copy root
if (path.length() > workingCopyPath.length() + 1)
{
Assert.assertEquals("missing '/' in status path",
path.charAt(workingCopyPath.length()), '/');
path = path.substring(workingCopyPath.length() + 1);
}
else
// this is the working copy root itself
path = "";
Item item = items.get(path);
Assert.assertNotNull("status not found in working copy: " + path,
item);
Assert.assertEquals("wrong text status in working copy: " + path,
item.textStatus, status.getTextStatus());
if (item.workingCopyRev != -1)
Assert.assertEquals("wrong revision number in working copy: "
+ path,
item.workingCopyRev, status.getRevisionNumber());
Assert.assertEquals("lock status wrong: " + path,
item.isLocked, status.isLocked());
Assert.assertEquals("switch status wrong: " + path,
item.isSwitched, status.isSwitched());
Assert.assertEquals("wrong prop status in working copy: " + path,
item.propStatus, status.getPropStatus());
if (item.myContent != null)
{
Assert.assertEquals("state says file, working copy not: " + path,
status.getNodeKind(),
item.nodeKind == null ? NodeKind.file : item.nodeKind);
if (status.getTextStatus() == Status.Kind.normal ||
item.checkContent)
{
File input = new File(workingCopyPath, item.myPath);
Reader rd =
new InputStreamReader(new FileInputStream(input));
StringBuffer buffer = new StringBuffer();
int ch;
while ((ch = rd.read()) != -1)
{
buffer.append((char) ch);
}
rd.close();
Assert.assertEquals("content mismatch: " + path,
buffer.toString(), item.myContent);
}
}
else
{
Assert.assertEquals("state says dir, working copy not: " + path,
status.getNodeKind(),
item.nodeKind == null ? NodeKind.dir : item.nodeKind);
}
if (checkRepos)
{
Assert.assertEquals("Last commit revisions for OOD path '"
+ item.myPath + "' don't match:",
item.reposLastCmtRevision,
status.getReposLastCmtRevisionNumber());
Assert.assertEquals("Last commit kinds for OOD path '"
+ item.myPath + "' don't match:",
item.reposKind, status.getReposKind());
// Only the last committed rev and kind is available for
( run in 1.564 second using v1.01-cache-2.11-cpan-39bf76dae61 )