@After public void clearProperty() { if (originalAmqUser == null) { System.clearProperty(DefaultConnectionProperties.AMQ_USER); } else { System.setProperty(DefaultConnectionProperties.AMQ_USER, originalAmqUser); } if (originalAmqPassword == null) { System.clearProperty(DefaultConnectionProperties.AMQ_PASSWORD); } else { System.setProperty(DefaultConnectionProperties.AMQ_PASSWORD, originalAmqPassword); } if (originalBrokerBindUrl == null) { System.clearProperty(DefaultConnectionProperties.BROKER_BIND_URL); } else { System.setProperty(DefaultConnectionProperties.BROKER_BIND_URL, originalBrokerBindUrl); } DefaultConnectionProperties.initialize(); }
/** * Login with valid user and password * Should allow */ @Test public void testLoginValidUserAndPasswordSystemProperty() throws Exception { System.setProperty(DefaultConnectionProperties.AMQ_USER, "guest"); System.setProperty(DefaultConnectionProperties.AMQ_PASSWORD, "guest"); DefaultConnectionProperties.initialize(); ConnectionFactory cf = new ActiveMQConnectionFactory(); Connection conn = addConnection(cf.createConnection()); }
/** * Login with valid user and password * Should allow */ @Test public void testLoginValidUserAndPasswordSystemPropertyWithAdditionalProperties() throws Exception { System.setProperty(DefaultConnectionProperties.AMQ_USER, "guest"); System.setProperty(DefaultConnectionProperties.AMQ_PASSWORD, "guest"); System.setProperty(DefaultConnectionProperties.BROKER_BIND_URL, "tcp://localhost:61616?compressLargeMessage=true"); DefaultConnectionProperties.initialize(); ConnectionFactory cf = new ActiveMQConnectionFactory(); Connection conn = addConnection(cf.createConnection()); Assert.assertTrue(((ActiveMQConnectionFactory) cf).isCompressLargeMessage()); }
/** * Login with valid user and invalid password * Should allow */ @Test public void testLoginValidUserInvalidPasswordSystemProperty() throws Exception { System.setProperty(DefaultConnectionProperties.AMQ_USER, "guest"); System.setProperty(DefaultConnectionProperties.AMQ_PASSWORD, "not.the.valid.password"); DefaultConnectionProperties.initialize(); try { ConnectionFactory cf = new ActiveMQConnectionFactory(); Connection conn1 = addConnection(cf.createConnection()); ProxyAssertSupport.fail(); } catch (JMSSecurityException e) { // Expected } }