ReceivePackAdvertiseRefsHookTest#testSuccess: Open TransportLocal in t-w-r
Change-Id: I198ff2ff36de482445141b5ce489204a9c2f4933 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
a9bbbc0965
commit
2de9b6c0bb
|
@ -199,6 +199,23 @@ public void advertiseRefs(UploadPack uploadPack)
|
||||||
assertFalse(haves.get().contains(P));
|
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
|
@Test
|
||||||
public void testSuccess() throws Exception {
|
public void testSuccess() throws Exception {
|
||||||
// Manually force a delta of an object so we reuse it later.
|
// Manually force a delta of an object so we reuse it later.
|
||||||
|
@ -230,19 +247,7 @@ public void testSuccess() throws Exception {
|
||||||
|
|
||||||
// Push this new content to the remote, doing strict validation.
|
// Push this new content to the remote, doing strict validation.
|
||||||
//
|
//
|
||||||
TransportLocal t = new TransportLocal(src, uriOf(dst), dst.getDirectory()) {
|
PushResult r;
|
||||||
@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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
RemoteRefUpdate u = new RemoteRefUpdate( //
|
RemoteRefUpdate u = new RemoteRefUpdate( //
|
||||||
src, //
|
src, //
|
||||||
R_MASTER, // src name
|
R_MASTER, // src name
|
||||||
|
@ -251,12 +256,9 @@ ReceivePack createReceivePack(final Repository db) {
|
||||||
null, // local tracking branch
|
null, // local tracking branch
|
||||||
null // expected id
|
null // expected id
|
||||||
);
|
);
|
||||||
PushResult r;
|
try (TransportLocal t = newTransportLocalWithStrictValidation()) {
|
||||||
try {
|
|
||||||
t.setPushThin(true);
|
t.setPushThin(true);
|
||||||
r = t.push(PM, Collections.singleton(u));
|
r = t.push(PM, Collections.singleton(u));
|
||||||
} finally {
|
|
||||||
t.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNotNull("have result", r);
|
assertNotNull("have result", r);
|
||||||
|
|
Loading…
Reference in New Issue