/** * 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)); }
/** * 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 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 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()); } }
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) { } }
/** * 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 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()); } }
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 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)); }
/** * test the basic SVNClient.isAdminDirectory functionality * @throws Throwable * @since 1.2 */ public void testBasicIsAdminDirectory() throws Throwable { // build the test setup OneTest thisTest = new OneTest(); Notify2 notify = new Notify2() { public void onNotify(NotifyInformation info) { client.isAdminDirectory(".svn"); } }; client.notification2(notify); // update the test assertEquals("wrong revision number from update", client.update(thisTest.getWCPath(), null, true), 1); }
/** * test the basic SVNClient.isAdminDirectory functionality * @throws Throwable * @since 1.2 */ public void testBasicIsAdminDirectory() throws Throwable { // build the test setup OneTest thisTest = new OneTest(); Notify2 notify = new Notify2() { public void onNotify(NotifyInformation info) { client.isAdminDirectory(".svn"); } }; client.notification2(notify); // update the test assertEquals("wrong revision number from update", client.update(thisTest.getWCPath(), null, true), 1); }
/** * Test the basic SVNClient.info functionality. * @throws Throwable */ public void testBasicInfo() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // get the item information and test it Info info = client.info(thisTest.getWCPath()+"/A/mu"); assertEquals("wrong revision from info", 1, info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", ScheduleKind.normal, info.getSchedule()); assertEquals("wrong node kind from info", NodeKind.file, info.getNodeKind()); }
/** * Test the basic SVNClient.info functionality. * @throws Throwable */ public void testBasicInfo() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); // get the item information and test it Info info = client.info(thisTest.getWCPath()+"/A/mu"); assertEquals("wrong revision from info", 1, info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", ScheduleKind.normal, info.getSchedule()); assertEquals("wrong node kind from info", NodeKind.file, info.getNodeKind()); }
/** * 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.getVersionInfo functionality. * @throws Throwable * @since 1.2 */ public void testBasicVersionInfo() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); assertEquals("wrong version info", "1", client.getVersionInfo(thisTest.getWCPath(), null, false)); }
/** * Test the basic SVNClient.getVersionInfo functionality. * @throws Throwable * @since 1.2 */ public void testBasicVersionInfo() throws Throwable { // create the working copy OneTest thisTest = new OneTest(); assertEquals("wrong version info", "1", client.getVersionInfo(thisTest.getWCPath(), null, false)); }