/** * Append the text <code>toAppend</code> to the WC file at * <code>path</code>, and update the expected WC state * accordingly. * * @param thisTest The test whose expected WC to tweak. * @param path The working copy-relative path to change. * @param toAppend The text to append to <code>path</code>. * @param rev The expected revision number for thisTest's WC. * @return The file created during the setup. * @since 1.5 */ private File appendText(OneTest thisTest, String path, String toAppend, int rev) throws FileNotFoundException { File f = new File(thisTest.getWorkingCopy(), path); PrintWriter writer = new PrintWriter(new FileOutputStream(f, true)); writer.print(toAppend); writer.close(); if (rev > 0) { WC wc = thisTest.getWc(); wc.setItemWorkingCopyRevision(path, rev); wc.setItemContent(path, wc.getItemContent(path) + toAppend); } addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(), path, NodeKind.file, CommitItemStateFlags.TextMods); return f; }
/** * Append the text <code>toAppend</code> to the WC file at * <code>path</code>, and update the expected WC state * accordingly. * * @param thisTest The test whose expected WC to tweak. * @param path The working copy-relative path to change. * @param toAppend The text to append to <code>path</code>. * @param rev The expected revision number for thisTest's WC. * @return The file created during the setup. * @since 1.5 */ private File appendText(OneTest thisTest, String path, String toAppend, int rev) throws FileNotFoundException { File f = new File(thisTest.getWorkingCopy(), path); PrintWriter writer = new PrintWriter(new FileOutputStream(f, true)); writer.print(toAppend); writer.close(); if (rev > 0) { WC wc = thisTest.getWc(); wc.setItemWorkingCopyRevision(path, rev); wc.setItemContent(path, wc.getItemContent(path) + toAppend); } addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(), path, NodeKind.file, CommitItemStateFlags.TextMods); return f; }
client.doImport(dir.getAbsolutePath(), thisTest.getUrl()+"/dir", "log message for import", true);
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 | addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(), "A/B/E/" + fileName, NodeKind.file, CommitItemStateFlags.Delete); thisTest.checkStatus(); assertExpectedSuggestion(thisTest.getUrl() + "/A/B/E/alpha", "A/B/F/alpha", thisTest);
removeDirOrFile(new File(secondWC)); client.checkout(thisTest.getUrl(), secondWC, null, null, Depth.empty, false, true);
String modUrl = thisTest.getUrl() + "/A"; Revision unspec = new Revision(RevisionKind.unspecified); client.merge(modUrl, Revision.HEAD, addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(), "branches/A", NodeKind.dir, CommitItemStateFlags.PropMods); addExpectedCommitItem(thisTest.getWCPath(), thisTest.getUrl(), "branches/A/mu", NodeKind.file, CommitItemStateFlags.TextMods);
null, "new_file", NodeKind.none, CommitItemStateFlags.Add); client.doImport(file.getAbsolutePath(), thisTest.getUrl()+"/dirA/dirB/new_file", "log message for new import", true);
/** * Setup a test with a WC. In the repository, create a * "/branches" directory, with a branch of "/A" underneath it. * Update the WC to reflect these modifications. * @return This test. */ private OneTest setupAndPerformMerge() throws Exception { OneTest thisTest = new OneTest(); // Verify that there are initially no potential merge sources. String[] suggestedSrcs = client.suggestMergeSources(thisTest.getWCPath(), Revision.WORKING); assertNotNull(suggestedSrcs); assertEquals(0, suggestedSrcs.length); // create branches directory in the repository (r2) addExpectedCommitItem(null, thisTest.getUrl(), "branches", NodeKind.none, CommitItemStateFlags.Add); client.mkdir(new String[]{thisTest.getUrl() + "/branches"}, "log_msg"); // copy A to branches (r3) addExpectedCommitItem(null, thisTest.getUrl(), "branches/A", NodeKind.none, CommitItemStateFlags.Add); client.copy(thisTest.getUrl() + "/A", thisTest.getUrl() + "/branches/A", "create A branch", Revision.HEAD); // update the WC (to r3) so that it has the branches folder client.update(thisTest.getWCPath(), Revision.HEAD, true); return thisTest; }
/** * Assert that the first merge source suggested for * <code>destPath</code> at {@link Revision#WORKING} and {@link * Revision#HEAD} is equivalent to <code>expectedSrc</code>. * @exception SubversionException If retrieval of the copy source fails. * @since 1.5 */ private void assertExpectedSuggestion(String expectedSrc, String destPath, OneTest thisTest) throws SubversionException { String wcPath = fileToSVNPath(new File(thisTest.getWCPath(), destPath), false); String[] suggestions = client.suggestMergeSources(wcPath, Revision.WORKING); assertNotNull(suggestions); assertTrue(suggestions.length >= 1); assertTrue("Unexpected copy source path, expected " + expectedSrc + ", got " + suggestions[0], expectedSrc.equals(suggestions[0])); // Same test using URL String url = thisTest.getUrl() + "/" + destPath; suggestions = client.suggestMergeSources(url, Revision.HEAD); assertNotNull(suggestions); assertTrue(suggestions.length >= 1); assertTrue("Unexpected copy source path, expected " + expectedSrc + ", got " + suggestions[0], expectedSrc.equals(suggestions[0])); }
/** * Setup a test with a WC. In the repository, create a * "/branches" directory, with a branch of "/A" underneath it. * Update the WC to reflect these modifications. * @return This test. */ private OneTest setupAndPerformMerge() throws Exception { OneTest thisTest = new OneTest(); // Verify that there are initially no potential merge sources. String[] suggestedSrcs = client.suggestMergeSources(thisTest.getWCPath(), Revision.WORKING); assertNotNull(suggestedSrcs); assertEquals(0, suggestedSrcs.length); // create branches directory in the repository (r2) addExpectedCommitItem(null, thisTest.getUrl(), "branches", NodeKind.none, CommitItemStateFlags.Add); client.mkdir(new String[]{thisTest.getUrl() + "/branches"}, "log_msg"); // copy A to branches (r3) addExpectedCommitItem(null, thisTest.getUrl(), "branches/A", NodeKind.none, CommitItemStateFlags.Add); client.copy(thisTest.getUrl() + "/A", thisTest.getUrl() + "/branches/A", "create A branch", Revision.HEAD); // update the WC (to r3) so that it has the branches folder client.update(thisTest.getWCPath(), Revision.HEAD, true); return thisTest; }
null, "new_file", NodeKind.none, CommitItemStateFlags.Add); client.doImport(file.getAbsolutePath(), thisTest.getUrl()+"/dirA/dirB/new_file", "log message for new import", true);
/** * 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 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(); }
/** * Assert that the first merge source suggested for * <code>destPath</code> at {@link Revision#WORKING} and {@link * Revision#HEAD} is equivalent to <code>expectedSrc</code>. * @exception SubversionException If retrieval of the copy source fails. * @since 1.5 */ private void assertExpectedSuggestion(String expectedSrc, String destPath, OneTest thisTest) throws SubversionException { String wcPath = fileToSVNPath(new File(thisTest.getWCPath(), destPath), false); String[] suggestions = client.suggestMergeSources(wcPath, Revision.WORKING); assertNotNull(suggestions); assertTrue(suggestions.length >= 1); assertTrue("Unexpected copy source path, expected " + expectedSrc + ", got " + suggestions[0], expectedSrc.equals(suggestions[0])); // Same test using URL String url = thisTest.getUrl() + "/" + destPath; suggestions = client.suggestMergeSources(url, Revision.HEAD); assertNotNull(suggestions); assertTrue(suggestions.length >= 1); assertTrue("Unexpected copy source path, expected " + expectedSrc + ", got " + suggestions[0], expectedSrc.equals(suggestions[0])); }
/** * Test the {@link SVNClientInterface.diffSummarize()} API. * @since 1.5 */ public void testDiffSummarize() throws SubversionException, IOException { OneTest thisTest = new OneTest(false); DiffSummaries summaries = new DiffSummaries(); // Perform a recursive diff summary, ignoring ancestry. client.diffSummarize(thisTest.getUrl(), new Revision.Number(0), thisTest.getUrl(), Revision.HEAD, Depth.infinity, null, false, summaries); assertExpectedDiffSummaries(summaries); summaries.clear(); // Perform a recursive diff summary with a peg revision, // ignoring ancestry. client.diffSummarize(thisTest.getUrl(), Revision.HEAD, new Revision.Number(0), Revision.HEAD, Depth.infinity, null, false, summaries); assertExpectedDiffSummaries(summaries); }
/** * Test the {@link SVNClientInterface.diffSummarize()} API. * @since 1.5 */ public void testDiffSummarize() throws SubversionException, IOException { OneTest thisTest = new OneTest(false); DiffSummaries summaries = new DiffSummaries(); // Perform a recursive diff summary, ignoring ancestry. client.diffSummarize(thisTest.getUrl(), new Revision.Number(0), thisTest.getUrl(), Revision.HEAD, Depth.infinity, null, false, summaries); assertExpectedDiffSummaries(summaries); summaries.clear(); // Perform a recursive diff summary with a peg revision, // ignoring ancestry. client.diffSummarize(thisTest.getUrl(), Revision.HEAD, new Revision.Number(0), Revision.HEAD, Depth.infinity, null, false, summaries); assertExpectedDiffSummaries(summaries); }
/** * constructor for create a copy * @param orig original test * @param append append this to the directory name of the original * test * @throws Exception */ private OneTest(OneTest orig, String append) throws SubversionException, IOException { this.testName = testBaseName + testCounter + append; repository = orig.getRepository(); url = orig.getUrl(); wc = orig.wc.copy(); workingCopy = createInitialWorkingCopy(repository); }
/** * constructor for create a copy * @param orig original test * @param append append this to the directory name of the original * test * @throws Exception */ private OneTest(OneTest orig, String append) throws SubversionException, IOException { this.testName = testBaseName + testCounter + append; repository = orig.getRepository(); url = orig.getUrl(); wc = orig.wc.copy(); workingCopy = createInitialWorkingCopy(repository); }