@Test public void testPacketExtension() throws Exception {
OADRPacketCollector packetCollector = new OADRPacketCollector();
venConnection.addPacketListener(packetCollector, new OADR2PacketFilter());
IQ iq = new OADR2IQ(new OADR2PacketExtension(createEventPayload(), this.marshaller));
iq.setTo(venConnection.getUser());
iq.setType(IQ.Type.SET);
vtnConnection.sendPacket(iq);
Packet packet = packetCollector.getQueue().poll(5,TimeUnit.SECONDS);
// Thread.sleep(1000000);
assertNotNull( "Received packet should not be null", packet);
assertTrue( "Packet should be an instance of OADRIQ", packet instanceof OADR2IQ );
assertNotNull( "OADR payload should not be null", ((OADR2IQ)packet).getOADRPayload() );
OADR2PacketExtension extension = (OADR2PacketExtension)packet.getExtension(XMLNS.OADR2.getNamespaceURI());
assertEquals( "Packet extension should be an oadrSignedObject element",
"oadrSignedObject", extension.getElementName());
assertEquals( "Extension should have the OADR2 namespace",
XMLNS.OADR2.getNamespaceURI(), extension.getNamespace());
Object pObj = extension.getPayload();
assertNotNull( "Extension payload should not be null", pObj );
assertTrue( "Extension payload should be an OadrSignedObject", pObj instanceof OadrSignedObject );
OadrSignedObject payload = (OadrSignedObject)pObj;
assertEquals( "Request ID should match what was sent",
"test 1234", payload.getOadrDistributeEvent().getRequestID() );