Replace most usages of PacketLineIn.END with PacketLineIn.end()

PacketLineIn.END is only referenced in tests. Replace most of those
with a new package visible end() method.

Remaining usages of PacketLineIn.END are in the form:

  while ((line = pckIn.readString()) != PacketLineIn.END) {

and are not trivial replacements, hence are not touched in this change.

Change-Id: Id77c5321ddcad127130b246bde8f08736e60e1ea
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2019-06-02 12:50:34 +09:00
parent e99aaa5f79
commit e0133b9440
4 changed files with 95 additions and 81 deletions

View File

@ -90,7 +90,7 @@ public void testRecvWantsWithCapabilities()
"4624442d68ee402a94364191085b77137618633e", "thin-pack",
"no-progress", "include-tag", "ofs-delta", "\n"),
"want f900c8326a43303685c46b279b9f70411bff1a4b\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities()
@ -114,7 +114,7 @@ public void testRecvWantsWithAgent()
"4624442d68ee402a94364191085b77137618633e", "thin-pack",
"agent=JGit.test/0.0.1", "\n"),
"want f900c8326a43303685c46b279b9f70411bff1a4b\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities()
@ -136,7 +136,7 @@ public void testRecvWantsWithoutCapabilities()
PacketLineIn pckIn = formatAsPacketLine(
"want 4624442d68ee402a94364191085b77137618633e\n",
"want f900c8326a43303685c46b279b9f70411bff1a4b\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities().isEmpty());
@ -151,7 +151,7 @@ public void testRecvWantsDeepen()
PacketLineIn pckIn = formatAsPacketLine(
"want 4624442d68ee402a94364191085b77137618633e\n",
"want f900c8326a43303685c46b279b9f70411bff1a4b\n", "deepen 3\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities().isEmpty());
@ -168,7 +168,7 @@ public void testRecvWantsShallow()
"want 4624442d68ee402a94364191085b77137618633e\n",
"want f900c8326a43303685c46b279b9f70411bff1a4b\n",
"shallow 4b643d0ef739a1b494e7d6926d8d8ed80d35edf4\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities().isEmpty());
@ -186,7 +186,7 @@ public void testRecvWantsFilter()
"want 4624442d68ee402a94364191085b77137618633e\n",
"want f900c8326a43303685c46b279b9f70411bff1a4b\n",
"filter blob:limit=13000\n",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV0Parser parser = new ProtocolV0Parser(defaultConfig());
FetchV0Request request = parser.recvWants(pckIn);
assertTrue(request.getClientCapabilities().isEmpty());

View File

@ -148,7 +148,7 @@ public void testFetchBasicArguments()
"want f900c8326a43303685c46b279b9f70411bff1a4b",
"have 554f6e41067b9e3e565b6988a8294fac1cb78f4b",
"have abc760ab9ad72f08209943251b36cb886a578f87", "done",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -178,7 +178,7 @@ public void testFetchWithShallow_deepen() throws IOException {
"deepen-relative",
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -197,7 +197,7 @@ public void testFetchWithShallow_deepenNot() throws IOException {
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
"deepen-not a08595f76159b09d57553e37a5123f1091bb13e7",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -214,7 +214,7 @@ public void testFetchWithShallow_deepenSince() throws IOException {
"shallow 28274d02c489f4c7e68153056e9061a46f62d7a0",
"shallow 145e683b229dcab9d0e2ccb01b386f9ecc17d29d",
"deepen-since 123123123",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -228,7 +228,7 @@ public void testFetchWithShallow_deepenSince() throws IOException {
public void testFetchWithNoneFilter() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"filter blob:none",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -240,7 +240,7 @@ public void testFetchWithNoneFilter() throws IOException {
public void testFetchWithBlobSizeFilter() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"filter blob:limit=15",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -252,7 +252,7 @@ public void testFetchWithBlobSizeFilter() throws IOException {
public void testFetchWithTreeDepthFilter() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"filter tree:3",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
@ -265,7 +265,7 @@ public void testFetchMustNotHaveMultipleFilters() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"filter blob:none",
"filter blob:limit=12",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
@ -276,7 +276,7 @@ public void testFetchMustNotHaveMultipleFilters() throws IOException {
@Test
public void testFetchFilterWithoutAllowFilter() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"filter blob:limit=12", PacketLineIn.END);
"filter blob:limit=12", PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
@ -294,7 +294,7 @@ public void testFetchWithRefInWant() throws Exception {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"want e4980cdc48cfa1301493ca94eb70523f6788b819",
"want-ref refs/heads/branchA",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowRefInWant().done());
@ -312,7 +312,7 @@ public void testFetchWithRefInWantUnknownRef() throws Exception {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"want e4980cdc48cfa1301493ca94eb70523f6788b819",
"want-ref refs/heads/branchC",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowRefInWant().done());
@ -329,7 +329,7 @@ public void testFetchWithRefInWantUnknownRef() throws Exception {
@Test
public void testLsRefsMinimalReq() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
@ -342,7 +342,7 @@ public void testLsRefsMinimalReq() throws IOException {
@Test
public void testLsRefsSymrefs() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(), "symrefs",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
@ -358,7 +358,7 @@ public void testLsRefsPeel() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(
PacketLineIn.delimiter(),
"peel",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());
@ -372,7 +372,7 @@ public void testLsRefsPeel() throws IOException {
public void testLsRefsRefPrefixes() throws IOException {
PacketLineIn pckIn = formatAsPacketLine(PacketLineIn.delimiter(),
"ref-prefix refs/for", "ref-prefix refs/heads",
PacketLineIn.END);
PacketLineIn.end());
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.getDefault());

View File

@ -489,7 +489,7 @@ public void onFetch(FetchV2Request req) {
public void testV2Capabilities() throws Exception {
TestV2Hook hook = new TestV2Hook();
ByteArrayInputStream recvStream =
uploadPackV2Setup(null, null, hook, PacketLineIn.END);
uploadPackV2Setup(null, null, hook, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(hook.capabilitiesRequest, notNullValue());
assertThat(pckIn.readString(), is("version 2"));
@ -510,7 +510,7 @@ public void testV2Capabilities() throws Exception {
public void testV2CapabilitiesAllowFilter() throws Exception {
server.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
ByteArrayInputStream recvStream =
uploadPackV2Setup(null, null, null, PacketLineIn.END);
uploadPackV2Setup(null, null, null, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -527,7 +527,7 @@ public void testV2CapabilitiesAllowFilter() throws Exception {
public void testV2CapabilitiesRefInWant() throws Exception {
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true);
ByteArrayInputStream recvStream =
uploadPackV2Setup(null, null, null, PacketLineIn.END);
uploadPackV2Setup(null, null, null, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -545,7 +545,7 @@ public void testV2CapabilitiesRefInWant() throws Exception {
public void testV2CapabilitiesRefInWantNotAdvertisedIfUnallowed() throws Exception {
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", false);
ByteArrayInputStream recvStream =
uploadPackV2Setup(null, null, null, PacketLineIn.END);
uploadPackV2Setup(null, null, null, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -561,7 +561,7 @@ public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() thr
server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true);
server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false);
ByteArrayInputStream recvStream =
uploadPackV2Setup(null, null, null, PacketLineIn.END);
uploadPackV2Setup(null, null, null, PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("version 2"));
@ -574,7 +574,7 @@ public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() thr
@Test
public void testV2EmptyRequest() throws Exception {
ByteArrayInputStream recvStream = uploadPackV2(PacketLineIn.END);
ByteArrayInputStream recvStream = uploadPackV2(PacketLineIn.end());
// Verify that there is nothing more after the capability
// advertisement.
assertEquals(0, recvStream.available());
@ -590,7 +590,7 @@ public void testV2LsRefs() throws Exception {
TestV2Hook hook = new TestV2Hook();
ByteArrayInputStream recvStream = uploadPackV2(null, null, hook,
"command=ls-refs\n", PacketLineIn.END);
"command=ls-refs\n", PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(hook.lsRefsRequest, notNullValue());
@ -608,7 +608,8 @@ public void testV2LsRefsSymrefs() throws Exception {
RevTag tag = remote.tag("tag", tip);
remote.update("refs/tags/tag", tag);
ByteArrayInputStream recvStream = uploadPackV2("command=ls-refs\n", PacketLineIn.delimiter(), "symrefs", PacketLineIn.END);
ByteArrayInputStream recvStream = uploadPackV2("command=ls-refs\n",
PacketLineIn.delimiter(), "symrefs", PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD symref-target:refs/heads/master"));
@ -625,7 +626,8 @@ public void testV2LsRefsPeel() throws Exception {
RevTag tag = remote.tag("tag", tip);
remote.update("refs/tags/tag", tag);
ByteArrayInputStream recvStream = uploadPackV2("command=ls-refs\n", PacketLineIn.delimiter(), "peel", PacketLineIn.END);
ByteArrayInputStream recvStream = uploadPackV2("command=ls-refs\n",
PacketLineIn.delimiter(), "peel", PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD"));
@ -646,8 +648,9 @@ public void testV2LsRefsMultipleCommands() throws Exception {
remote.update("refs/tags/tag", tag);
ByteArrayInputStream recvStream = uploadPackV2(
"command=ls-refs\n", PacketLineIn.delimiter(), "symrefs", "peel", PacketLineIn.END,
"command=ls-refs\n", PacketLineIn.delimiter(), PacketLineIn.END);
"command=ls-refs\n", PacketLineIn.delimiter(), "symrefs",
"peel", PacketLineIn.end(), "command=ls-refs\n",
PacketLineIn.delimiter(), PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD symref-target:refs/heads/master"));
@ -675,7 +678,7 @@ public void testV2LsRefsRefPrefix() throws Exception {
PacketLineIn.delimiter(),
"ref-prefix refs/heads/maste",
"ref-prefix refs/heads/other",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
@ -694,7 +697,7 @@ public void testV2LsRefsRefPrefixNoSlash() throws Exception {
PacketLineIn.delimiter(),
"ref-prefix refs/heads/maste",
"ref-prefix r",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
@ -710,7 +713,7 @@ public void testV2LsRefsUnrecognizedArgument() throws Exception {
"command=ls-refs\n",
PacketLineIn.delimiter(),
"invalid-argument\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -718,7 +721,7 @@ public void testV2LsRefsServerOptions() throws Exception {
String[] lines = { "command=ls-refs\n",
"server-option=one\n", "server-option=two\n",
PacketLineIn.delimiter(),
PacketLineIn.END };
PacketLineIn.end() };
TestV2Hook testHook = new TestV2Hook();
uploadPackV2Setup(null, null, testHook, lines);
@ -764,7 +767,7 @@ public void testV2FetchRequestPolicyAdvertised() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + advertized.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
// This doesn't
thrown.expect(TransportException.class);
@ -777,7 +780,7 @@ public void testV2FetchRequestPolicyAdvertised() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + unadvertized.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -795,7 +798,7 @@ public void testV2FetchRequestPolicyReachableCommit() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + reachable.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
// This doesn't
thrown.expect(TransportException.class);
@ -808,7 +811,7 @@ public void testV2FetchRequestPolicyReachableCommit() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + unreachable.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -825,7 +828,7 @@ public void testV2FetchRequestPolicyTip() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + tip.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
// This doesn't
thrown.expect(TransportException.class);
@ -838,7 +841,7 @@ public void testV2FetchRequestPolicyTip() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + parentOfTip.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -856,7 +859,7 @@ public void testV2FetchRequestPolicyReachableCommitTip() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + parentOfTip.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
// This doesn't
thrown.expect(TransportException.class);
@ -869,7 +872,7 @@ public void testV2FetchRequestPolicyReachableCommitTip() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + unreachable.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -884,7 +887,7 @@ public void testV2FetchRequestPolicyAny() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"want " + unreachable.name() + "\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -902,7 +905,7 @@ public void testV2FetchServerDoesNotStopNegotiation() throws Exception {
"want " + fooChild.toObjectId().getName() + "\n",
"want " + barChild.toObjectId().getName() + "\n",
"have " + fooParent.toObjectId().getName() + "\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("acknowledgments"));
@ -926,7 +929,7 @@ public void testV2FetchServerStopsNegotiation() throws Exception {
"want " + barChild.toObjectId().getName() + "\n",
"have " + fooParent.toObjectId().getName() + "\n",
"have " + barParent.toObjectId().getName() + "\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("acknowledgments"));
@ -961,7 +964,7 @@ public void testV2FetchClientStopsNegotiation() throws Exception {
"want " + barChild.toObjectId().getName() + "\n",
"have " + fooParent.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
@ -990,7 +993,7 @@ public void testV2FetchThinPack() throws Exception {
"have " + parent.toObjectId().getName() + "\n",
"thin-pack\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
@ -1014,7 +1017,7 @@ public void testV2FetchNoProgress() throws Exception {
PacketLineIn.delimiter(),
"want " + commit.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream, new TextProgressMonitor(sw));
@ -1028,7 +1031,7 @@ public void testV2FetchNoProgress() throws Exception {
"want " + commit.toObjectId().getName() + "\n",
"no-progress\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream, new TextProgressMonitor(sw));
@ -1048,7 +1051,7 @@ public void testV2FetchIncludeTag() throws Exception {
PacketLineIn.delimiter(),
"want " + commit.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1061,7 +1064,7 @@ public void testV2FetchIncludeTag() throws Exception {
"want " + commit.toObjectId().getName() + "\n",
"include-tag\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1084,7 +1087,7 @@ public void testV2FetchOfsDelta() throws Exception {
PacketLineIn.delimiter(),
"want " + child.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
ReceivedPackStatistics receivedStats = parsePack(recvStream);
@ -1097,7 +1100,7 @@ public void testV2FetchOfsDelta() throws Exception {
"want " + child.toObjectId().getName() + "\n",
"ofs-delta\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
receivedStats = parsePack(recvStream);
@ -1119,7 +1122,7 @@ public void testV2FetchShallow() throws Exception {
"want " + barChild.toObjectId().getName() + "\n",
"have " + fooChild.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1135,7 +1138,7 @@ public void testV2FetchShallow() throws Exception {
"have " + fooChild.toObjectId().getName() + "\n",
"shallow " + fooChild.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1155,7 +1158,7 @@ public void testV2FetchDeepenAndDone() throws Exception {
"want " + child.toObjectId().getName() + "\n",
"deepen 1\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
assertThat(pckIn.readString(), is("shallow " + child.toObjectId().getName()));
@ -1171,7 +1174,7 @@ public void testV2FetchDeepenAndDone() throws Exception {
PacketLineIn.delimiter(),
"want " + child.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1189,7 +1192,7 @@ public void testV2FetchDeepenWithoutDone() throws Exception {
PacketLineIn.delimiter(),
"want " + child.toObjectId().getName() + "\n",
"deepen 1\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
// Verify that only the correct section is sent. "shallow-info"
@ -1224,7 +1227,7 @@ public void testV2FetchShallowSince() throws Exception {
"want " + merge.toObjectId().getName() + "\n",
"have " + boundary.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
@ -1274,7 +1277,7 @@ public void testV2FetchShallowSince_excludedParentWithMultipleChildren() throws
"want " + child1.toObjectId().getName() + "\n",
"want " + child2.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
@ -1312,7 +1315,7 @@ public void testV2FetchShallowSince_noCommitsSelected() throws Exception {
"deepen-since 1510000\n",
"want " + tooOld.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -1337,7 +1340,7 @@ public void testV2FetchDeepenNot() throws Exception {
"want " + merge.toObjectId().getName() + "\n",
"have " + three.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
@ -1388,7 +1391,7 @@ public void testV2FetchDeepenNot_excludeDescendantOfWant() throws Exception {
"deepen-not four\n",
"want " + two.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -1408,7 +1411,7 @@ public void testV2FetchDeepenNot_supportAnnotatedTags() throws Exception {
"deepen-not twotag\n",
"want " + four.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
assertThat(pckIn.readString(), is("shallow " + three.toObjectId().getName()));
@ -1443,7 +1446,7 @@ public void testV2FetchDeepenNot_excludedParentWithMultipleChildren() throws Exc
"want " + child1.toObjectId().getName() + "\n",
"want " + child2.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
@ -1472,14 +1475,14 @@ public void testV2FetchUnrecognizedArgument() throws Exception {
"command=fetch\n",
PacketLineIn.delimiter(),
"invalid-argument\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
public void testV2FetchServerOptions() throws Exception {
String[] lines = { "command=fetch\n", "server-option=one\n",
"server-option=two\n", PacketLineIn.delimiter(),
PacketLineIn.END };
PacketLineIn.end() };
TestV2Hook testHook = new TestV2Hook();
uploadPackV2Setup(null, null, testHook, lines);
@ -1507,7 +1510,7 @@ public void testV2FetchFilter() throws Exception {
"want " + commit.toObjectId().getName() + "\n",
"filter blob:limit=5\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@ -1564,7 +1567,7 @@ private void uploadV2WithTreeDepthFilter(
}
input.add("filter tree:" + depth + "\n");
input.add("done\n");
input.add(PacketLineIn.END);
input.add(PacketLineIn.end());
ByteArrayInputStream recvStream =
uploadPackV2(RequestPolicy.ANY, /*refFilter=*/null,
/*hook=*/null, input.toArray(new String[0]));
@ -1849,7 +1852,7 @@ public void testV2FetchFilterWhenNotAllowed() throws Exception {
"want " + commit.toObjectId().getName() + "\n",
"filter blob:limit=5\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
}
@Test
@ -1863,7 +1866,7 @@ public void testV2FetchWantRefIfNotAllowed() throws Exception {
PacketLineIn.delimiter(),
"want-ref refs/heads/one\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
} catch (PackProtocolException e) {
assertThat(
e.getMessage(),
@ -1890,7 +1893,7 @@ public void testV2FetchWantRef() throws Exception {
"want-ref refs/heads/one\n",
"want-ref refs/heads/two\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("wanted-refs"));
assertThat(
@ -1921,7 +1924,7 @@ public void testV2FetchBadWantRef() throws Exception {
"want-ref refs/heads/one\n",
"want-ref refs/heads/nonExistentRef\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
} catch (PackProtocolException e) {
assertThat(
e.getMessage(),
@ -1948,7 +1951,7 @@ public void testV2FetchMixedWantRef() throws Exception {
"want-ref refs/heads/one\n",
"want " + two.toObjectId().getName() + "\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("wanted-refs"));
assertThat(
@ -1976,7 +1979,7 @@ public void testV2FetchWantRefWeAlreadyHave() throws Exception {
"want-ref refs/heads/one\n",
"have " + one.toObjectId().getName(),
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
// The client still needs to know the hash of the object that
@ -2008,7 +2011,7 @@ public void testV2FetchWantRefAndDeepen() throws Exception {
"want-ref refs/heads/branch1\n",
"deepen 1\n",
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
// shallow-info appears first, then wanted-refs.
@ -2041,7 +2044,7 @@ public void testV2FetchMissingShallow() throws Exception {
"shallow 0123012301230123012301230123012301230123",
"shallow " + two.getName() + '\n',
"done\n",
PacketLineIn.END);
PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
@ -2070,7 +2073,7 @@ public void testGetPeerAgentProtocolV0() throws Exception {
UploadPack up = new UploadPack(server);
ByteArrayInputStream send = linesAsInputStream(
"want " + one.getName() + " agent=JGit-test/1.2.3\n",
PacketLineIn.END,
PacketLineIn.end(),
"have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n");
ByteArrayOutputStream recv = new ByteArrayOutputStream();
@ -2093,7 +2096,7 @@ public void testGetPeerAgentProtocolV2() throws Exception {
"command=fetch\n", "agent=JGit-test/1.2.4\n",
PacketLineIn.delimiter(), "want " + one.getName() + "\n",
"have 11cedf1b796d44207da702f7d420684022fc0f09\n", "done\n",
PacketLineIn.END);
PacketLineIn.end());
ByteArrayOutputStream recv = new ByteArrayOutputStream();
up.upload(send, recv, null);

View File

@ -250,6 +250,17 @@ static String delimiter() {
return DELIM;
}
/**
* Get the end marker.
* <p>
* Intended for use only in tests.
*
* @return The end marker.
*/
static String end() {
return END;
}
/**
* Check if a string is the packet end marker.
*