mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leon Doud <leon.d...@gmail.com>
Subject Rosters not working as expected
Date Tue, 05 Mar 2013 03:42:11 GMT
Hello,

I'm trying to use Vysper (version 0.7)  to programmatically create an XMPP
server instance for use in a jUnit test. For the test there are two users
configured on the XMPP server. Each user has the other user on their own
roster.

The test sends one chat message from the first user to the second user. The
test does not work. I figured the message was being blocked because the
rosters are not setup correctly.

To test this theory I logged into the XMPP server as both users, using
Pidgin. When I logged in as "user1", the only person on my roster was
"user1".  When I logged in as "user2", no one was on my roster.

Below is the Java code where I attempt to programmatically create an XMPP
server, two users and rosters for both users. I appreciate any help
figuring out what I'm doing wrong.

Thanks,
Leon


package org.apache.cxf.transport.xmpp.chat;

import org.apache.vysper.mina.TCPEndpoint;
import org.apache.vysper.storage.StorageProviderRegistry;
import org.apache.vysper.storage.inmemory.MemoryStorageProviderRegistry;
import org.apache.vysper.xmpp.addressing.Entity;
import org.apache.vysper.xmpp.addressing.EntityImpl;
import org.apache.vysper.xmpp.authorization.AccountManagement;
import org.apache.vysper.xmpp.modules.roster.RosterItem;
import org.apache.vysper.xmpp.modules.roster.SubscriptionType;
import org.apache.vysper.xmpp.modules.roster.persistence.RosterManager;
import org.apache.vysper.xmpp.server.XMPPServer;

public class ConduitTest {

    private static final String CERT_FILENAME = "bogus_mina_tls.cert";
    private static final String CERT_PASSWORD = "boguspw";

    private static final String DOMAIN_NAME = "localhost.localdomain";
    private static final String USER2_NAME = "service1@" + DOMAIN_NAME;
    private static final String USER2_PASSWORD = "service1";

    private static final String USER1_NAME = "user1@" + DOMAIN_NAME;
    private static final String USER1_PASSWORD = "user1";

    public static void main(String[] args) throws Exception {
        XMPPServer server = new XMPPServer(DOMAIN_NAME);
        server.addEndpoint(new TCPEndpoint());

server.setTLSCertificateInfo(ClassLoader.getSystemResourceAsStream(CERT_FILENAME),
CERT_PASSWORD);

        // Store data in memory.
        StorageProviderRegistry providerRegistry = new
MemoryStorageProviderRegistry();
        server.setStorageProviderRegistry(providerRegistry);

        // Create test users.
        Entity user1Entity = EntityImpl.parse(USER1_NAME);
        Entity user2Entity = EntityImpl.parse(USER2_NAME);

        AccountManagement accountManagement =
(AccountManagement)providerRegistry.retrieve(AccountManagement.class);
        accountManagement.addUser(user1Entity, USER1_PASSWORD);
        accountManagement.addUser(user2Entity, USER2_PASSWORD);

        RosterManager rosterManager =
(RosterManager)providerRegistry.retrieve(RosterManager.class);
        rosterManager.addContact(user2Entity, new RosterItem(user1Entity,
SubscriptionType.BOTH));
        rosterManager.addContact(user1Entity, new RosterItem(user2Entity,
SubscriptionType.BOTH));

        server.start();
        Thread.sleep(60000);
        server.stop();
    }
}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message