// test sending an OFF status message. public void testSendOffStatus() { StringBuilder sb = new StringBuilder(); java.io.DataOutputStream output = new java.io.DataOutputStream( new java.io.OutputStream() { @Override public void write(int b) throws java.io.IOException { sb.append((char) b); } }); java.io.DataInputStream input = new java.io.DataInputStream(System.in); SimplePowerServer a = new SimplePowerServer(input, output); try { a.sendStatus(jmri.PowerManager.OFF); Assert.assertEquals("send OFF Status check", "POWER OFF\n", sb.toString()); } catch (java.io.IOException ioe) { Assert.fail("Exception sending Off Status"); } }
// test parsing an OFF status message. public void testParseOffStatus() { java.io.DataOutputStream output = new java.io.DataOutputStream( new java.io.OutputStream() { // null output string drops characters // could be replaced by one that checks for specific outputs @Override public void write(int b) throws java.io.IOException {} }); java.io.DataInputStream input = new java.io.DataInputStream(System.in); SimplePowerServer a = new SimplePowerServer(input, output); try { a.parseStatus("POWER OFF\n"); Assert.assertEquals( "Parse OFF Status Check", jmri.InstanceManager.getDefault(jmri.PowerManager.class).getPower(), jmri.PowerManager.OFF); } catch (jmri.JmriException jmrie) { Assert.fail("Exception retrieving Status"); } }