List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:org.brekka.stillingar.example.FieldTypesDOMTest.java
/** * /*from w ww . j ava 2s . c o m*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:org.brekka.stillingar.example.FieldTypesJAXBTest.java
/** * // w w w.j a va 2 s . c om */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate().getTime(), t.getDateAsCalendar().getTime()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsCalendar().getTime()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime()).toString(), t.getDateTime().toString()); assertEquals(new LocalDate(testing.getDate()).toString(), t.getLocalDate().toString()); assertEquals(new LocalTime(testing.getTime()).toString(), t.getLocalTime().toString()); assertEquals(String.format("%tT", testing.getTime()), String.format("%tT", t.getTimeAsCalendar().getTime())); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertNotNull(t.getTestingObject() instanceof org.brekka.stillingar.example.Configuration.Testing); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:com.semagia.mql.tolog.TestXSLOptimizer.java
@Test public void testTransform() throws Exception { if ("tolog-tut-2-4_2.tl".equals(_filename)) { return;/*from w ww . j a va 2s . c om*/ } final URL url = TestXSLOptimizer.class.getResource("/xsltests/tolog/in/" + _filename); final URL referenceURL = TestXSLOptimizer.class .getResource("/xsltests/tolog/baseline/" + _filename + ".c14n"); final Builder builder = new Builder( new XSLTOptimizerReader(new InputStreamReader(url.openStream()), _optimizers)); final Document doc = builder.build(""); final ByteArrayOutputStream expected = new ByteArrayOutputStream(); final InputStream tmp = referenceURL.openStream(); int b; while ((b = tmp.read()) != -1) { expected.write(b); } tmp.close(); byte[] expectedBytes = expected.toByteArray(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); Canonicalizer canonicalizer = new Canonicalizer(out); canonicalizer.write(doc); byte[] resDoc = out.toByteArray(); String c14n = out.toString("utf-8"); diff_match_patch dmp = new diff_match_patch(); LinkedList<Patch> patches = dmp.patch_make(new String(expectedBytes, "utf-8"), c14n); //System.out.println(c14n); assertTrue(dmp.patch_toText(patches), Arrays.equals(expectedBytes, resDoc)); }
From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.PackedMatrixTest.java
@Test public void testBandedBLASWithZeroInMiddleReturnMatrixValidity() { PackedMatrix tmp = new PackedMatrix(_bandedBLASWithZeroInMiddle, allowZerosOn.bothSides); for (int i = 0; i < _bandedBLASWithZeroInMiddle.length; i++) { assertTrue(Arrays.equals(_bandedBLASWithZeroInMiddle[i], tmp.getRowElements(i))); }/* w w w . ja v a 2 s.co m*/ }
From source file:com.google.testing.coverage.BitField.java
/** * Compare a BitField object with an array of bytes * * @param other a byte array to compare to * @return true if the underlying byte array is equal to the given byte array *//*from w w w . j a v a 2 s . c o m*/ public boolean equals(byte[] other) { return Arrays.equals(bytes, other); }
From source file:edu.umn.msi.tropix.common.io.IOContextsTest.java
@Test(groups = "unit") public void outputForStream() { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final OutputContext outputContext = OutputContexts.forOutputStream(outputStream); outputContext.put("Moo Cow".getBytes()); assert Arrays.equals(outputStream.toByteArray(), "Moo Cow".getBytes()); }
From source file:com.netflix.hystrix.contrib.javanica.utils.MethodProvider.java
/** * Gets method by name and parameters types using reflection, * if the given type doesn't contain required method then continue applying this method for all super classes up to Object class. * * @param type the type to search method * @param name the method name * @param parameterTypes the parameters types * @return Some if method exists otherwise None *//*from w w w. ja va2 s . co m*/ public Optional<Method> getMethod(Class<?> type, String name, Class<?>... parameterTypes) { Method[] methods = type.getDeclaredMethods(); for (Method method : methods) { if (method.getName().equals(name) && Arrays.equals(method.getParameterTypes(), parameterTypes)) { return Optional.of(method); } } Class<?> superClass = type.getSuperclass(); if (superClass != null && !superClass.equals(Object.class)) { return getMethod(superClass, name, parameterTypes); } else { return Optional.absent(); } }
From source file:com.codeabovelab.dm.common.security.token.SignedTokenServiceBackend.java
@Override public TokenData getToken(String tokenString) { final String key = unwrapToken(tokenString); if (key.isEmpty()) { return null; }/*from w w w . j a v a 2 s .c o m*/ byte[] decodedKey = base32.decode(key); byte[] currentSignature; final long creationTime; byte[] random; byte[] payload; { byte[] content; { ByteBuffer buffer = ByteBuffer.wrap(decodedKey); content = restoreArray(buffer); currentSignature = restoreArray(buffer); } ByteBuffer contentBuffer = ByteBuffer.wrap(content); creationTime = contentBuffer.getLong(); random = restoreArray(contentBuffer); // we need to skip secret restoreArray(contentBuffer); payload = restoreArray(contentBuffer); } final byte[] serverSecret = computeServerSecretApplicableAt(creationTime); // Verification byte[] expectedSign = sign(contentPack(creationTime, random, serverSecret, payload)); Assert.isTrue(Arrays.equals(expectedSign, currentSignature), "Key verification failure"); String[] unpack = unpack(Utf8.decode(payload)); return new TokenDataImpl(creationTime, TokenUtils.getKeyWithTypeAndToken(TYPE, key), unpack[0], unpack[1]); }
From source file:components.security.Password.java
/** * Checks if the given plain password matches the given password hash * * @param plain the plain text password. * @param database the hashed password from the database. * @param salt the salt used for the hashed password. * @return true if the passwords match, false if not. *//*from w w w . ja v a 2 s .c om*/ public boolean check(char[] plain, char[] database, byte[] salt) { checkNotNull(plain); checkArgument(plain.length != 0, "Plain must not be empty."); checkNotNull(database); checkArgument(database.length != 0, "Database must not be empty."); checkNotNull(salt); checkArgument(salt.length != 0, "Salt must not be empty."); char[] hashedPlain = this.hash(plain, salt); return Arrays.equals(hashedPlain, database); }