Bladeren bron

HookMessageTest: Open Transport in try-with-resource

Change-Id: Ie58b01a8a78e4f42a3b913708a545687c5c9f96b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
tags/v4.11.0.201803080745-r
David Pursehouse 6 jaren geleden
bovenliggende
commit
b5115f6897
1 gewijzigde bestanden met toevoegingen van 2 en 10 verwijderingen
  1. 2
    10
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java

+ 2
- 10
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java Bestand weergeven

final RevCommit Q = src.commit().add("Q", Q_txt).create(); final RevCommit Q = src.commit().add("Q", Q_txt).create();
final Repository db = src.getRepository(); final Repository db = src.getRepository();
final String dstName = Constants.R_HEADS + "new.branch"; final String dstName = Constants.R_HEADS + "new.branch";
Transport t;
PushResult result; PushResult result;


t = Transport.open(db, remoteURI);
try {
try (Transport t = Transport.open(db, remoteURI)) {
final String srcExpr = Q.name(); final String srcExpr = Q.name();
final boolean forceUpdate = false; final boolean forceUpdate = false;
final String localName = null; final String localName = null;
srcExpr, dstName, forceUpdate, localName, oldId); srcExpr, dstName, forceUpdate, localName, oldId);
result = t.push(NullProgressMonitor.INSTANCE, Collections result = t.push(NullProgressMonitor.INSTANCE, Collections
.singleton(update)); .singleton(update));
} finally {
t.close();
} }


assertTrue(remoteRepository.hasObject(Q_txt)); assertTrue(remoteRepository.hasObject(Q_txt));
final RevCommit Q = src.commit().add("Q", Q_txt).create(); final RevCommit Q = src.commit().add("Q", Q_txt).create();
final Repository db = src.getRepository(); final Repository db = src.getRepository();
final String dstName = Constants.R_HEADS + "new.branch"; final String dstName = Constants.R_HEADS + "new.branch";
Transport t;
PushResult result; PushResult result;


t = Transport.open(db, remoteURI);
OutputStream out = new ByteArrayOutputStream(); OutputStream out = new ByteArrayOutputStream();
try {
try (Transport t = Transport.open(db, remoteURI)) {
final String srcExpr = Q.name(); final String srcExpr = Q.name();
final boolean forceUpdate = false; final boolean forceUpdate = false;
final String localName = null; final String localName = null;
srcExpr, dstName, forceUpdate, localName, oldId); srcExpr, dstName, forceUpdate, localName, oldId);
result = t.push(NullProgressMonitor.INSTANCE, result = t.push(NullProgressMonitor.INSTANCE,
Collections.singleton(update), out); Collections.singleton(update), out);
} finally {
t.close();
} }


String expectedMessage = "message line 1\n" // String expectedMessage = "message line 1\n" //

Laden…
Annuleren
Opslaan