Here it is:

The stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range:
-12
        at java.lang.String.substring(String.java:1937)
        at
org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:539)
        at
org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:207)
        at org.smslib.Service.readMessages(Service.java:481)
        at org.smslib.Service.readMessages(Service.java:369)
        at
pl.waw.tusa.in.sms.SmsServiceTest.readMessages(SmsServiceTest.java:
112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
        at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
        at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
        at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
73)
        at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
46)
        at
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:
41)
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:
173)
        at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
        at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
        at
junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:
515)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:
1031)
        at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:
888)

The call:
    @Test
    public void readMessages() throws TimeoutException,
GatewayException, IOException, InterruptedException {
        Vector<InboundMessage> vector = new Vector<InboundMessage>();

        try {
            service.readMessages(vector, MessageClasses.ALL);
        } catch (Exception ex) {
            ex.printStackTrace();
        }


        for (InboundMessage msg : vector) {
            SmsListener smsListener = new SmsListener();
            smsListener.process(null, MessageTypes.INBOUND, msg);
        }
    }

The setup for the test:
    @Before
    public void setUp() throws GatewayException, SMSLibException,
TimeoutException, IOException, InterruptedException {
        service.startService();
    }



The constructor fot that test:
    public static String PORT = "COM7";
    public static String PIN = "1985";
    public static String PIN2 = "8173";
    private SerialModemGateway gateway;
    private Service service;
    private final static String ID = "TusA";

    public SmsServiceTest() throws GatewayException {
        gateway = new SerialModemGateway(ID, 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);
            }
        });
    }



Used lib: 3.4.5, tester - jUnit.

However, due to try-catching the exception, I am able to process
gathered messages. Anyway,
this is runtime exception which should not be catched on that purpose
and in that way (to control the code).

I'm looking forward to Your reply, I can post any information You want
and I am able to provide to You

--
Tomek

On Mar 20, 11:04 pm, Tomasz Jurkiewicz <[email protected]>
wrote:
> You will get it as soon as tomorrow, when I will have access to my device
> set.
>
> 2010/3/20 Thanasis <[email protected]>
>
>
>
>
>
> > Hi,
>
> > Please post the trace.
>
> > On 18 March 2010 18:26, Tomek Jurkiewicz <[email protected]>wrote:
>
> >> Anyway, I have different problem with smslib 3.4.3+ (inclusive) - I
> >> get some String.substring call exception.
>
> >> I traced it and it comes to be, that one of the indexes (in
> >> readMessages call), I think j = -1, is causing eventual
> >> exception, on both GenericATHandler and E160 Handler, when AT response
> >> +CMS: ERROR 321 (or 322) is encountered.
>
> >> Is it familiar to You? I switched to 3.4.2 (I do not get the
> >> exception).
> >> If not, I will post here the stacktrace.
>
> >> Cheers,
> >> Tomek
>
> >> On Mar 17, 6:30 pm, Thanasis <[email protected]> wrote:
> >> > Great! ;)
>
> >> > On Mar 17, 4:36 pm, Tomek Jurkiewicz <[email protected]>
> >> > wrote:
>
> >> > > And finally, the problem is solved ;)
>
> >> > > I just came up with the idea right after submitting the previous post.
> >> > > Smslib works fine and is great, and JUnit is great testing library,
> >> > > but...
> >> > > i misused it. Notice, that for every test I get different testing
> >> > > class instance, but the gateway is started only once, in one of the
> >> > > tests...
>
> >> > > That is all for now,
> >> > > Thank You for the attention ;)
>
> >> --
> >> 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]<smslib%[email protected]>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/smslib?hl=en.
>
> >  --
> > 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]<smslib%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/smslib?hl=en.
>
> --
> Pozdrawiam,
> Tomek Jurkiewicz

-- 
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