List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:com.jsen.javascript.java.HostedJavaObject.java
/** * Constructs new scope that contains the passed object members. * /*from w ww . ja v a 2s . co m*/ * @param scope Scope to become the parent scope of this Java object. * @param objectMembers Object and its members to be put into this new scope. */ public HostedJavaObject(Scriptable scope, ObjectMembers objectMembers) { super(objectMembers.getObject(), scope, null); this.objectMembers = objectMembers; TopLevel topLevel = JavaScriptEngine.getObjectTopLevel(scope); Scriptable builtinObject = topLevel.getBuiltinCtor(Builtins.Object); setPrototype(builtinObject); if (object instanceof ObjectGetter) { Class<?>[] getterArgs = ObjectGetter.METHOD_ARG_TYPES; String getterName = ObjectGetter.METHOD_NAME; for (Method method : objectClass.getMethods()) { String methodName = method.getName(); Class<?>[] methodParams = method.getParameterTypes(); if (methodName.equals(getterName) && !Arrays.equals(methodParams, getterArgs)) { hasNonObjectGetterGet = true; break; } } } }
From source file:com.amazonaws.util.Base32CodecTest.java
@Test public void testVectorsPerRfc4648() throws NoSuchAlgorithmException, UnsupportedEncodingException { String[] testVectors = { "", "f", "fo", "foo", "foob", "fooba", "foobar", }; String[] expected = { "", "MY======", "MZXQ====", "MZXW6===", "MZXW6YQ=", "MZXW6YTB", "MZXW6YTBOI======", }; for (int i = 0; i < testVectors.length; i++) { String data = testVectors[i]; byte[] source = data.getBytes("UTF-8"); String b32encoded = Base32.encodeAsString(data.getBytes("UTF-8")); Assert.assertEquals(expected[i], b32encoded); byte[] b32 = b32encoded.getBytes("UTF-8"); byte[] decoded = Base32.decode(b32); Assert.assertTrue(Arrays.equals(source, decoded)); }/* w w w . j a v a 2 s . c o m*/ }
From source file:com.github.aelstad.keccakj.fips202.KeccakDigestTestUtils.java
public void runTests(List<DigestTest> tests, KeccakSponge sponge) { for (DigestTest dt : tests) { sponge.reset();//from ww w .ja v a 2 s .c o m sponge.getAbsorbStream().writeBits(dt.msg, 0, dt.len); System.out.println("Rate is now " + new String(Hex.encodeHex(sponge.getRateBits(0, Math.min(dt.len, sponge.getRateBits()))))); byte[] rv = new byte[dt.digest.length]; sponge.getSqueezeStream().read(rv); Assert.assertTrue(rv.length == dt.digest.length); ; org.junit.Assert.assertTrue(Arrays.equals(rv, dt.digest)); } testPerformance(sponge); }
From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.PackedMatrixTest.java
@Test public void testBandedBLASReturnMatrixValidity() { PackedMatrix tmp = new PackedMatrix(_bandedBLAS, allowZerosOn.bothSides); for (int i = 0; i < _bandedBLAS.length; i++) { assertTrue(Arrays.equals(_bandedBLAS[i], tmp.getRowElements(i))); }/* w w w . j a va 2s .com*/ }
From source file:com.yahoo.bullet.drpc.FilterBoltTest.java
private boolean tupleEquals(List<Object> actual, Tuple expectedTuple) { List<Object> expected = expectedTuple.getValues(); boolean result = isSameTuple(actual, expected); byte[] actualRecordList = (byte[]) actual.get(1); byte[] expectedRecordList = (byte[]) expected.get(1); return result && Arrays.equals(actualRecordList, expectedRecordList); }
From source file:bftsmart.tom.ServiceProxy.java
/** * Constructor// w w w . java2 s .co m * * @param processId Process id for this client (should be different from replicas) * @param configHome Configuration directory for BFT-SMART * @param replyComparator used for comparing replies from different servers * to extract one returned by f+1 * @param replyExtractor used for extracting the response from the matching * quorum of replies */ public ServiceProxy(int processId, String configHome, Comparator<byte[]> replyComparator, Extractor replyExtractor) { if (configHome == null) { init(processId); } else { init(processId, configHome); } if (getViewManager().getStaticConf().isBFT()) { replyQuorum = (int) Math .ceil((getViewManager().getCurrentViewN() + getViewManager().getCurrentViewF()) / 2) + 1; } else { replyQuorum = (int) Math.ceil((getViewManager().getCurrentViewN()) / 2) + 1; } replies = new TOMMessage[getViewManager().getCurrentViewN()]; comparator = (replyComparator != null) ? replyComparator : new Comparator<byte[]>() { @Override public int compare(byte[] o1, byte[] o2) { return Arrays.equals(o1, o2) ? 0 : -1; } }; extractor = (replyExtractor != null) ? replyExtractor : new Extractor() { @Override public TOMMessage extractResponse(TOMMessage[] replies, int sameContent, int lastReceived) { return replies[lastReceived]; } }; replyListener = null; }
From source file:com.funambol.ctp.core.Unauthorized.java
/** * Compares <code>this</code> object with input object to establish if are * the same object.// w w w . j a v a2 s .c o m * * @param obj the object to compare * @return true if the objects are equals, false otherwise */ public boolean deepequals(Object obj) { if (obj == null || (!obj.getClass().equals(this.getClass()))) { return false; } if (this == obj) { return true; } Unauthorized cmd = (Unauthorized) obj; if (this.getNonce() == null) { if (cmd.getNonce() != null) { return false; } } else { if (cmd.getNonce() == null) { return false; } if (!(Arrays.equals(this.getNonce(), cmd.getNonce()))) { return false; } } return true; }
From source file:com.thruzero.common.core.security.SimpleCipherTest.java
@Test public void testSimpleCipherDirectConfiguration() { byte[] salt = UNIQUE_SALT; String passPhrase = UNIQUE_PASS_PHRASE; int iterationCount = UNIQUE_ITERATION_COUNT; // First, assert that the test values do not match the default values assertNotDefaultCipherValues(salt, passPhrase, iterationCount); // test configuration constructed using direct arguments SimpleCipherConfiguration simpleCipherConfiguration = new SimpleCipherConfiguration(salt, passPhrase.toCharArray(), iterationCount); assertTrue("Configuration salt must equal given salt", Arrays.equals(salt, simpleCipherConfiguration.getSalt())); assertTrue("Configuration pass-phrase must equal given pass-phrase", Arrays.equals(passPhrase.toCharArray(), simpleCipherConfiguration.getPassPhrase())); assertEquals("Configuration iteration count must equal given iteration count", UNIQUE_ITERATION_COUNT, simpleCipherConfiguration.getIterationCount()); }
From source file:com.cloudera.livy.client.common.TestHttpMessages.java
private void checkEquals(String name, Field f, Object o1, Object o2) throws Exception { Object v1 = f.get(o1);//w w w . j av a 2 s . co m Object v2 = f.get(o2); boolean match; if (!f.getType().isArray()) { match = v1.equals(v2); } else if (v1 instanceof byte[]) { match = Arrays.equals((byte[]) v1, (byte[]) v2); } else { throw new IllegalArgumentException("FIX ME: " + f.getType().getSimpleName()); } assertTrue(String.format("Field %s of %s does not match after deserialization.", f.getName(), name), match); }
From source file:org.owasp.proxy.http.dao.JdbcMessageDAOTest.java
@Test public void testSaveMessageContent() { MutableBufferedRequest request = new MutableBufferedRequest.Impl(); request.setTarget(InetSocketAddress.createUnresolved("localhost", 80)); request.setSsl(false);/* w w w.j av a 2 s.c o m*/ request.setHeader(AsciiString.getBytes("GET / HTTP/1.0\r\nHost: localhost\r\n\r\n")); request.setTime(1); MutableBufferedResponse response = new MutableBufferedResponse.Impl(); response.setHeader(AsciiString.getBytes("HTTP/1.0 200 Ok\r\nContent-Type: text\r\n\r\n")); byte[] cont = AsciiString.getBytes("Some content"); response.setContent(cont); response.setHeaderTime(2); response.setContentTime(4); dao.saveRequest(request); dao.saveResponse(response); int id = dao.saveConversation(request.getId(), response.getId()); logger.fine("ADDED conversation"); dump(); logger.fine("##############################################"); Conversation c = dao.getConversation(id); RequestHeader reqh = dao.loadRequestHeader(c.getRequestId()); ResponseHeader resph = dao.loadResponseHeader(c.getResponseId()); assertTrue(Arrays.equals(request.getHeader(), reqh.getHeader())); assertEquals(request.getTarget(), reqh.getTarget()); assertEquals(request.isSsl(), reqh.isSsl()); assertEquals(request.getTime(), reqh.getTime()); assertTrue("Response headers differ", Arrays.equals(response.getHeader(), resph.getHeader())); assertEquals(response.getHeaderTime(), resph.getHeaderTime()); assertEquals(response.getContentTime(), resph.getContentTime()); byte[] content = dao.loadMessageContent(dao.getMessageContentId(c.getRequestId())); assertNull(content); content = dao.loadMessageContent(dao.getMessageContentId(c.getResponseId())); assertTrue(Arrays.equals(cont, content)); assertTrue("Delete failed", dao.deleteConversation(id)); dump(); }