KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > driver > jexl > JexlConnectionPerfTest


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.driver.jexl;
17
18 import scriptella.AbstractTestCase;
19 import scriptella.configuration.MockConnectionEl;
20 import scriptella.configuration.StringResource;
21 import scriptella.spi.ConnectionParameters;
22 import scriptella.spi.IndexedQueryCallback;
23 import scriptella.spi.MockDriverContext;
24 import scriptella.spi.MockParametersCallbacks;
25 import scriptella.spi.ParametersCallback;
26 import scriptella.spi.Resource;
27
28 import java.util.Collections JavaDoc;
29
30 /**
31  * @author Fyodor Kupolov
32  * @version 1.0
33  * @since 12.01.2007
34  */

35 public class JexlConnectionPerfTest extends AbstractTestCase {
36
37     /**
38      * History:
39      * 12.01.2007 - Duron 1.7Mhz - 670 ms
40      */

41     public void testExecuteScript() {
42         Resource r = new StringResource("x=0;while (x < 2000) {x=x+step;};");
43         JexlConnection jc = new JexlConnection(new ConnectionParameters(new MockConnectionEl(), new MockDriverContext()));
44         for (int i = 0; i < 200; i++) {
45             jc.executeScript(r, MockParametersCallbacks.fromMap(Collections.singletonMap("step", 1)));
46         }
47     }
48
49     /**
50      * History:
51      * 12.01.2007 - Duron 1.7Mhz - 720 ms
52      */

53     public void testExecuteQuery() {
54         Resource r = new StringResource("i=0;while (i < maxI) {i=i+1;query.next();}");
55         JexlConnection jc = new JexlConnection(new ConnectionParameters(new MockConnectionEl(), new MockDriverContext()));
56         IndexedQueryCallback callback = new IndexedQueryCallback() {
57             protected void processRow(final ParametersCallback parameters, final int rowNumber) {
58                 parameters.getParameter("i");
59             }
60         };
61         for (int i=0;i<10;i++) {
62             jc.executeQuery(r, MockParametersCallbacks.fromMap(Collections.singletonMap("maxI", 20000)), callback);
63         }
64
65     }
66
67 }
68
Popular Tags