KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > test > internal > performance > tests > VariationsTests


1 /*******************************************************************************
2  * Copyright (c) 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.test.internal.performance.tests;
12
13 import org.eclipse.test.internal.performance.db.Variations;
14
15 import junit.framework.TestCase;
16
17 public class VariationsTests extends TestCase {
18
19     public void testVariations() {
20         Variations v1= new Variations();
21         v1.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
22
assertEquals("|k1=foo|", v1.toExactMatchString()); //$NON-NLS-1$
23
assertEquals("%|k1=foo|%", v1.toQueryPattern()); //$NON-NLS-1$
24

25         Variations v2= new Variations();
26         v2.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
27
v2.put("k2", "bar"); //$NON-NLS-1$ //$NON-NLS-2$
28
assertEquals("|k1=foo||k2=bar|", v2.toExactMatchString()); //$NON-NLS-1$
29
assertEquals("%|k1=foo|%|k2=bar|%", v2.toQueryPattern()); //$NON-NLS-1$
30

31         Variations v3= new Variations();
32         v3.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
33
v3.put("k2", "bar"); //$NON-NLS-1$ //$NON-NLS-2$
34
v3.put("k3", "xyz"); //$NON-NLS-1$ //$NON-NLS-2$
35
assertEquals("|k1=foo||k2=bar||k3=xyz|", v3.toExactMatchString()); //$NON-NLS-1$
36
assertEquals("%|k1=foo|%|k2=bar|%|k3=xyz|%", v3.toQueryPattern()); //$NON-NLS-1$
37
}
38     
39     public void testParseVariations() {
40         Variations v1= new Variations();
41         v1.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
42

43         Variations v= new Variations();
44         v.parseDB(v1.toExactMatchString());
45         assertEquals(v1, v);
46         
47         Variations v2= new Variations();
48         v2.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
49
v2.put("k2", "bar"); //$NON-NLS-1$ //$NON-NLS-2$
50
v= new Variations();
51         v.parseDB(v2.toExactMatchString());
52         assertEquals(v2, v);
53
54         Variations v3= new Variations();
55         v3.put("k1", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
56
v3.put("k2", "bar"); //$NON-NLS-1$ //$NON-NLS-2$
57
v3.put("k3", "xyz"); //$NON-NLS-1$ //$NON-NLS-2$
58
v= new Variations();
59         v.parseDB(v3.toExactMatchString());
60         assertEquals(v3, v);
61     }
62     
63 // public void testMaxLength() {
64
// StringBuffer sb= new StringBuffer();
65
// for (int i= 0; i < 1000; i++)
66
// sb.append("0123456789"); //$NON-NLS-1$
67
// Variations v= new Variations(sb.toString(), null);
68
//
69
// String s1= v.toExactMatchString();
70
// assertTrue(s1.length() == 10000);
71
//
72
// String s2= v.toQueryPattern();
73
// assertTrue(s2.length() == 10000);
74
// }
75
}
76
Popular Tags