@Test
    public void testMessageObserver() {
        System.out.println("testMessageObserver");

        try {
            assertTrue(c.registerToServer(GlobalConstants.IP_LOOPBACK));
        } catch (Exception ex) {
            fail("Registration from client to server failed - " + ex);
        }

        final StringBuilder sbServer = new StringBuilder();
        final StringBuilder sbClient = new StringBuilder();

        s.getListenerRegistrator().addMessageObserver(new Observer() {
            @Override
            public void update(Observable o, Object arg) {
                if (arg instanceof DataPacket) {
                    DataPacket dp = (DataPacket) arg;

                    if (dp.getData() instanceof Message) {
                        final Message m = (Message) dp.getData();
                        sbServer.append(m.getHeader());
                        sbServer.reverse();
                    } else {
                        sbServer.append(GenericResponses.OK);
                    }
                }
            }
        });
        final Observer o = new Observer() {
            @Override
            public void update(Observable o, Object arg) {
                if (arg instanceof DataPacket) {
                    DataPacket dp = (DataPacket) arg;

                    if (dp.getData() instanceof Message) {
                        final Message m = (Message) dp.getData();
                        sbClient.append(m.getHeader());
                        sbClient.reverse();
                    } else {
                        sbClient.append(GenericResponses.OK);
                    }
                }
            }
        };
        c.getListenerRegistrator().addMessageObserver(o);

        try {
            final String header = "abcdefg";
            final Message m = new Message(header, "data");
            final StringBuilder expected = new StringBuilder();

            assertEquals(GenericResponses.NOT_HANDLED_DIRECTLY, c.sendDataToServer(m,100000));
            assertEquals(GenericResponses.NOT_HANDLED_DIRECTLY, s.getClient(c.getLocalID()).sendData(m));
            expected.append(header);
            expected.reverse();

            synchronized (this) {
                this.wait(10);
            }

            assertEquals(expected.toString(), sbServer.toString());
            assertEquals(expected.toString(), sbClient.toString());

            assertEquals(GenericResponses.NOT_HANDLED_DIRECTLY, c.sendDataToServer(header));
            assertEquals(GenericResponses.NOT_HANDLED_DIRECTLY, s.getClient(c.getLocalID()).sendData(header));
            expected.append(GenericResponses.OK);

            synchronized (this) {
                this.wait(10);
            }

            assertEquals(expected.toString(), sbServer.toString());
            assertEquals(expected.toString(), sbClient.toString());

            c.getListenerRegistrator().removeMessageObserver(o);
            s.getClient(c.getLocalID()).sendData(m);
            assertEquals(expected.toString(), sbClient.toString());
        } catch (ConnectionException ex) {
            fail("Communication failed - " + ex);
        } catch (InterruptedException ex) {
            Logger.getLogger(MessagingTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }