I slightly modified the code, and here it is:

public class SmsServiceTest {

    public static String PORT = "COM11";
    public static String PIN = "1985";
    public static String PIN2 = "1985";
    private SerialModemGateway gateway;
    private Service service;

    public SmsServiceTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() throws GatewayException {
        Logger.getRootLogger().setLevel(Level.ALL);
        gateway = new SerialModemGateway("TusA", PORT, 57600,
"Huawei", "E160");
        gateway.setProtocol(Protocols.PDU);
        gateway.setInbound(true);
        gateway.setOutbound(true);
        gateway.setSimPin(PIN);
        gateway.setSimPin2(PIN2);

        service = new Service();
        service.addGateway(gateway);
        gateway.setService(service);


        service.setCallNotification(new ICallNotification() {

            @Override
            public void process(String string, String string1) {
                System.err.println(string);
                System.err.println(string1);
            }
        });
        service.setInboundMessageNotification(new SmsListener());
        service.setGatewayStatusNotification(new
IGatewayStatusNotification() {

            @Override
            public void process(String string, GatewayStatuses
oldStatus, GatewayStatuses newStatus) {
                System.err.println(oldStatus + " -> " + newStatus);
            }
        });


    }

    @After
    public void tearDown() {
    }

    @Test
    public void startService() throws SMSLibException,
TimeoutException, GatewayException, IOException, InterruptedException
{
        service.startService();
        System.err.println("Signal level: " +
gateway.getSignalLevel());
        System.err.println("[start] Service status: " +
service.getServiceStatus());

    }

    @Test
    public void sendMessage() throws TimeoutException,
GatewayException, GatewayException, IOException, InterruptedException,
SMSLibException {
        System.err.println("[send] Service status: " +
service.getServiceStatus());
        service.sendMessage(new OutboundMessage("+48692439627",
"test"));
    }

    @Test
    public void readMessages() throws TimeoutException,
GatewayException, IOException, InterruptedException {
        List<InboundMessage> msgList;
        MessageClasses messageClass = MessageClasses.UNREAD;

        msgList = new ArrayList<InboundMessage>();
        System.err.println("[read] Service status: " +
service.getServiceStatus());
        this.gateway.readMessages(msgList, messageClass);

        messageClass = MessageClasses.UNREAD;
        System.err.println(msgList);
        for (InboundMessage msg : msgList) {
            SmsListener smsListener = new SmsListener();
            smsListener.process(null, MessageTypes.INBOUND, msg);
        }

    }
}


And the output:

------------- Standard Output ---------------
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
------------- ---------------- ---------------
------------- Standard Error -----------------
log4j:ERROR Could not find value for key log4j.appender.MAIL
log4j:ERROR Could not instantiate appender named "MAIL".
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: SMSLib: A Java API library for sending and receiving SMS via a
GSM modem or other supported gateways.
This software is distributed under the terms of the Apache v2.0
License.
Web Site: http://smslib.org
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: Version: 3.4.5
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: JRE Version: 1.6.0_17
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: JRE Impl Version: 14.3-b01
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: O/S: Windows XP / x86 / 5.1
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: GTW: TusA: Starting gateway, using Huawei E160 AT Handler.
2010-03-17 15:19:54 org.smslib.helper.Logger logInfo
INFO: GTW: TusA: Opening: COM11 @57600
2010-03-17 15:20:01 org.smslib.helper.Logger logInfo
INFO: GTW: TusA: GSM: Registered to home network.
2010-03-17 15:20:01 org.smslib.helper.Logger logInfo
INFO: GTW: TusA: MEM: Storage Locations Found: MESMSR
STOPPED -> STARTING
2010-03-17 15:20:01 org.smslib.helper.Logger logInfo
INFO: GTW: TusA: Gateway started.
STARTING -> STARTED
Signal level: 48
[start] Service status: STARTED
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: SMSLib: A Java API library for sending and receiving SMS via a
GSM modem or other supported gateways.
This software is distributed under the terms of the Apache v2.0
License.
Web Site: http://smslib.org
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: Version: 3.4.5
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: JRE Version: 1.6.0_17
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: JRE Impl Version: 14.3-b01
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: O/S: Windows XP / x86 / 5.1
[read] Service status: STOPPED
[]
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: SMSLib: A Java API library for sending and receiving SMS via a
GSM modem or other supported gateways.
This software is distributed under the terms of the Apache v2.0
License.
Web Site: http://smslib.org
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: Version: 3.4.5
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: JRE Version: 1.6.0_17
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: JRE Impl Version: 14.3-b01
2010-03-17 15:20:02 org.smslib.helper.Logger logInfo
INFO: O/S: Windows XP / x86 / 5.1
[send] Service status: STOPPED
------------- ---------------- ---------------

See this? Service status on both read and send is STOPPED, even though
I got notification that the service has started, and I was not
notified of
its subsequent status change (either to STOPPING or STOPPED). I also
debugged the code,
and in fact - I get return statement on line 583 of the Service class.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"SMSLib User Group" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/smslib?hl=en.

Reply via email to