Example usage for java.util Arrays equals

List of usage examples for java.util Arrays equals

Introduction

In this page you can find the example usage for java.util Arrays equals.

Prototype

public static boolean equals(Object[] a, Object[] a2) 

Source Link

Document

Returns true if the two specified arrays of Objects are equal to one another.

Usage

From source file:com.talis.storage.s3.S3ObjectFactoryTest.java

@Test
public void createdObjectDataContainsBytesFromBuffer() throws Exception {
    S3Object obj = factory.newObject("second", 8, MediaType.TEXT_PLAIN_TYPE, buffer);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.copy(obj.getDataInputStream(), out);
    assertTrue(Arrays.equals(entity, out.toByteArray()));
}

From source file:org.jtalks.common.model.entity.UserTest.java

@Test
public void testSetNullAvatar() {
    sut.setAvatar(null);

    assertTrue(Arrays.equals(sut.getAvatar(), new byte[0]));
}

From source file:org.jfree.data.DataUtilities.java

/**
 * Tests two arrays for equality.  To be considered equal, the arrays must
 * have exactly the same dimensions, and the values in each array must also
 * match (two values that qre both NaN or both INF are considered equal
 * in this test)./*w  ww. j  a v  a2 s .  c o  m*/
 *
 * @param a  the first array (<code>null</code> permitted).
 * @param b  the second array (<code>null</code> permitted).
 *
 * @return A boolean.
 *
 * @since 1.0.13
 */
public static boolean equal(double[][] a, double[][] b) {
    if (a == null) {
        return (b == null);
    }
    if (b == null) {
        return false; // already know 'a' isn't null
    }
    if (a.length != b.length) {
        return false;
    }
    for (int i = 0; i < a.length; i++) {
        if (!Arrays.equals(a[i], b[i])) {
            return false;
        }
    }
    return true;
}

From source file:com.ichi2.libanki.test.FindTestCase.java

@MediumTest
public void test_parse() {
    Finder f = new Finder(null);
    assertTrue(Arrays.equals(f._tokenize("hello world"), new String[] { "hello", "world" }));
    assertTrue(Arrays.equals(f._tokenize("hello  world"), new String[] { "hello", "world" }));
    assertTrue(Arrays.equals(f._tokenize("one -two"), new String[] { "one", "-", "two" }));
    assertTrue(Arrays.equals(f._tokenize("one --two"), new String[] { "one", "-", "two" }));
    assertTrue(Arrays.equals(f._tokenize("one - two"), new String[] { "one", "-", "two" }));
    assertTrue(Arrays.equals(f._tokenize("one or -two"), new String[] { "one", "or", "-", "two" }));
    assertTrue(Arrays.equals(f._tokenize("'hello \"world\"'"), new String[] { "hello \"world\"" }));
    assertTrue(Arrays.equals(f._tokenize("\"hello world\""), new String[] { "hello world" }));
    assertTrue(Arrays.equals(f._tokenize("one (two or ( three or four))"),
            new String[] { "one", "(", "two", "or", "(", "three", "or", "four", ")", ")" }));
    assertTrue(Arrays.equals(f._tokenize("embedded'string"), new String[] { "embedded'string" }));
    assertTrue(Arrays.equals(f._tokenize("deck:'two words'"), new String[] { "deck:two words" }));
}

From source file:com.talis.storage.ItemFactoryTest.java

@Test
public void createItemWithCorrectEntity() throws Exception {
    SubmittedItem item = factory.newSubmittedItem(MediaType.APPLICATION_XML_TYPE,
            new ByteArrayInputStream(entityBytes));
    assertTrue(Arrays.equals(entityBytes, IOUtils.toByteArray(item.getEntity())));
}

From source file:com.linkedin.databus2.schemas.SchemaId.java

@Override
public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof SchemaId))
        return false;
    if (this == obj)
        return true; //shortcut
    SchemaId id = (SchemaId) obj;/*from   w ww.ja va 2 s. c  om*/
    return Arrays.equals(_idBytes, id._idBytes);
}

From source file:de.schildbach.game.chess.ChessPosition.java

@Override
public boolean equals(Object o) {
    if (o == null)
        return false;

    if (!super.equals(o))
        return false;

    ChessPosition other = (ChessPosition) o;

    if (!Arrays.equals(castlingAvailableWhite, other.castlingAvailableWhite))
        return false;

    if (!Arrays.equals(castlingAvailableBlack, other.castlingAvailableBlack))
        return false;

    if (!ObjectUtils.equals(this.enPassantTargetSquare, other.enPassantTargetSquare))
        return false;

    return true;/*ww w  . j ava 2s  .  c  om*/
}

From source file:com.bitsofproof.supernode.api.ExtendedKeyTest.java

@Test
public void testGenerator() throws ValidationException {
    ExtendedKey ekprivate = ExtendedKey.createNew();
    ExtendedKey ekpublic = new ExtendedKey(new ECPublicKey(ekprivate.getMaster().getPublic(), true),
            ekprivate.getChainCode(), 0, 0, 0);

    for (int i = 0; i < 20; ++i) {
        Key fullControl = ekprivate.getKey(i);
        Key readOnly = ekpublic.getKey(i);

        assertTrue(Arrays.equals(fullControl.getPublic(), readOnly.getPublic()));
        assertTrue(fullControl.getAddress().equals(readOnly.getAddress()));

        byte[] toSign = new byte[100];
        random.nextBytes(toSign);/*from  w  w  w  .  j  a  va 2  s.  c o  m*/
        byte[] signature = fullControl.sign(toSign);

        assertTrue(readOnly.verify(toSign, signature));
    }
}

From source file:com.spectralogic.ds3client.utils.hashing.Md5Hash.java

@Override
public boolean equals(final Object obj) {
    if (!(obj instanceof Md5Hash)) {
        return false;
    }//from   www.ja  va 2  s  .  c om
    final Md5Hash otherHash = (Md5Hash) obj;
    return Arrays.equals(this.hash, otherHash.getHash());
}

From source file:edu.umn.msi.tropix.common.test.FileDisposableResourceFactoryTest.java

@Test(groups = "unit", timeOut = 1000)
public void fromByte() throws IOException {
    final byte[] bytes = new byte[10];
    RANDOM.nextBytes(bytes);//from   w  ww  .j  a  v a 2  s  .com

    final DisposableResource resource = FileDisposableResourceFactory.getByteFunciton().apply(bytes);
    final File file = resource.getFile();
    assert file.exists();
    final byte[] fileBytes = FileUtils.readFileToByteArray(file);
    assert Arrays.equals(bytes, fileBytes);
    resource.dispose();
    assert !file.exists();
}