diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-14 13:05:41 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-15 07:57:02 +0900 |
commit | 2de9b6c0bbfc6536805a5325ff786951fcd539af (patch) | |
tree | 3ce4f21a0028244db15348c0274d9e562911bd9c /org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java | |
parent | a9bbbc096536d8a85618fdf2882809631c63bf18 (diff) | |
download | jgit-2de9b6c0bbfc6536805a5325ff786951fcd539af.tar.gz jgit-2de9b6c0bbfc6536805a5325ff786951fcd539af.zip |
ReceivePackAdvertiseRefsHookTest#testSuccess: Open TransportLocal in t-w-r
Change-Id: I198ff2ff36de482445141b5ce489204a9c2f4933
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java index 8ef87cb3c1..7aae7b0c32 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java @@ -199,6 +199,23 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas assertFalse(haves.get().contains(P)); } + private TransportLocal newTransportLocalWithStrictValidation() + throws Exception { + return new TransportLocal(src, uriOf(dst), dst.getDirectory()) { + @Override + ReceivePack createReceivePack(final Repository db) { + db.close(); + dst.incrementOpen(); + + final ReceivePack rp = super.createReceivePack(dst); + rp.setCheckReceivedObjects(true); + rp.setCheckReferencedObjectsAreReachable(true); + rp.setAdvertiseRefsHook(new HidePrivateHook()); + return rp; + } + }; + } + @Test public void testSuccess() throws Exception { // Manually force a delta of an object so we reuse it later. @@ -230,19 +247,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas // Push this new content to the remote, doing strict validation. // - TransportLocal t = new TransportLocal(src, uriOf(dst), dst.getDirectory()) { - @Override - ReceivePack createReceivePack(final Repository db) { - db.close(); - dst.incrementOpen(); - - final ReceivePack rp = super.createReceivePack(dst); - rp.setCheckReceivedObjects(true); - rp.setCheckReferencedObjectsAreReachable(true); - rp.setAdvertiseRefsHook(new HidePrivateHook()); - return rp; - } - }; + PushResult r; RemoteRefUpdate u = new RemoteRefUpdate( // src, // R_MASTER, // src name @@ -251,12 +256,9 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas null, // local tracking branch null // expected id ); - PushResult r; - try { + try (TransportLocal t = newTransportLocalWithStrictValidation()) { t.setPushThin(true); r = t.push(PM, Collections.singleton(u)); - } finally { - t.close(); } assertNotNull("have result", r); |