/** This test tests that complete packet is build correctly */ public static void PacketBuilderTest() throws IOException, JdpException { /* Complete packet test */ { JdpJmxPacket p1 = new JdpJmxPacket(UUID.randomUUID(), "fake://unit-test"); p1.setMainClass("FakeUnitTest"); p1.setInstanceName("Fake"); byte[] b = p1.getPacketData(); JdpJmxPacket p2 = new JdpJmxPacket(b); JdpDoSomething.printJdpPacket(p1); JdpDoSomething.compaireJdpPacketEx(p1, p2); } /*Missed field packet test*/ { JdpJmxPacket p1 = new JdpJmxPacket(UUID.randomUUID(), "fake://unit-test"); p1.setMainClass("FakeUnitTest"); p1.setInstanceName(null); byte[] b = p1.getPacketData(); JdpJmxPacket p2 = new JdpJmxPacket(b); JdpDoSomething.printJdpPacket(p1); JdpDoSomething.compaireJdpPacketEx(p1, p2); } System.out.println("OK: Test passed"); }
public static void main(String[] args) { try { PacketBuilderTest(); startFakeDiscoveryService(); JdpDoSomething.doSomething(); } catch (Throwable e) { e.printStackTrace(); System.out.println("Test failed. unexpected error " + e); } }