Search in sources :

Example 1 with BindParameter

use of org.jsmpp.session.BindParameter in project camel by apache.

the class SmppConsumer method createSession.

private SMPPSession createSession() throws IOException {
    SMPPSession session = createSMPPSession();
    session.setEnquireLinkTimer(configuration.getEnquireLinkTimer());
    session.setTransactionTimer(configuration.getTransactionTimer());
    session.addSessionStateListener(internalSessionStateListener);
    session.setMessageReceiverListener(messageReceiverListener);
    session.connectAndBind(this.configuration.getHost(), this.configuration.getPort(), new BindParameter(BindType.BIND_RX, this.configuration.getSystemId(), this.configuration.getPassword(), this.configuration.getSystemType(), TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, configuration.getAddressRange()));
    return session;
}
Also used : BindParameter(org.jsmpp.session.BindParameter) SMPPSession(org.jsmpp.session.SMPPSession)

Example 2 with BindParameter

use of org.jsmpp.session.BindParameter in project camel by apache.

the class SmppProducerLazySessionCreationTest method processShouldCreateTheSmppSession.

@Test
public void processShouldCreateTheSmppSession() throws Exception {
    expect(endpoint.getConnectionString()).andReturn("smpp://smppclient@localhost:2775").times(2);
    //expectation
    session.setEnquireLinkTimer(5000);
    //expectation
    session.setTransactionTimer(10000);
    session.addSessionStateListener(isA(SessionStateListener.class));
    expect(session.connectAndBind("localhost", new Integer(2775), new BindParameter(BindType.BIND_TX, "smppclient", "password", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, ""))).andReturn("1");
    expect(endpoint.getConnectionString()).andReturn("smpp://smppclient@localhost:2775");
    expect(endpoint.isSingleton()).andReturn(true);
    SmppBinding binding = createMock(SmppBinding.class);
    Exchange exchange = createMock(Exchange.class);
    Message in = createMock(Message.class);
    SmppCommand command = createMock(SmppCommand.class);
    expect(endpoint.getBinding()).andReturn(binding);
    expect(binding.createSmppCommand(session, exchange)).andReturn(command);
    expect(exchange.getIn()).andReturn(in);
    expect(in.getHeader("CamelSmppSystemId", String.class)).andReturn(null);
    expect(in.getHeader("CamelSmppPassword", String.class)).andReturn(null);
    command.execute(exchange);
    replay(session, endpoint, binding, exchange, in, command);
    producer.doStart();
    producer.process(exchange);
    verify(session, endpoint, binding, exchange, in, command);
}
Also used : Exchange(org.apache.camel.Exchange) SessionStateListener(org.jsmpp.session.SessionStateListener) Message(org.apache.camel.Message) BindParameter(org.jsmpp.session.BindParameter) Test(org.junit.Test)

Example 3 with BindParameter

use of org.jsmpp.session.BindParameter in project camel by apache.

the class SmppProducerLazySessionCreationTest method processShouldCreateTheSmppSessionWithTheSystemIdAndPasswordFromTheExchange.

@Test
public void processShouldCreateTheSmppSessionWithTheSystemIdAndPasswordFromTheExchange() throws Exception {
    expect(endpoint.getConnectionString()).andReturn("smpp://localhost:2775").times(2);
    //expectation
    session.setEnquireLinkTimer(5000);
    //expectation
    session.setTransactionTimer(10000);
    session.addSessionStateListener(isA(SessionStateListener.class));
    expect(session.connectAndBind("localhost", new Integer(2775), new BindParameter(BindType.BIND_TX, "smppclient2", "password2", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, ""))).andReturn("1");
    expect(endpoint.getConnectionString()).andReturn("smpp://localhost:2775");
    SmppBinding binding = createMock(SmppBinding.class);
    Exchange exchange = createMock(Exchange.class);
    Message in = createMock(Message.class);
    SmppCommand command = createMock(SmppCommand.class);
    expect(endpoint.getBinding()).andReturn(binding);
    expect(endpoint.isSingleton()).andReturn(true);
    expect(binding.createSmppCommand(session, exchange)).andReturn(command);
    expect(exchange.getIn()).andReturn(in);
    expect(in.getHeader("CamelSmppSystemId", String.class)).andReturn("smppclient2");
    expect(in.getHeader("CamelSmppPassword", String.class)).andReturn("password2");
    command.execute(exchange);
    replay(session, endpoint, binding, exchange, in, command);
    producer.doStart();
    producer.process(exchange);
    verify(session, endpoint, binding, exchange, in, command);
}
Also used : Exchange(org.apache.camel.Exchange) SessionStateListener(org.jsmpp.session.SessionStateListener) Message(org.apache.camel.Message) BindParameter(org.jsmpp.session.BindParameter) Test(org.junit.Test)

Example 4 with BindParameter

use of org.jsmpp.session.BindParameter in project camel by apache.

the class SmppProducerTest method doStartExpectations.

private void doStartExpectations() throws IOException {
    expect(endpoint.getConnectionString()).andReturn("smpp://smppclient@localhost:2775").times(2);
    //expectation
    session.setEnquireLinkTimer(5000);
    //expectation
    session.setTransactionTimer(10000);
    session.addSessionStateListener(isA(SessionStateListener.class));
    expect(session.connectAndBind("localhost", new Integer(2775), new BindParameter(BindType.BIND_TX, "smppclient", "password", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, ""))).andReturn("1");
    expect(endpoint.getConnectionString()).andReturn("smpp://smppclient@localhost:2775");
    expect(endpoint.isSingleton()).andReturn(true);
}
Also used : SessionStateListener(org.jsmpp.session.SessionStateListener) BindParameter(org.jsmpp.session.BindParameter)

Example 5 with BindParameter

use of org.jsmpp.session.BindParameter in project camel by apache.

the class SmppProducer method createSession.

private SMPPSession createSession() throws IOException {
    LOG.debug("Connecting to: {}...", getEndpoint().getConnectionString());
    SMPPSession session = createSMPPSession();
    session.setEnquireLinkTimer(this.configuration.getEnquireLinkTimer());
    session.setTransactionTimer(this.configuration.getTransactionTimer());
    session.addSessionStateListener(internalSessionStateListener);
    session.connectAndBind(this.configuration.getHost(), this.configuration.getPort(), new BindParameter(BindType.BIND_TX, this.configuration.getSystemId(), this.configuration.getPassword(), this.configuration.getSystemType(), TypeOfNumber.valueOf(configuration.getTypeOfNumber()), NumberingPlanIndicator.valueOf(configuration.getNumberingPlanIndicator()), ""));
    LOG.info("Connected to: {}", getEndpoint().getConnectionString());
    return session;
}
Also used : BindParameter(org.jsmpp.session.BindParameter) SMPPSession(org.jsmpp.session.SMPPSession)

Aggregations

BindParameter (org.jsmpp.session.BindParameter)7 SessionStateListener (org.jsmpp.session.SessionStateListener)4 Test (org.junit.Test)4 Exchange (org.apache.camel.Exchange)2 Message (org.apache.camel.Message)2 SMPPSession (org.jsmpp.session.SMPPSession)2 MessageReceiverListener (org.jsmpp.session.MessageReceiverListener)1