1 package org.umu.cops.stack;
3 import org.junit.Assert;
7 * Tests for the first constructor of the COPSHandle class.
8 * Should any of these tests be inaccurate it is due to the fact that they have been written after COPSHandle had been
9 * released and my assumptions may be incorrect.
11 public class COPSHandleFirstConstructorTest {
13 @Test (expected = IllegalArgumentException.class)
14 public void constructWithNullId() {
15 final COPSData id = null;
20 public void constructWithDefaultId() {
21 final COPSData id = new COPSData();
22 final COPSHandle handle = new COPSHandle(id);
23 Assert.assertEquals(0, handle.getDataLength());
24 Assert.assertTrue(id.equals(handle.getId()));
26 final COPSHandle eqHash = new COPSHandle(id);
27 Assert.assertTrue(handle.equals(eqHash));
28 Assert.assertEquals(handle.hashCode(), eqHash.hashCode());
32 public void constructWithData() {
33 final COPSData id = new COPSData("12345");
34 final COPSHandle handle = new COPSHandle(id);
36 // TODO - need to determine if 12 is indeed correct given the value "123456778"
37 Assert.assertEquals(8, handle.getDataLength());
38 Assert.assertTrue(id.equals(handle.getId()));
40 final COPSHandle eqHash = new COPSHandle(id);
41 Assert.assertTrue(handle.equals(eqHash));
42 Assert.assertEquals(handle.hashCode(), eqHash.hashCode());