cleanup: use assertArrayEquals for assertion on arrays

Change-Id: I1df945011f8e5f03959b693d3564fe357e707f91
This commit is contained in:
Robin Rosenberg 2012-09-02 00:15:53 +02:00 committed by Matthias Sohn
parent 476e1d2ff1
commit cd23b214bf
10 changed files with 43 additions and 45 deletions

View File

@ -43,6 +43,7 @@
package org.eclipse.jgit.dircache;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@ -54,7 +55,6 @@
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@ -215,7 +215,7 @@ public void testReadWriteV3() throws Exception {
dc.writeTo(bos);
final byte[] indexBytes = bos.toByteArray();
final byte[] expectedBytes = IO.readFully(file);
assertTrue(Arrays.equals(expectedBytes, indexBytes));
assertArrayEquals(expectedBytes, indexBytes);
}
private static void assertV3TreeEntry(int indexPosition, String path,

View File

@ -48,6 +48,7 @@
package org.eclipse.jgit.lib;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -117,7 +118,7 @@ public void test005_PutGetStringList() {
final Object[] expArr = values.toArray();
final String[] actArr = c.getStringList("my", null, "somename");
assertTrue(Arrays.equals(expArr, actArr));
assertArrayEquals(expArr, actArr);
final String expText = "[my]\n\tsomename = value1\n\tsomename = value2\n";
assertEquals(expText, c.toText());

View File

@ -43,13 +43,11 @@
package org.eclipse.jgit.lib;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import org.junit.Test;
public class ConstantsEncodingTest {
@ -59,7 +57,7 @@ public void testEncodeASCII_SimpleASCII()
final String src = "abc";
final byte[] exp = { 'a', 'b', 'c' };
final byte[] res = Constants.encodeASCII(src);
assertTrue(Arrays.equals(exp, res));
assertArrayEquals(exp, res);
assertEquals(src, new String(res, 0, res.length, "UTF-8"));
}
@ -79,7 +77,7 @@ public void testEncodeASCII_Number13() {
final long src = 13;
final byte[] exp = { '1', '3' };
final byte[] res = Constants.encodeASCII(src);
assertTrue(Arrays.equals(exp, res));
assertArrayEquals(exp, res);
}
@Test
@ -87,7 +85,7 @@ public void testEncode_SimpleASCII() throws UnsupportedEncodingException {
final String src = "abc";
final byte[] exp = { 'a', 'b', 'c' };
final byte[] res = Constants.encode(src);
assertTrue(Arrays.equals(exp, res));
assertArrayEquals(exp, res);
assertEquals(src, new String(res, 0, res.length, "UTF-8"));
}
@ -98,7 +96,7 @@ public void testEncode_Unicode() throws UnsupportedEncodingException {
(byte) 0xAD, 0x63, (byte) 0xC5, (byte) 0x8D, 0x64, 0x65,
(byte) 0xCC, (byte) 0xBD };
final byte[] res = Constants.encode(src);
assertTrue(Arrays.equals(exp, res));
assertArrayEquals(exp, res);
assertEquals(src, new String(res, 0, res.length, "UTF-8"));
}
}

View File

@ -44,19 +44,17 @@
package org.eclipse.jgit.storage.file;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.AnyObjectId;
@ -199,7 +197,7 @@ public void testObjectMovedToNewPack2()
assertNotNull(data2);
assertNotNull(data1);
assertNotSame(data1, data2); // cache should be per-pack, not per object
assertTrue(Arrays.equals(data1, data2));
assertArrayEquals(data1, data2);
assertEquals(load2.getType(), load1.getType());
}

View File

@ -43,6 +43,7 @@
package org.eclipse.jgit.storage.file;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -224,7 +225,7 @@ public void testDelta_SmallObjectChain() throws Exception {
assertEquals(data3.length, ol.getSize());
assertFalse("is large", ol.isLarge());
assertNotNull(ol.getCachedBytes());
assertTrue(Arrays.equals(data3, ol.getCachedBytes()));
assertArrayEquals(data3, ol.getCachedBytes());
ObjectStream in = ol.openStream();
assertNotNull("have stream", in);

View File

@ -43,14 +43,13 @@
package org.eclipse.jgit.storage.pack;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import org.eclipse.jgit.junit.JGitTestUtil;
import org.eclipse.jgit.junit.TestRng;
import org.eclipse.jgit.lib.Constants;
@ -246,6 +245,6 @@ private void doTest() throws IOException {
assertTrue("delta is not empty", actDelta.length > 0);
assertEquals(src.length, BinaryDelta.getBaseSize(actDelta));
assertEquals(dst.length, BinaryDelta.getResultSize(actDelta));
assertTrue(Arrays.equals(dst, BinaryDelta.apply(src, actDelta)));
assertArrayEquals(dst, BinaryDelta.apply(src, actDelta));
}
}

