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.memory.MemoryStoreTest.java

/**
 * At the moment, on MemoryStore can guarantee the entity of the 
 * StoredItem returned by write will match that of the 
 * SubmittedItem because there's no chunking involved. See
 * TODO item in S3Store.write() re: making an entity stream
 * using reconstructChunks() or similar when writing
 *///from www  . ja va2 s.c o m
@Test
public void storedItemHasExpectedEntity() throws Exception {
    SubmittedItem submitted = new SubmittedItem(MediaType.TEXT_PLAIN_TYPE, new ByteArrayInputStream(data));
    StoredItem stored = store.write(itemURI, submitted);
    assertTrue(Arrays.equals(data, IOUtils.toByteArray(stored.getEntity())));
}

From source file:org.springframework.social.twitter.api.MentionEntity.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }//from  w w  w  .  j  a va  2s  .  c  o m
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    MentionEntity that = (MentionEntity) o;

    if (id != that.id) {
        return false;
    }
    if (name != null ? !name.equals(that.name) : that.name != null) {
        return false;
    }
    if (!Arrays.equals(indices, that.indices)) {
        return false;
    }
    if (screenName != null ? !screenName.equals(that.screenName) : that.screenName != null) {
        return false;
    }

    return true;
}

From source file:com.brienwheeler.apps.main.MainBaseTest.java

@Test
public void testProcessArgs() {
    String[] args = new String[] { ONE, TWO };
    Main1 main = new Main1(args);
    main.run();//from  w ww .j  a v  a  2  s  .  c  om
    ArrayList<String> processedArgs = main.getProcessedArgs();
    Assert.assertTrue(Arrays.equals(args, processedArgs.toArray(new String[processedArgs.size()])));
}

From source file:com.jivesoftware.os.amza.api.wal.KeyedTimestampId.java

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }// w w w .j  av  a2 s. com
    if (o == null || getClass() != o.getClass()) {
        return false;
    }

    KeyedTimestampId that = (KeyedTimestampId) o;

    if (timestamp != that.timestamp) {
        return false;
    }
    if (tombstoned != that.tombstoned) {
        return false;
    }
    if (!Arrays.equals(prefix, that.prefix)) {
        return false;
    }
    return Arrays.equals(key, that.key);

}

From source file:com.hpe.caf.worker.testing.validation.Base64PropertyValidator.java

@Override
protected boolean isValid(Object testedPropertyValue, Object validatorPropertyValue) {
    if (validatorPropertyValue == null) {
        return testedPropertyValue == null;
    }/*from  w w  w. jav a 2s  . c  om*/

    if (testedPropertyValue == null) {
        return false;
    }

    if (!(testedPropertyValue instanceof byte[]) || !(validatorPropertyValue instanceof String)) {
        throw new AssertionError(
                "Unexpected types provided to Base64PropertyValidator. Expected byte array testedPropertyValue and String validatorPropertyValue. Provided were "
                        + testedPropertyValue.getClass().getSimpleName() + " and "
                        + validatorPropertyValue.getClass().getSimpleName() + ". Values: "
                        + testedPropertyValue.toString() + ", " + validatorPropertyValue.toString());
    }

    byte[] testedPropertyValueBytes = (byte[]) testedPropertyValue;

    if (validatorPropertyValue.toString().equals("*")) {
        return testedPropertyValueBytes.length > 0;
    }

    boolean areEqual = Arrays.equals(testedPropertyValueBytes,
            Base64.decodeBase64(validatorPropertyValue.toString()));

    if (!areEqual) {
        String actual = Base64.encodeBase64String(testedPropertyValueBytes);
        System.err.println("Unexpected result. Actual value: " + actual + ", expected value: "
                + validatorPropertyValue.toString());
    }

    return areEqual;
}

From source file:net.darkmist.clf.UtilTest.java

public void testBThenA() throws Exception {
    Integer[] a = new Integer[] { 6, 7, 8, 9 };
    Integer[] b = new Integer[] { 1, 2, 3, 4, 5 };
    Integer[] expected = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    Integer[] actual = new Integer[a.length + b.length];

    Util.merge(a, b, actual, comparator);
    assertTrue(Arrays.equals(actual, expected));
}

From source file:org.springmodules.cache.provider.ehcache.EhCacheFlushingModel.java

/**
 * @see java.lang.Object#equals(java.lang.Object)
 *///from w  w  w.  j av a2s  .c  o  m
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof EhCacheFlushingModel)) {
        return false;
    }
    EhCacheFlushingModel flushingModel = (EhCacheFlushingModel) obj;
    if (!Arrays.equals(cacheNames, flushingModel.cacheNames)) {
        return false;
    }
    return true;
}

From source file:au.com.borner.salesforce.client.rest.domain.LoginResponse.java

public void verify(String consumerSecret) {
    SecretKey hmacKey = null;//from   w ww .  j  a v a  2 s.c o m
    try {
        byte[] key = consumerSecret.getBytes();
        hmacKey = new SecretKeySpec(key, ALGORITHM);
        Mac mac = Mac.getInstance(ALGORITHM);
        mac.init(hmacKey);
        byte[] digest = mac.doFinal((getIdUrl() + getIssuedAt()).getBytes());
        byte[] decode_sig = new Base64(true).decode(getSignature());
        if (!Arrays.equals(digest, decode_sig)) {
            throw new SecurityException("Signature could not be verified!");
        }
    } catch (NoSuchAlgorithmException e) {
        throw new SecurityException(String.format(
                "Algorithm not found while trying to verifying signature: algorithm=%s; message=%s", ALGORITHM,
                e.getMessage()), e);
    } catch (InvalidKeyException e) {
        throw new SecurityException(
                String.format("Invalid key encountered while trying to verify signature: key=%s; message=%s",
                        hmacKey, e.getMessage()),
                e);
    }
}

From source file:com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveData.java

@Override
public boolean equals(final Object o) {
    if (o == null) {
        return false;
    }/* w ww.  ja v a  2  s. c o m*/
    if (!(o instanceof FuturePriceCurveData)) {
        return false;
    }
    final FuturePriceCurveData<?> other = (FuturePriceCurveData<?>) o;
    return getDefinitionName().equals(other.getDefinitionName())
            && getSpecificationName().equals(other.getSpecificationName())
            && getTarget().equals(other.getTarget()) && Arrays.equals(getXs(), other.getXs())
            && _values.equals(other._values);
}

From source file:batch.demo.util.InMemoryResource.java

public boolean equals(Object res) {
    if (!(res instanceof InMemoryResource)) {
        return false;
    }//  w  w w  .  j  a v a  2  s.  c  o m

    return Arrays.equals(source, ((InMemoryResource) res).source);
}