From 85ac3c599616e1ebdb55b0169eb3734f8006f52b Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 30 Nov 2020 16:44:05 +0100 Subject: [PATCH] Use new protocol version constants Change-Id: Icd6b876e392c55a7322a990ac7f618250b732b4b Signed-off-by: Matthias Sohn --- .../jgit/transport/UploadPackTest.java | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index cdf9d661d..5045e9464 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -437,8 +437,9 @@ private ByteArrayInputStream uploadPackV2( Consumer postConstructionSetup, String... inputLines) throws Exception { - ByteArrayInputStream recvStream = - uploadPackSetup("2", postConstructionSetup, inputLines); + ByteArrayInputStream recvStream = uploadPackSetup( + TransferConfig.ProtocolVersion.V2.version(), + postConstructionSetup, inputLines); PacketLineIn pckIn = new PacketLineIn(recvStream); // drain capabilities @@ -478,9 +479,11 @@ public void onFetch(FetchV2Request req) { @Test public void testV2Capabilities() throws Exception { TestV2Hook hook = new TestV2Hook(); - ByteArrayInputStream recvStream = uploadPackSetup( "2", - (UploadPack up) -> {up.setProtocolV2Hook(hook);}, - PacketLineIn.end()); + ByteArrayInputStream recvStream = uploadPackSetup( + TransferConfig.ProtocolVersion.V2.version(), + (UploadPack up) -> { + up.setProtocolV2Hook(hook); + }, PacketLineIn.end()); PacketLineIn pckIn = new PacketLineIn(recvStream); assertThat(hook.capabilitiesRequest, notNullValue()); assertThat(pckIn.readString(), is("version 2")); @@ -500,8 +503,9 @@ public void testV2Capabilities() throws Exception { private void checkAdvertisedIfAllowed(String configSection, String configName, String fetchCapability) throws Exception { server.getConfig().setBoolean(configSection, null, configName, true); - ByteArrayInputStream recvStream = - uploadPackSetup("2", null, PacketLineIn.end()); + ByteArrayInputStream recvStream = uploadPackSetup( + TransferConfig.ProtocolVersion.V2.version(), null, + PacketLineIn.end()); PacketLineIn pckIn = new PacketLineIn(recvStream); assertThat(pckIn.readString(), is("version 2")); @@ -524,8 +528,9 @@ private void checkAdvertisedIfAllowed(String configSection, String configName, private void checkUnadvertisedIfUnallowed(String configSection, String configName, String fetchCapability) throws Exception { server.getConfig().setBoolean(configSection, null, configName, false); - ByteArrayInputStream recvStream = - uploadPackSetup("2", null, PacketLineIn.end()); + ByteArrayInputStream recvStream = uploadPackSetup( + TransferConfig.ProtocolVersion.V2.version(), null, + PacketLineIn.end()); PacketLineIn pckIn = new PacketLineIn(recvStream); assertThat(pckIn.readString(), is("version 2")); @@ -576,8 +581,9 @@ public void testV2CapabilitiesAdvertiseSidebandAll() throws Exception { public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() throws Exception { server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true); server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false); - ByteArrayInputStream recvStream = - uploadPackSetup("2", null, PacketLineIn.end()); + ByteArrayInputStream recvStream = uploadPackSetup( + TransferConfig.ProtocolVersion.V2.version(), null, + PacketLineIn.end()); PacketLineIn pckIn = new PacketLineIn(recvStream); assertThat(pckIn.readString(), is("version 2")); @@ -741,7 +747,10 @@ public void testV2LsRefsServerOptions() throws Exception { PacketLineIn.end() }; TestV2Hook testHook = new TestV2Hook(); - uploadPackSetup("2", (UploadPack up) -> {up.setProtocolV2Hook(testHook);}, lines); + uploadPackSetup(TransferConfig.ProtocolVersion.V2.version(), + (UploadPack up) -> { + up.setProtocolV2Hook(testHook); + }, lines); LsRefsV2Request req = testHook.lsRefsRequest; assertEquals(2, req.getServerOptions().size()); @@ -1561,7 +1570,10 @@ public void testV2FetchServerOptions() throws Exception { PacketLineIn.end() }; TestV2Hook testHook = new TestV2Hook(); - uploadPackSetup("2", (UploadPack up) -> {up.setProtocolV2Hook(testHook);}, lines); + uploadPackSetup(TransferConfig.ProtocolVersion.V2.version(), + (UploadPack up) -> { + up.setProtocolV2Hook(testHook); + }, lines); FetchV2Request req = testHook.fetchRequest; assertNotNull(req);