/**
 * The MIT License
 *
 * Copyright (C) 2015 Asterios Raptis
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package de.alpharogroup.crypto.hash;

import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

import org.junit.Test;
import org.testng.AssertJUnit;

import de.alpharogroup.crypto.algorithm.HashAlgorithm;

/**
 * Test class for the class {@link HashExtensions}.
 */
public class HashExtensionsTest
{

	/**
	 * Test method for {@link HashExtensions#hash(byte[], String, HashAlgorithm, Charset)}
	 *
	 * @throws NoSuchAlgorithmException
	 *             is thrown if instantiation of the MessageDigest object fails.
	 */
	@Test
	public void testHashByteArray() throws NoSuchAlgorithmException
	{
		final Charset charset = Charset.forName("UTF-8");
		final String password = "abcdefghijklmnopqrst";
		final String newInsertPassword = "abcdefghijklmnopqrst";
		final String salt = null;
		final HashAlgorithm hashAlgorithm = HashAlgorithm.SHA_512;
		final  byte[] expected = HashExtensions.hash(password.getBytes(), salt, hashAlgorithm, charset);
		final  byte[] actual = HashExtensions.hash(newInsertPassword.getBytes(), salt, hashAlgorithm, charset);

		AssertJUnit.assertTrue(expected.length == actual.length);
		AssertJUnit.assertTrue("'expected' should be equal with 'actual'.", Arrays.equals(expected, actual));
	}
	

	
	/**
	 * Test method for {@link HashExtensions#hash(String, String, HashAlgorithm, Charset)}
	 *
	 * @throws NoSuchAlgorithmException
	 *             is thrown if instantiation of the MessageDigest object fails.
	 */
	@Test
	public void testHash() throws NoSuchAlgorithmException
	{
		final Charset charset = Charset.forName("UTF-8");
		final String password = "abcdefghijklmnopqrst";
		final String newInsertPassword = "abcdefghijklmnopqrst";
		final String salt = "NzeCdmaz";
		final HashAlgorithm hashAlgorithm = HashAlgorithm.SHA_512;
		final String expected = HashExtensions.hash(password, salt, hashAlgorithm, charset);
		final String actual = HashExtensions.hash(newInsertPassword, salt, hashAlgorithm, charset);

		AssertJUnit.assertTrue("'expected' should be equal with 'actual'.",
			expected.equals(actual));
	}

	/**
	 * Test method for {@link HashExtensions#hashAndBase64(String, String, HashAlgorithm, Charset)}
	 *
	 * @throws NoSuchAlgorithmException
	 *             is thrown if instantiation of the MessageDigest object fails.
	 */
	@Test
	public void testHashAndBase64() throws NoSuchAlgorithmException
	{
		final Charset charset = Charset.forName("UTF-8");
		final String password = "secret";
		final String newInsertPassword = "secret";
		final String salt = "NzeCdmaz";
		final HashAlgorithm hashAlgorithm = HashAlgorithm.SHA_512;
		final String expected = HashExtensions.hashAndBase64(password, salt, hashAlgorithm, charset);
		final String actual = HashExtensions.hashAndBase64(newInsertPassword, salt, hashAlgorithm, charset);
		AssertJUnit.assertTrue("'expected' should be equal with 'actual'.",
			expected.equals(actual));
	}

}

@@ -1298,17 +1298,25 @@
 org.
-junit.Tes
+testng.AssertJUni
 t;%0Ai
@@ -1332,26 +1332,31 @@
 .testng.
-AssertJUni
+annotations.Tes
 t;%0A%0Aimpo
@@ -1502,16 +1502,804 @@
 Test%0A%7B%0A%0A
+%09/**%0A%09 * Test method for %7B@link HashExtensions#hash(byte%5B%5D, HashAlgorithm)%7D%0A%09 *%0A%09 * @throws NoSuchAlgorithmException%0A%09 *             is thrown if instantiation of the MessageDigest object fails.%0A%09 */%0A%09@Test%0A%09public void testHashByteArrayWithAlgorithm() throws NoSuchAlgorithmException%0A%09%7B%0A%09%09final String password = %22abcdefghijklmnopqrst%22;%0A%09%09final String newInsertPassword = %22abcdefghijklmnopqrst%22;%0A%09%09final HashAlgorithm hashAlgorithm = HashAlgorithm.SHA_512;%0A%09%09byte%5B%5D expected = HashExtensions.hash(password.getBytes(), hashAlgorithm);%0A%09%09byte%5B%5D actual = HashExtensions.hash(newInsertPassword.getBytes(), hashAlgorithm);%0A%0A%09%09AssertJUnit.assertTrue(expected.length == actual.length);%0A%09%09AssertJUnit.assertTrue(%22'expected' should be equal with 'actual'.%22, Arrays.equals(expected, actual));%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -2830,31 +2830,24 @@
 .SHA_512;%0A%09%09
-final  
 byte%5B%5D expec
@@ -2930,22 +2930,360 @@
 ;%0A%09%09
-final  
 byte%5B%5D 
+actual = HashExtensions.hash(newInsertPassword.getBytes(), salt, hashAlgorithm, charset);%0A%0A%09%09AssertJUnit.assertTrue(expected.length == actual.length);%0A%09%09AssertJUnit.assertTrue(%22'expected' should be equal with 'actual'.%22, Arrays.equals(expected, actual));%0A%09%09%0A%09%09expected = HashExtensions.hash(password.getBytes(), null, hashAlgorithm, charset);%0A%09%09
 actu
@@ -3329,36 +3329,36 @@
 ord.getBytes(), 
-salt
+null
 , hashAlgorithm,

Update HashExtensionsTest.java