public class MacTest
extends TestCase
Modifier and Type | Field and Description |
---|---|
static String |
srvMac |
static String[] |
validAlgorithmsMac |
Constructor and Description |
---|
MacTest() |
Modifier and Type | Method and Description |
---|---|
static Test |
suite() |
void |
test_getAlgorithm() |
void |
test_getProvider() |
void |
testClone()
Test for
clone() method
Assertion: clone if provider is clo |
void |
testGetMacLength()
Test for
getMacLength() method
Assertion: return Mac length |
void |
testInit()
Test for
init(Key key, AlgorithmParameterSpec params)
init(Key key)
methods
Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException
when parameters are not appropriate |
void |
testMac01()
Test for
getInstance(String algorithm) method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not available |
void |
testMac02()
Test for
getInstance(String algorithm) method
Assertion: returns Mac object |
void |
testMac03()
Test for
getInstance(String algorithm, String provider) method
Assertion:
throws IllegalArgumentException when provider is null or empty
throws NoSuchProviderException when provider is not available |
void |
testMac04()
Test for
getInstance(String algorithm, String provider) method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not available |
void |
testMac05()
Test for
getInstance(String algorithm, String provider) method
Assertion: returns Mac object |
void |
testMac06()
Test for
getInstance(String algorithm, Provider provider) method
Assertion: throws IllegalArgumentException when provider is null |
void |
testMac07()
Test for
getInstance(String algorithm, Provider provider) method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not available |
void |
testMac08()
Test for
getInstance(String algorithm, Provider provider) method
Assertion: returns Mac object |
void |
testMac09()
Test for
update and doFinal methods
Assertion: throws IllegalStateException when Mac is not initialized |
void |
testMac10()
Test for
doFinal(byte[] output, int outOffset) method
Assertion:
throws ShotBufferException when outOffset is negative or
outOffset >= output.length or when given buffer is small |
void |
testMac11()
Test for
doFinal(byte[] output, int outOffset) and
doFinal() methods Assertion: Mac result is stored in
output buffer |
void |
testMac12()
Test for
doFinal(byte[] input) method
Assertion: update Mac and returns result |
void |
testMac13()
Test for
update(byte[] input, int outset, int len) method
Assertion: throws IllegalArgumentException when offset or len is negative,
offset + len >= input.length |
void |
testMac14()
Test for
update(byte[] input, int outset, int len) and
update(byte[] input
methods
Assertion: updates Mac |
void |
testMacClone()
Test for
clone() method
Assertion: returns Mac object or throws CloneNotSupportedException |
void |
testMacConstructor()
Test for
Mac constructor
Assertion: returns Mac object |
void |
testReset()
Test for
reset() method
Assertion: return Mac length |
void |
testUpdateByteBuffer01()
Test for
update(ByteBuffer input)
update(byte[] input, int offset, int len)
methods
Assertion: processes Mac; if input is null then do nothing |
void |
testUpdateByteBuffer02()
Test for
update(ByteBuffer input)
update(byte[] input, int offset, int len)
methods
Assertion: processes Mac |
public static final String srvMac
public static final String[] validAlgorithmsMac
public void testMac01()
getInstance(String algorithm)
method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not availablepublic void testMac02() throws NoSuchAlgorithmException
getInstance(String algorithm)
method
Assertion: returns Mac objectNoSuchAlgorithmException
public void testMac03() throws NoSuchAlgorithmException, NoSuchProviderException
getInstance(String algorithm, String provider)
method
Assertion:
throws IllegalArgumentException when provider is null or empty
throws NoSuchProviderException when provider is not availablepublic void testMac04() throws NoSuchAlgorithmException, IllegalArgumentException, NoSuchProviderException
getInstance(String algorithm, String provider)
method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not availablepublic void testMac05() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException
getInstance(String algorithm, String provider)
method
Assertion: returns Mac objectpublic void testMac06() throws NoSuchAlgorithmException, NoSuchProviderException
getInstance(String algorithm, Provider provider)
method
Assertion: throws IllegalArgumentException when provider is nullpublic void testMac07() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException
getInstance(String algorithm, Provider provider)
method
Assertion:
throws NullPointerException when algorithm is null
throws NoSuchAlgorithmException when algorithm is not availablepublic void testMac08() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException
getInstance(String algorithm, Provider provider)
method
Assertion: returns Mac objectpublic void testMac09() throws Exception
update
and doFinal
methods
Assertion: throws IllegalStateException when Mac is not initializedException
public void testMac10() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidKeyException
doFinal(byte[] output, int outOffset)
method
Assertion:
throws ShotBufferException when outOffset is negative or
outOffset >= output.length or when given buffer is smallpublic void testMac11() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidKeyException, ShortBufferException
doFinal(byte[] output, int outOffset)
and
doFinal()
methods Assertion: Mac result is stored in
output bufferpublic void testMac12() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidKeyException
doFinal(byte[] input)
method
Assertion: update Mac and returns resultpublic void testMac13() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidKeyException
update(byte[] input, int outset, int len)
method
Assertion: throws IllegalArgumentException when offset or len is negative,
offset + len >= input.lengthpublic void testMac14() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidKeyException
update(byte[] input, int outset, int len)
and
update(byte[] input
methods
Assertion: updates Macpublic void testMacClone() throws NoSuchAlgorithmException, CloneNotSupportedException
clone()
method
Assertion: returns Mac object or throws CloneNotSupportedExceptionpublic void testInit() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, InvalidKeyException
init(Key key, AlgorithmParameterSpec params)
init(Key key)
methods
Assertion: throws InvalidKeyException and InvalidAlgorithmParameterException
when parameters are not appropriatepublic void testUpdateByteBuffer01() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, InvalidKeyException
update(ByteBuffer input)
update(byte[] input, int offset, int len)
methods
Assertion: processes Mac; if input is null then do nothingpublic void testUpdateByteBuffer02() throws NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException, IllegalStateException, InvalidAlgorithmParameterException, InvalidKeyException
update(ByteBuffer input)
update(byte[] input, int offset, int len)
methods
Assertion: processes Macpublic void testClone()
clone()
method
Assertion: clone if provider is clopublic void testGetMacLength()
getMacLength()
method
Assertion: return Mac lengthpublic void testReset() throws InvalidKeyException
reset()
method
Assertion: return Mac lengthInvalidKeyException
public void testMacConstructor() throws NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException
Mac
constructor
Assertion: returns Mac objectpublic void test_getAlgorithm() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public void test_getProvider() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public static Test suite()