/** * Test the basic SVNClient.fileContent functionality. * @throws Throwable */ public void testBasicCatStream() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // modify A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.print("some text"); pw.close(); // get the content from the repository ByteArrayOutputStream baos = new ByteArrayOutputStream(); client.streamFileContent(thisTest.getWCPath() + "/A/mu", null, null, 100, baos); byte[] content = baos.toByteArray(); byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); }
/** * Test the basic SVNClient.fileContent functionality. * @throws Throwable */ public void testBasicCatStream() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // modify A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.print("some text"); pw.close(); // get the content from the repository ByteArrayOutputStream baos = new ByteArrayOutputStream(); client.streamFileContent(thisTest.getWCPath() + "/A/mu", null, null, 100, baos); byte[] content = baos.toByteArray(); byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); }
/** * Test the basic SVNClient.fileContent functionality. * @throws Throwable */ public void testBasicCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // modify A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.print("some text"); pw.close(); // get the content from the repository byte[] content = client.fileContent(thisTest.getWCPath()+"/A/mu", null); byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); }
WC wc = thisTest.getWc();
muWriter.print("appended mu text"); muWriter.close(); thisTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified); thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.missing); thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted); thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted); thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted); thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted); thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.normal);
thisTest.getWc().setItemContent("iota", greekWC.getItemContent("A/D/gamma")); thisTest.getWc().setItemIsSwitched("iota", true); client.doSwitch(iotaPath, gammaUrl, null, true); thisTest.getWc().setItemIsSwitched("A/D/H",true); thisTest.getWc().removeItem("A/D/H/chi"); thisTest.getWc().removeItem("A/D/H/omega"); thisTest.getWc().removeItem("A/D/H/psi"); thisTest.getWc().addItem("A/D/H/pi", thisTest.getWc().getItemContent("A/D/G/pi")); thisTest.getWc().addItem("A/D/H/rho", thisTest.getWc().getItemContent("A/D/G/rho")); thisTest.getWc().addItem("A/D/H/tau", thisTest.getWc().getItemContent("A/D/G/tau")); client.doSwitch(adhPath, adgURL, null, true);
thisTest.getWc().setItemContent("iota", greekWC.getItemContent("A/D/gamma")); thisTest.getWc().setItemIsSwitched("iota", true); client.doSwitch(iotaPath, gammaUrl, null, true); thisTest.getWc().setItemIsSwitched("A/D/H",true); thisTest.getWc().removeItem("A/D/H/chi"); thisTest.getWc().removeItem("A/D/H/omega"); thisTest.getWc().removeItem("A/D/H/psi"); thisTest.getWc().addItem("A/D/H/pi", thisTest.getWc().getItemContent("A/D/G/pi")); thisTest.getWc().addItem("A/D/H/rho", thisTest.getWc().getItemContent("A/D/G/rho")); thisTest.getWc().addItem("A/D/H/tau", thisTest.getWc().getItemContent("A/D/G/tau")); client.doSwitch(adhPath, adgURL, null, true);
thisTest.getWc().addItem("dirA", null); thisTest.getWc().setItemWorkingCopyRevision("dirA",2); thisTest.getWc().addItem("dirA/dirB", null); thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB",2); thisTest.getWc().addItem("dirA/dirB/new_file", "some text"); thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB/new_file",2);
thisTest.getWc().addItem("dirA", null); thisTest.getWc().setItemWorkingCopyRevision("dirA",2); thisTest.getWc().addItem("dirA/dirB", null); thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB",2); thisTest.getWc().addItem("dirA/dirB/new_file", "some text"); thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB/new_file",2);
/** * 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; }
/** * 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(); }
/** * 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; }
/** * Test the basis SVNClient.add functionality with files that * should be ignored. * @throws Throwable */ public void testBasicAddIgnores() throws Throwable { // create working copy OneTest thisTest = new OneTest(); // create dir File dir = new File(thisTest.getWorkingCopy(), "dir"); dir.mkdir(); // create dir/foo.c File fileC = new File(dir, "foo.c"); new FileOutputStream(fileC).close(); // create dir/foo.o (should be ignored) File fileO = new File(dir, "foo.o"); new FileOutputStream(fileO).close(); // add dir client.add(dir.getAbsolutePath(), true); thisTest.getWc().addItem("dir", null); thisTest.getWc().setItemTextStatus("dir",Status.Kind.added); thisTest.getWc().addItem("dir/foo.c", ""); thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added); thisTest.getWc().addItem("dir/foo.o", ""); thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored); thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown); // test the working copy status 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(); }
/** * Test the basis SVNClient.add functionality with files that * should be ignored. * @throws Throwable */ public void testBasicAddIgnores() throws Throwable { // create working copy OneTest thisTest = new OneTest(); // create dir File dir = new File(thisTest.getWorkingCopy(), "dir"); dir.mkdir(); // create dir/foo.c File fileC = new File(dir, "foo.c"); new FileOutputStream(fileC).close(); // create dir/foo.o (should be ignored) File fileO = new File(dir, "foo.o"); new FileOutputStream(fileO).close(); // add dir client.add(dir.getAbsolutePath(), true); thisTest.getWc().addItem("dir", null); thisTest.getWc().setItemTextStatus("dir",Status.Kind.added); thisTest.getWc().addItem("dir/foo.c", ""); thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added); thisTest.getWc().addItem("dir/foo.o", ""); thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored); thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown); // test the working copy status thisTest.checkStatus(); }
/** * Test the basic SVNClient.list functionality. * @throws Throwable */ public void testBasicLs() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // list the repository root dir DirEntry[] entries = client.list(thisTest.getWCPath(), null, false); thisTest.getWc().check(entries, "", false); // list directory A entries = client.list(thisTest.getWCPath() + "/A", null, false); thisTest.getWc().check(entries, "A", false); // list directory A in BASE revision entries = client.list(thisTest.getWCPath() + "/A", Revision.BASE, false); thisTest.getWc().check(entries, "A", false); // list file A/mu entries = client.list(thisTest.getWCPath() + "/A/mu", null, false); thisTest.getWc().check(entries, "A/mu"); }
/** * Test the basic SVNClient.list functionality. * @throws Throwable */ public void testBasicLs() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // list the repository root dir DirEntry[] entries = client.list(thisTest.getWCPath(), null, false); thisTest.getWc().check(entries, "", false); // list directory A entries = client.list(thisTest.getWCPath() + "/A", null, false); thisTest.getWc().check(entries, "A", false); // list directory A in BASE revision entries = client.list(thisTest.getWCPath() + "/A", Revision.BASE, false); thisTest.getWc().check(entries, "A", false); // list file A/mu entries = client.list(thisTest.getWCPath() + "/A/mu", null, false); thisTest.getWc().check(entries, "A/mu"); }
/** * Test the basic SVNClient.fileContent functionality. * @throws Throwable */ public void testBasicCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // modify A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.print("some text"); pw.close(); // get the content from the repository byte[] content = client.fileContent(thisTest.getWCPath()+"/A/mu", null); byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); }