Package rocks.xmpp.core.stanza.model.client

Examples of rocks.xmpp.core.stanza.model.client.IQ


        Assert.assertEquals(xml, "<iq from=\"from@domain\" id=\"id\" to=\"to@domain\" type=\"get\"><error type=\"modify\"><service-unavailable xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"></service-unavailable></error></iq>");
    }

    @Test
    public void testErrorIQ() throws JAXBException, XMLStreamException {
        IQ iq = new IQ(IQ.Type.GET);
        iq.setId("id");
        iq.setTo(new Jid("to", "domain"));
        iq.setFrom(new Jid("from", "domain"));
        IQ error = iq.createError(new StanzaError(new UndefinedCondition()));
        Assert.assertEquals(error.getType(), IQ.Type.ERROR);
        Assert.assertEquals(error.getId(), iq.getId());
        Assert.assertEquals(error.getTo(), iq.getFrom());
        Assert.assertEquals(error.getFrom(), iq.getTo());
        Assert.assertEquals(error.getError().getBy(), error.getFrom());
    }
View Full Code Here


        Assert.assertEquals(error.getError().getBy(), error.getFrom());
    }

    @Test
    public void testResultIQ() throws JAXBException, XMLStreamException {
        IQ iq = new IQ(IQ.Type.GET);
        iq.setId("id");
        iq.setTo(new Jid("to", "domain"));
        iq.setFrom(new Jid("from", "domain"));
        IQ result = iq.createResult();
        Assert.assertEquals(result.getType(), IQ.Type.RESULT);
        Assert.assertEquals(result.getId(), iq.getId());
        Assert.assertEquals(result.getTo(), iq.getFrom());
        Assert.assertEquals(result.getFrom(), iq.getTo());
    }
View Full Code Here

                "       type='error'>\n" +
                "     <error type='modify'>\n" +
                "       <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </iq>";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertEquals(iq.getType(), IQ.Type.ERROR);
        Assert.assertNotNull(iq.getError());
        Assert.assertEquals(iq.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertTrue(iq.getError().getCondition() instanceof BadRequest);
    }
View Full Code Here

        String xml = "<iq id='wy2xa82b4' type='error'>\n" +
                "     <error type='cancel'>\n" +
                "       <conflict xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </iq>";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertEquals(iq.getType(), IQ.Type.ERROR);
        Assert.assertNotNull(iq.getError());
        Assert.assertEquals(iq.getError().getType(), StanzaError.Type.CANCEL);
        Assert.assertTrue(iq.getError().getCondition() instanceof Conflict);
    }
View Full Code Here

                "       <unsupported\n" +
                "           xmlns='http://jabber.org/protocol/pubsub#errors'\n" +
                "           feature='retrieve-subscriptions'/>\n" +
                "     </error>\n" +
                "   </iq>";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertEquals(iq.getType(), IQ.Type.ERROR);
        Assert.assertNotNull(iq.getError());
        Assert.assertEquals(iq.getError().getType(), StanzaError.Type.CANCEL);
        Assert.assertTrue(iq.getError().getCondition() instanceof FeatureNotImplemented);
    }
View Full Code Here

                "     <error type='wait'>\n" +
                "       <resource-constraint\n" +
                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "     </error>\n" +
                "   </iq>";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertNotNull(iq.getError());
        Assert.assertEquals(iq.getType(), IQ.Type.ERROR);
        Assert.assertEquals(iq.getError().getType(), StanzaError.Type.WAIT);
        Assert.assertTrue(iq.getError().getCondition() instanceof ResourceConstraint);
    }
View Full Code Here

                "    id='last1'\n" +
                "    to='romeo@montague.net/orchard'\n" +
                "    type='result'>\n" +
                "  <query xmlns='jabber:iq:last' seconds='903'/>\n" +
                "</iq>";
        IQ iq = unmarshal(xml, IQ.class);
        LastActivity lastActivity = iq.getExtension(LastActivity.class);
        Assert.assertNotNull(lastActivity);
        Assert.assertEquals(lastActivity.getSeconds(), 903);
    }
View Full Code Here

                "           xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "       <not-subscribed\n" +
                "           xmlns='http://jabber.org/protocol/pubsub#errors'/>\n" +
                "     </error>\n" +
                "   </iq>";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertNotNull(iq.getError());
        Assert.assertEquals(iq.getType(), IQ.Type.ERROR);
        Assert.assertEquals(iq.getError().getType(), StanzaError.Type.MODIFY);
        Assert.assertTrue(iq.getError().getCondition() instanceof UnexpectedRequest);
    }
View Full Code Here

    }


    @Test
    public void marshalEntityTimeRequest() throws XMLStreamException, JAXBException {
        IQ iq = new IQ("time_1", IQ.Type.GET, new EntityTime());
        String xml = marshal(iq);
        Assert.assertEquals(xml, "<iq id=\"time_1\" type=\"get\"><time xmlns=\"urn:xmpp:time\"></time></iq>");
    }
View Full Code Here

                "    <tzo>-06:00</tzo>\n" +
                "    <utc>2006-12-19T17:58:35Z</utc>\n" +
                "  </time>\n" +
                "</iq>";

        IQ iq = unmarshal(xml, IQ.class);
        EntityTime entityTime = iq.getExtension(EntityTime.class);
        Assert.assertNotNull(entityTime);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(entityTime.getTimezone());
        calendar.setTime(entityTime.getDate());
        Assert.assertEquals(calendar.get(Calendar.HOUR_OF_DAY), 11);
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.stanza.model.client.IQ

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.