Browse Source

cleanup: use assertArrayEquals for assertion on arrays

Change-Id: I1df945011f8e5f03959b693d3564fe357e707f91
stable-2.1
Robin Rosenberg 12 years ago committed by Matthias Sohn
parent
commit
cd23b214bf
  1. 4
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java
  2. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
  3. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConstantsEncodingTest.java
  4. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java
  5. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java
  6. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/pack/DeltaIndexTest.java
  7. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/pack/DeltaStreamTest.java
  8. 42
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java
  9. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutInputStreamTest.java
  10. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java

4
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java vendored

@ -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.File;
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 class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase {
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,

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java

@ -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 class ConfigTest {
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());

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConstantsEncodingTest.java

@ -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 class ConstantsEncodingTest {
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 class ConstantsEncodingTest {
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 class ConstantsEncodingTest {
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 class ConstantsEncodingTest {
(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"));
}
}

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/ConcurrentRepackTest.java

@ -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 class ConcurrentRepackTest extends RepositoryTestCase {
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());
}

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/PackFileTest.java

@ -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 class PackFileTest extends LocalDiskRepositoryTestCase {
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);

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/pack/DeltaIndexTest.java

@ -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 @@ public class DeltaIndexTest {
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));
}
}

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/pack/DeltaStreamTest.java

@ -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 @@ public class DeltaStreamTest {
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.
//

42
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/TemporaryBufferTest.java

@ -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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
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 class TemporaryBufferTest {
o.close();
final byte[] r = o.toByteArray();
assertEquals(expect.length, r.length);
assertTrue(Arrays.equals(expect, r));
assertArrayEquals(expect, r);
}
} finally {
b.destroy();

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutInputStreamTest.java

@ -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 class TimeoutInputStreamTest {
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 class TimeoutInputStreamTest {
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

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/TimeoutOutputStreamTest.java

@ -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 class TimeoutOutputStreamTest {
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 class TimeoutOutputStreamTest {
os.write(exp);
in.want(exp.length);
in.read(act);
assertTrue(Arrays.equals(exp, act));
assertArrayEquals(exp, act);
}
@Test

Loading…
Cancel
Save