}
@Test
public void jmsRuntimeFactoryBuilderTest() throws InsufficientInfoToBuildException {
// url + all options
RemoteJmsRuntimeEngineFactory jmsRuntimeFactory =
RemoteJmsRuntimeEngineFactory.newBuilder()
.addDeploymentId("deployment")
.addProcessInstanceId(46l)
.addUserName("C")
.addPassword("cake")
.addRemoteInitialContext(remoteInitialContext)
.addTimeout(3)
.addExtraJaxbClasses(MyType.class)
.useSsl(false)
.buildFactory();
assertNotNull( jmsRuntimeFactory );
// context, minimum
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addRemoteInitialContext(remoteInitialContext)
.addUserName("E*")
.addPassword("koffie")
.buildFactory();
try {
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addRemoteInitialContext(remoteInitialContext)
.addPassword("koffie")
.buildFactory();
fail( "A user name should always be required!");
} catch(InsufficientInfoToBuildException e) {
// expected
}
try {
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addRemoteInitialContext(remoteInitialContext)
.addUserName("E*")
.buildFactory();
fail( "A password should always be required!");
} catch(InsufficientInfoToBuildException e) {
// expected
}
try {
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addUserName("E*")
.addPassword("koffie")
.buildFactory();
fail( "An inital context or server url should always be required!");
} catch(InsufficientInfoToBuildException e) {
// expected
}
// queue collection, minimum
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addUserName("M")
.addPassword("koekje")
.addKieSessionQueue(mock(Queue.class))
.addTaskServiceQueue(mock(Queue.class))
.addResponseQueue(mock(Queue.class))
.addConnectionFactory(mock(ConnectionFactory.class))
.buildFactory();
try {
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addUserName("1")
.addPassword("ijs")
.addTaskServiceQueue(mock(Queue.class))
.addResponseQueue(mock(Queue.class))
.addConnectionFactory(mock(ConnectionFactory.class))
.buildFactory();
jmsRuntimeFactory.newRuntimeEngine().getKieSession();
fail( "A ksession queue is required for a ksession!");
} catch( MissingRequiredInfoException e) {
// expected
}
try {
jmsRuntimeFactory = RemoteJmsRuntimeEngineFactory.newBuilder()
.addUserName("1")
.addPassword("ijs")
.addKieSessionQueue(mock(Queue.class))
.addResponseQueue(mock(Queue.class))
.addConnectionFactory(mock(ConnectionFactory.class))
.buildFactory();
jmsRuntimeFactory.newRuntimeEngine().getTaskService();
fail( "A task service queue is always required!");
} catch( MissingRequiredInfoException e) {
// expected
}