Example of standalone Apache Qpid (amqp) Junit Test

后端 未结 4 1471
失恋的感觉
失恋的感觉 2020-12-28 09:46

Does anyone have an example of using Apache Qpid within a standalone junit test.

Ideally I want to be able to create a queue on the fly which I can

4条回答
  •  醉酒成梦
    2020-12-28 10:11

    The best I could figure out was:

    PropertiesConfiguration properties = new PropertiesConfiguration();
    properties.addProperty("virtualhosts.virtualhost.name", "test");
    properties.addProperty("security.principal-databases.principal-database.name", "testPasswordFile");
    properties.addProperty("security.principal-databases.principal-database.class", "org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabase");
    ServerConfiguration config = new ServerConfiguration(properties);
    ApplicationRegistry.initialise(new ApplicationRegistry(config) {
        @Override
        protected void createDatabaseManager(ServerConfiguration configuration) throws Exception {
            Properties users = new Properties();
            users.put("guest","guest");
            users.put("admin","admin");
            _databaseManager = new PropertiesPrincipalDatabaseManager("testPasswordFile", users);
        }
    });
    TransportConnection.createVMBroker(ApplicationRegistry.DEFAULT_INSTANCE);
    

    With a URL of:

    amqp://admin:admin@/test?brokerlist='vm://:1?sasl_mechs='PLAIN''
    

    The big pain is with configuration and authorization. Milage may vary.

提交回复
热议问题