01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.bpmscript;
18:
19: import org.bpmscript.StackTraceParser;
20:
21: import junit.framework.TestCase;
22:
23: public class StackTraceParserTest extends TestCase {
24:
25: protected void setUp() throws Exception {
26: super .setUp();
27: }
28:
29: protected void tearDown() throws Exception {
30: super .tearDown();
31: }
32:
33: /*
34: * Test method for 'org.bpmscript.jbi.StackTraceParser.getScriptStackTrace(String)'
35: */
36: public void testGetScriptStackTraceString() {
37: String trace = " at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2460)\n"
38: + " at script.pause(classpath:/org/bpmscript/jbi/bpmscriptlibrary.js:2)\n"
39: + " at script(classpath:/org/bpmscript/jbi/bpmscriptlibrary.js:86)\n"
40: + " at script.main(main.js:129)\n"
41: + " at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2250)\n"
42: + " at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:149)\n"
43: + " at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)\n"
44: + " at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)\n"
45: + " at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:147)\n"
46: + " at org.bpmscript.jbi.ProcessExecutor.send(ProcessExecutor.java:91)\n"
47: + " at org.bpmscript.jbi.BpmScriptComponent.onMessageExchange(BpmScriptComponent.java:77)\n"
48: + " at org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:671)\n"
49: + " at org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:176)\n"
50: + " at org.apache.servicemix.jbi.nmr.flow.jms.JMSFlow.access$001(JMSFlow.java:68)\n"
51: + " at org.apache.servicemix.jbi.nmr.flow.jms.JMSFlow$1.run(JMSFlow.java:411)\n"
52: + " at org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)\n"
53: + " at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)\n"
54: + " at java.lang.Thread.run(Unknown Source)";
55: StackTraceParser parser = new StackTraceParser();
56: StackTraceElement[] scriptStackTrace = parser
57: .getScriptStackTrace(trace);
58: assertNotNull(scriptStackTrace);
59: assertEquals(3, scriptStackTrace.length);
60: assertEquals("script", scriptStackTrace[0].getClassName());
61: assertEquals("pause", scriptStackTrace[0].getMethodName());
62: assertEquals(
63: "classpath:/org/bpmscript/jbi/bpmscriptlibrary.js",
64: scriptStackTrace[0].getFileName());
65: assertEquals(2, scriptStackTrace[0].getLineNumber());
66:
67: assertEquals("script", scriptStackTrace[1].getClassName());
68: assertEquals("", scriptStackTrace[1].getMethodName());
69: assertEquals(
70: "classpath:/org/bpmscript/jbi/bpmscriptlibrary.js",
71: scriptStackTrace[1].getFileName());
72: assertEquals(86, scriptStackTrace[1].getLineNumber());
73:
74: assertEquals("script", scriptStackTrace[2].getClassName());
75: assertEquals("main", scriptStackTrace[2].getMethodName());
76: assertEquals("main.js", scriptStackTrace[2].getFileName());
77: assertEquals(129, scriptStackTrace[2].getLineNumber());
78: }
79:
80: }
|