/** Tests setting and getting the data using Proxy class accessor methods. */ @Test public void testDataAccessors() { // Create a new Proxy and use accessors to set the data Proxy proxy = new Proxy("colors"); proxy.setData(new String[] {"red", "green", "blue"}); String[] data = (String[]) proxy.getData(); // test assertions Assert.assertEquals("Expecting data.length == 3", data.length, 3); Assert.assertEquals("Expecting data[0] == 'red'", data[0], "red"); Assert.assertEquals("Expecting data[1] == 'green'", data[1], "green"); Assert.assertEquals("Expecting data[2] == 'blue'", data[2], "blue"); }
/** Tests setting the name and body using the Notification class Constructor. */ @Test public void testConstructor() { // Create a new Proxy using the Constructor to set the name and data Proxy proxy = new Proxy("colors", new String[] {"red", "green", "blue"}); String[] data = (String[]) proxy.getData(); // test assertions Assert.assertNotNull("Expecting proxy not null", proxy); Assert.assertEquals( "Expecting proxy.getProxyName() == 'colors'", proxy.getProxyName(), "colors"); Assert.assertEquals("Expecting data.length == 3", data.length, 3); Assert.assertEquals("Expecting data[0] == 'red'", data[0], "red"); Assert.assertEquals("Expecting data[1] == 'green'", data[1], "green"); Assert.assertEquals("Expecting data[2] == 'blue'", data[2], "blue"); }