Util { public static boolean equals(Object o1, Object o2) { return (o1 == null && o2 == null) || (o1 != null && o2 != null && o1.equals(o2)); } private  Util(); static byte[] addCrc32(byte[] b); static byte[] addCrc32(byte[] b, int off, int len); static byte[] calculateCrc32(byte[] b, int off, int length); static String decodeString(byte[] buf, int ofs, int len); static byte[] toByteArray(String value); static byte[] toByteArray(InputStream in); static byte[] toByteArray(InputStream in, int bufferSize); static byte[] copyOf(byte[] b); static byte[] copyOf(byte[] b, int off, int len); static byte[] join(byte[] a, byte[] b); static int lcm(int a, int b); static int gcd(int a, int b); static byte[] toByteArray(short value); static byte[] toByteArray(int value); static byte[] toByteArray(long value); static short toShort(byte[] b); static short toShort(byte[] b, int offset); static int toInt(byte[] b); static int toInt(byte[] b, int offset); static long toLong(byte[] b); static long toLong(byte[] b, int offset); static long decodeUnsignedLong(byte[] buf, int ofs, int len); static byte[] encodeUnsignedLong(long value); static byte[] calculateHMAC(byte[] message, byte[] keyBytes, String algorithm); static int copyData(InputStream in, OutputStream out); static int copyData(InputStream in, OutputStream out, int limit, int bufSize); static int copyData(InputStream in, OutputStream out, int limit); static void closeQuietly(InputStream input); static void closeQuietly(OutputStream output); static Long nextLong(); static void notNull(Object o, String name); static boolean equals(Object o1, Object o2); static boolean equalsIgnoreOrder(Collection<?> c1, Collection<?> c2); static boolean containsInt(final int[] array, final int key); static URL toUrl(String url); static String getDefaultTrustStore(); static KeyStore loadKeyStore(File file, String password); static final int DEFAULT_BUFFER_SIZE; }
@Test public void testEqualsBothNulls() { Assert.assertTrue(Util.equals(null, null)); }
@Test public void testEqualsOneNull() { Assert.assertFalse(Util.equals(null, new Object())); Assert.assertFalse(Util.equals(new Object(), null)); }
@Test public void testEqualsBothNotNull() { Assert.assertTrue(Util.equals("a_string", "a_string")); }