XmppConnectionFactoryBean implements FactoryBean<XMPPTCPConnection>, InitializingBean, DisposableBean { @Override public void afterPropertiesSet() throws XMPPException, IOException, SmackException { XMPPTCPConnectionConfiguration configuration = createConnectionConfiguration(host, port, serviceName); Assert.notNull(configuration, "'configuration' must not be null"); Assert.hasText(username, "'username' must not be empty"); Assert.hasText(password, "'password' must not be empty"); connection = new XMPPTCPConnection(configuration); try { connection.connect(); if (StringUtils.hasText(resource)) { connection.login(username, password, Resourcepart.from(resource)); } else { connection.login(username, password); } } catch (InterruptedException e) { throw new IOException(e); } }  void setHost(String host); void setPort(int port); void setServiceName(String serviceName); void setUsername(String username); void setPassword(String password); void setResource(String resource); @Override void afterPropertiesSet(); @Override void destroy(); @Override XMPPTCPConnection getObject(); @Override Class<XMPPTCPConnection> getObjectType(); @Override boolean isSingleton();  }
@Test(expected = IllegalArgumentException.class) public void noHost() throws XMPPException, IOException, SmackException { factoryBean.afterPropertiesSet(); }