@Test(expected = IllegalStateException.class)
public void bothMethodAndCodeUsed() throws CoapException, IOException {

    CoapPacket cp = new CoapPacket(Method.DELETE, null, "", null);
    cp.setCode(Code.C202_DELETED);
    CoapTcpPacketSerializer.serialize(cp);
}