diff options
author | André Dietisheim <adietish@redhat.com> | 2013-02-01 15:58:44 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2013-03-21 00:30:30 +0100 |
commit | a31920555f075c028f087b2e174293e1f11d714d (patch) | |
tree | 6a62dbfe6c53d172e2ffda2196cc0f901e17f5a1 /org.eclipse.jgit.http.test | |
parent | 8fcde4b31b36205ea6ef673808489943e4aca3ef (diff) | |
download | jgit-a31920555f075c028f087b2e174293e1f11d714d.tar.gz jgit-a31920555f075c028f087b2e174293e1f11d714d.zip |
Allow users to show server messages while pushing
Allow users to provide their OutputStream (via Transport#
push(monitor, refUpdates, out)) so that server messages can be written
to it (in SideBandInputStream) while they're coming in.
CQ: 7065
Bug: 398404
Change-Id: I670782784b38702d52bca98203909aca0496d1c0
Signed-off-by: Andre Dietisheim <andre.dietisheim@gmail.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.http.test')
-rw-r--r-- | org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java index c9045763c6..155a43399c 100644 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java @@ -47,6 +47,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -180,4 +182,40 @@ public class HookMessageTest extends HttpTestCase { + "come back next year!\n", // result.getMessages()); } + + @Test + public void testPush_HookMessagesToOutputStream() throws Exception { + final TestRepository src = createTestRepository(); + final RevBlob Q_txt = src.blob("new text"); + final RevCommit Q = src.commit().add("Q", Q_txt).create(); + final Repository db = src.getRepository(); + final String dstName = Constants.R_HEADS + "new.branch"; + Transport t; + PushResult result; + + t = Transport.open(db, remoteURI); + OutputStream out = new ByteArrayOutputStream(); + try { + final String srcExpr = Q.name(); + final boolean forceUpdate = false; + final String localName = null; + final ObjectId oldId = null; + + RemoteRefUpdate update = new RemoteRefUpdate(src.getRepository(), + srcExpr, dstName, forceUpdate, localName, oldId); + result = t.push(NullProgressMonitor.INSTANCE, + Collections.singleton(update), out); + } finally { + t.close(); + } + + String expectedMessage = "message line 1\n" // + + "error: no soup for you!\n" // + + "come back next year!\n"; + assertEquals(expectedMessage, // + result.getMessages()); + + assertEquals(expectedMessage, out.toString()); + } + } |