|
|
@ -123,28 +123,24 @@ public class GetTextTest { |
|
|
|
|
|
|
|
|
|
|
|
private Patch parseTestPatchFile() throws IOException { |
|
|
|
private Patch parseTestPatchFile() throws IOException { |
|
|
|
final String patchFile = JGitTestUtil.getName() + ".patch"; |
|
|
|
final String patchFile = JGitTestUtil.getName() + ".patch"; |
|
|
|
final InputStream in = getClass().getResourceAsStream(patchFile); |
|
|
|
try (InputStream in = getClass().getResourceAsStream(patchFile)) { |
|
|
|
if (in == null) { |
|
|
|
if (in == null) { |
|
|
|
fail("No " + patchFile + " test vector"); |
|
|
|
fail("No " + patchFile + " test vector"); |
|
|
|
return null; // Never happens
|
|
|
|
return null; // Never happens
|
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
|
|
|
|
final Patch p = new Patch(); |
|
|
|
final Patch p = new Patch(); |
|
|
|
p.parse(in); |
|
|
|
p.parse(in); |
|
|
|
return p; |
|
|
|
return p; |
|
|
|
} finally { |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String readTestPatchFile(final Charset cs) throws IOException { |
|
|
|
private String readTestPatchFile(final Charset cs) throws IOException { |
|
|
|
final String patchFile = JGitTestUtil.getName() + ".patch"; |
|
|
|
final String patchFile = JGitTestUtil.getName() + ".patch"; |
|
|
|
final InputStream in = getClass().getResourceAsStream(patchFile); |
|
|
|
try (InputStream in = getClass().getResourceAsStream(patchFile)) { |
|
|
|
if (in == null) { |
|
|
|
if (in == null) { |
|
|
|
fail("No " + patchFile + " test vector"); |
|
|
|
fail("No " + patchFile + " test vector"); |
|
|
|
return null; // Never happens
|
|
|
|
return null; // Never happens
|
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
|
|
|
|
final InputStreamReader r = new InputStreamReader(in, cs); |
|
|
|
final InputStreamReader r = new InputStreamReader(in, cs); |
|
|
|
char[] tmp = new char[2048]; |
|
|
|
char[] tmp = new char[2048]; |
|
|
|
final StringBuilder s = new StringBuilder(); |
|
|
|
final StringBuilder s = new StringBuilder(); |
|
|
@ -152,8 +148,6 @@ public class GetTextTest { |
|
|
|
while ((n = r.read(tmp)) > 0) |
|
|
|
while ((n = r.read(tmp)) > 0) |
|
|
|
s.append(tmp, 0, n); |
|
|
|
s.append(tmp, 0, n); |
|
|
|
return s.toString(); |
|
|
|
return s.toString(); |
|
|
|
} finally { |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|