View File

@ -43,6 +43,7 @@
package org.eclipse.jgit.storage.pack;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -267,7 +268,7 @@ private void assertValidState() throws IOException {
delta = deltaBuf.toByteArray();
assertEquals(base.length, BinaryDelta.getBaseSize(delta));
assertEquals(data.length, BinaryDelta.getResultSize(delta));
assertTrue(Arrays.equals(data, BinaryDelta.apply(base, delta)));
assertArrayEquals(data, BinaryDelta.apply(base, delta));
// Assert that a single bulk read produces the correct result.
//

View File

@ -44,17 +44,15 @@
package org.eclipse.jgit.util;
import static org.eclipse.jgit.junit.JGitTestUtil.getName;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import org.eclipse.jgit.junit.TestRng;
import org.junit.Test;
@ -116,7 +114,7 @@ public void testOneBlock_BulkWrite() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -124,7 +122,7 @@ public void testOneBlock_BulkWrite() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -147,7 +145,7 @@ public void testOneBlockAndHalf_BulkWrite() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -155,7 +153,7 @@ public void testOneBlockAndHalf_BulkWrite() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -176,7 +174,7 @@ public void testOneBlockAndHalf_SingleWrite() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -184,7 +182,7 @@ public void testOneBlockAndHalf_SingleWrite() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -206,7 +204,7 @@ public void testOneBlockAndHalf_Copy() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -214,7 +212,7 @@ public void testOneBlockAndHalf_Copy() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -234,7 +232,7 @@ public void testLarge_SingleWrite() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -242,7 +240,7 @@ public void testLarge_SingleWrite() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -260,7 +258,7 @@ public void testInCoreInputStream() throws IOException {
InputStream in = b.openInputStream();
byte[] act = new byte[cnt];
IO.readFully(in, act, 0, cnt);
assertTrue(Arrays.equals(test, act));
assertArrayEquals(test, act);
}
@Test
@ -277,7 +275,7 @@ public void testInCoreLimit_SwitchOnAppendByte() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -285,7 +283,7 @@ public void testInCoreLimit_SwitchOnAppendByte() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -306,7 +304,7 @@ public void testInCoreLimit_SwitchBeforeAppendByte() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -314,7 +312,7 @@ public void testInCoreLimit_SwitchBeforeAppendByte() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -338,7 +336,7 @@ public void testInCoreLimit_SwitchOnCopy() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -346,7 +344,7 @@ public void testInCoreLimit_SwitchOnCopy() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(test.length, r.length);
assertTrue(Arrays.equals(test, r));
assertArrayEquals(test, r);
}
} finally {
b.destroy();
@ -396,7 +394,7 @@ public void testRandomWrites() throws IOException {
final byte[] r = b.toByteArray();
assertNotNull(r);
assertEquals(expect.length, r.length);
assertTrue(Arrays.equals(expect, r));
assertArrayEquals(expect, r);
}
{
final ByteArrayOutputStream o = new ByteArrayOutputStream();
@ -404,7 +402,7 @@ public void testRandomWrites() throws IOException {
o.close();
final byte[] r = o.toByteArray();
assertEquals(expect.length, r.length);
assertTrue(Arrays.equals(expect, r));
assertArrayEquals(expect, r);
}
} finally {
b.destroy();

View File

@ -43,6 +43,7 @@
package org.eclipse.jgit.util.io;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -124,7 +125,7 @@ public void testTimeout_readBuffer_Success1() throws IOException {
final byte[] act = new byte[exp.length];
out.write(exp);
IO.readFully(is, act, 0, act.length);
assertTrue(Arrays.equals(exp, act));
assertArrayEquals(exp, act);
}
@Test
@ -135,7 +136,7 @@ public void testTimeout_readBuffer_Success2() throws IOException {
IO.readFully(is, act, 0, 1);
IO.readFully(is, act, 1, 1);
IO.readFully(is, act, 2, 1);
assertTrue(Arrays.equals(exp, act));
assertArrayEquals(exp, act);
}
@Test

View File

@ -43,6 +43,7 @@
package org.eclipse.jgit.util.io;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -108,7 +109,7 @@ public void testTimeout_writeByte_Success2() throws IOException {
os.write(exp[2]);
in.want(exp.length);
in.read(act);
assertTrue(Arrays.equals(exp, act));
assertArrayEquals(exp, act);
}
@Test
@ -131,7 +132,7 @@ public void testTimeout_writeBuffer_Success1() throws IOException {
os.write(exp);
in.want(exp.length);
in.read(act);
assertTrue(Arrays.equals(exp, act));
assertArrayEquals(exp, act);
}
@Test