Java Code Examples for org.jxmpp.jid.impl.JidCreate#fullFrom()

The following examples show how to use org.jxmpp.jid.impl.JidCreate#fullFrom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WrappedJid.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) {
    final Localpart localpart = inner.getLocalpartOrNull();
    try {
        final Resourcepart resourcepart = Resourcepart.from(resource.toString());
        if (localpart == null) {
            return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart));
        } else {
            return new WrappedJid(
                    JidCreate.fullFrom(
                            localpart,
                            inner.getDomain(),
                            resourcepart
                    ));
        }
    } catch (XmppStringprepException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 2
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void candidateFromStreamHostTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    String host = "localhost";
    int port = 1234;
    Bytestream.StreamHost streamHost = new Bytestream.StreamHost(jid, host, port);

    JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate(streamHost, 2000, JingleS5BTransportCandidate.Type.direct);

    assertEquals(2000, candidate.getPriority());
    assertEquals(jid, candidate.getJid());
    assertEquals(host, candidate.getHost().toString());
    assertEquals(port, candidate.getPort());

    assertEquals(streamHost.toXML().toString(), candidate.getStreamHost().toXML().toString());
}
 
Example 3
Source File: WrappedJid.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@Override
public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) {
    final Localpart localpart = inner.getLocalpartOrNull();
    try {
        final Resourcepart resourcepart = Resourcepart.from(resource.toString());
        if (localpart == null) {
            return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart));
        } else {
            return new WrappedJid(
                    JidCreate.fullFrom(
                            localpart,
                            inner.getDomain(),
                            resourcepart
                    ));
        }
    } catch (XmppStringprepException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 4
Source File: JingleTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void parserTest() throws XmppStringprepException {
    String sessionId = "testSessionId";

    Jingle.Builder builder = Jingle.getBuilder();
    builder.setSessionId(sessionId);
    builder.setAction(JingleAction.session_initiate);

    FullJid romeo = JidCreate.fullFrom("[email protected]/orchard");
    FullJid juliet = JidCreate.fullFrom("[email protected]/balcony");
    builder.setInitiator(romeo);
    builder.setResponder(juliet);

    Jingle jingle = builder.build();
    assertNotNull(jingle);
    assertEquals(romeo, jingle.getInitiator());
    assertEquals(juliet, jingle.getResponder());
    assertEquals(jingle.getAction(), JingleAction.session_initiate);
    assertEquals(sessionId, jingle.getSid());

    String xml = "<jingle xmlns='urn:xmpp:jingle:1' " +
            "initiator='[email protected]/orchard' " +
            "responder='[email protected]/balcony' " +
            "action='session-initiate' " +
            "sid='" + sessionId + "'>" +
            "</jingle>";
    assertTrue(jingle.toXML().toString().contains(xml));
}
 
Example 5
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void transportCandidateIllegalPriorityTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    assertThrows(IllegalArgumentException.class, () -> {
        new JingleS5BTransportCandidate(
                "cid", "localhost", jid, 5555, -30, JingleS5BTransportCandidate.Type.proxy);
    });
}
 
Example 6
Source File: JingleS5BTransportTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void transportCandidateIllegalPortTest() throws XmppStringprepException, UnknownHostException {
    FullJid jid = JidCreate.fullFrom("[email protected]/test");
    assertThrows(IllegalArgumentException.class, () -> {
        new JingleS5BTransportCandidate(
                "cid", "host", jid, -5555, 30, JingleS5BTransportCandidate.Type.proxy);
    });
}