KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > expression > PropertiesSubstitutorPerfTest


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.expression;
17
18 import scriptella.AbstractTestCase;
19 import scriptella.spi.MockParametersCallbacks;
20
21 import java.util.Arrays JavaDoc;
22
23 /**
24  * Tests {@link scriptella.expression.PropertiesSubstitutor} performance.
25  *
26  * @author Fyodor Kupolov
27  * @version 1.0
28  */

29 public class PropertiesSubstitutorPerfTest extends AbstractTestCase {
30     /**
31      * History:
32      * 05.09.2006 - Duron 1700 Mhz - 4078 ms
33      */

34     public void test() {
35         PropertiesSubstitutor ps = new PropertiesSubstitutor(MockParametersCallbacks.NAME);
36
37         char [] fillC = new char[1000];
38         Arrays.fill(fillC,'-');
39         String JavaDoc fill = new String JavaDoc(fillC);
40
41         String JavaDoc line = "Text ${subst1} $subst2 "+fill+":$end //";
42         String JavaDoc exp = "Text subst1 subst2 "+fill+":end //";
43
44
45
46         for (int i=0;i<100000;i++) {
47             String JavaDoc s = ps.substitute(line);
48             assertEquals(exp, s);
49         }
50     }
51 }
52
Popular Tags