Java Code Examples for org.jivesoftware.smack.packet.Stanza#setFrom()

The following examples show how to use org.jivesoftware.smack.packet.Stanza#setFrom() . 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: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void autoCompareMatchingEntityFullJid() {
    FromMatchesFilter filter = FromMatchesFilter.create(FULL_JID1_R1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(FULL_JID1_R1);
    assertTrue(filter.accept(packet));

    packet.setFrom(BASE_JID1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 2
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
    public void autoCompareMatchingBaseJid() {
        FromMatchesFilter filter = FromMatchesFilter.create(BASE_JID1);
        Stanza packet = StanzaBuilder.buildMessage().build();

        packet.setFrom(BASE_JID1);
        assertTrue(filter.accept(packet));

        packet.setFrom(FULL_JID1_R1);
        assertTrue(filter.accept(packet));

        packet.setFrom(FULL_JID1_R2);
        assertTrue(filter.accept(packet));

        packet.setFrom(BASE_JID2);
        assertFalse(filter.accept(packet));

        packet.setFrom(FULL_JID2);
        assertFalse(filter.accept(packet));

        packet.setFrom(BASE_JID3);
        assertFalse(filter.accept(packet));
}
 
Example 3
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void autoCompareMatchingServiceJid() {
    FromMatchesFilter filter = FromMatchesFilter.create(SERVICE_JID1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(SERVICE_JID1);
    assertTrue(filter.accept(packet));

    packet.setFrom(SERVICE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R1);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 4
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void bareCompareMatchingEntityFullJid() {
    FromMatchesFilter filter = FromMatchesFilter.createBare(FULL_JID1_R1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(BASE_JID1);
    assertTrue(filter.accept(packet));

    packet.setFrom(FULL_JID1_R1);
    assertTrue(filter.accept(packet));

    packet.setFrom(FULL_JID1_R2);
    assertTrue(filter.accept(packet));

    packet.setFrom(BASE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 5
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
    public void bareCompareMatchingBaseJid() {
        FromMatchesFilter filter = FromMatchesFilter.createBare(BASE_JID1);
        Stanza packet = StanzaBuilder.buildMessage().build();

        packet.setFrom(BASE_JID1);
        assertTrue(filter.accept(packet));

        packet.setFrom(FULL_JID1_R1);
        assertTrue(filter.accept(packet));

        packet.setFrom(FULL_JID1_R2);
        assertTrue(filter.accept(packet));

        packet.setFrom(BASE_JID2);
        assertFalse(filter.accept(packet));

        packet.setFrom(FULL_JID2);
        assertFalse(filter.accept(packet));

        packet.setFrom(BASE_JID3);
        assertFalse(filter.accept(packet));
}
 
Example 6
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void bareCompareMatchingServiceJid() {
    FromMatchesFilter filter = FromMatchesFilter.createBare(SERVICE_JID1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(SERVICE_JID1);
    assertTrue(filter.accept(packet));

    packet.setFrom(SERVICE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R1);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 7
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void fullCompareMatchingEntityFullJid() {
    FromMatchesFilter filter = FromMatchesFilter.createFull(FULL_JID1_R1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(FULL_JID1_R1);
    assertTrue(filter.accept(packet));

    packet.setFrom(BASE_JID1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 8
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 6 votes vote down vote up
@Test
public void fullCompareMatchingBaseJid() {
    FromMatchesFilter filter = FromMatchesFilter.createFull(BASE_JID1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(BASE_JID1);
    assertTrue(filter.accept(packet));

    packet.setFrom(FULL_JID1_R1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}
 
Example 9
Source File: FromMatchesFilterTest.java    From Smack with Apache License 2.0 5 votes vote down vote up
@Test
public void fullCompareMatchingServiceJid() {
    FromMatchesFilter filter = FromMatchesFilter.createFull(SERVICE_JID1);
    Stanza packet = StanzaBuilder.buildMessage().build();

    packet.setFrom(SERVICE_JID1);
    assertTrue(filter.accept(packet));

    packet.setFrom(SERVICE_JID2);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID1);
    assertFalse(filter.accept(packet));

    packet.setFrom(FULL_JID1_R1);
    assertFalse(filter.accept(packet));

    packet.setFrom(BASE_JID3);
    assertFalse(filter.accept(packet));
}