Source Code Cross Referenced for Test03Distance.java in  » Net » lucene-connector » org » apache » lucene » queryParser » surround » query » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » lucene connector » org.apache.lucene.queryParser.surround.query 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lucene.queryParser.surround.query;
002:
003:        /**
004:         * Licensed to the Apache Software Foundation (ASF) under one or more
005:         * contributor license agreements.  See the NOTICE file distributed with
006:         * this work for additional information regarding copyright ownership.
007:         * The ASF licenses this file to You under the Apache License, Version 2.0
008:         * (the "License"); you may not use this file except in compliance with
009:         * the License.  You may obtain a copy of the License at
010:         *
011:         *     http://www.apache.org/licenses/LICENSE-2.0
012:         *
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License.
018:         */
019:
020:        import junit.framework.TestCase;
021:        import junit.framework.TestSuite;
022:        import junit.textui.TestRunner;
023:
024:        public class Test03Distance extends TestCase {
025:            public static void main(String args[]) {
026:                TestRunner.run(new TestSuite(Test03Distance.class));
027:            }
028:
029:            boolean verbose = false;
030:            int maxBasicQueries = 16;
031:
032:            String[] exceptionQueries = { "(aa and bb) w cc",
033:                    "(aa or bb) w (cc and dd)", "(aa opt bb) w cc",
034:                    "(aa not bb) w cc", "(aa or bb) w (bi:cc)",
035:                    "(aa or bb) w bi:cc", "(aa or bi:bb) w cc",
036:                    "(aa or (bi:bb)) w cc", "(aa or (bb and dd)) w cc" };
037:
038:            public void test00Exceptions() throws Exception {
039:                String m = ExceptionQueryTst.getFailQueries(exceptionQueries,
040:                        verbose);
041:                if (m.length() > 0) {
042:                    fail("No ParseException for:\n" + m);
043:                }
044:            }
045:
046:            final String fieldName = "bi";
047:
048:            String[] docs1 = { "word1 word2 word3", "word4 word5",
049:                    "ord1 ord2 ord3", "orda1 orda2 orda3 word2 worda3",
050:                    "a c e a b c" };
051:
052:            SingleFieldTestDb db1 = new SingleFieldTestDb(docs1, fieldName);
053:
054:            String[] docs2 = { "w1 w2 w3 w4 w5", "w1 w3 w2 w3", "" };
055:
056:            SingleFieldTestDb db2 = new SingleFieldTestDb(docs2, fieldName);
057:
058:            public void distanceTest1(String query, int[] expdnrs)
059:                    throws Exception {
060:                BooleanQueryTst bqt = new BooleanQueryTst(query, expdnrs, db1,
061:                        fieldName, this , new BasicQueryFactory(maxBasicQueries));
062:                bqt.setVerbose(verbose);
063:                bqt.doTest();
064:            }
065:
066:            public void distanceTest2(String query, int[] expdnrs)
067:                    throws Exception {
068:                BooleanQueryTst bqt = new BooleanQueryTst(query, expdnrs, db2,
069:                        fieldName, this , new BasicQueryFactory(maxBasicQueries));
070:                bqt.setVerbose(verbose);
071:                bqt.doTest();
072:            }
073:
074:            public void test0W01() throws Exception {
075:                int[] expdnrs = { 0 };
076:                distanceTest1("word1 w word2", expdnrs);
077:            }
078:
079:            public void test0N01() throws Exception {
080:                int[] expdnrs = { 0 };
081:                distanceTest1("word1 n word2", expdnrs);
082:            }
083:
084:            public void test0N01r() throws Exception { /* r reverse */
085:                int[] expdnrs = { 0 };
086:                distanceTest1("word2 n word1", expdnrs);
087:            }
088:
089:            public void test0W02() throws Exception {
090:                int[] expdnrs = {};
091:                distanceTest1("word2 w word1", expdnrs);
092:            }
093:
094:            public void test0W03() throws Exception {
095:                int[] expdnrs = {};
096:                distanceTest1("word2 2W word1", expdnrs);
097:            }
098:
099:            public void test0N03() throws Exception {
100:                int[] expdnrs = { 0 };
101:                distanceTest1("word2 2N word1", expdnrs);
102:            }
103:
104:            public void test0N03r() throws Exception {
105:                int[] expdnrs = { 0 };
106:                distanceTest1("word1 2N word2", expdnrs);
107:            }
108:
109:            public void test0W04() throws Exception {
110:                int[] expdnrs = {};
111:                distanceTest1("word2 3w word1", expdnrs);
112:            }
113:
114:            public void test0N04() throws Exception {
115:                int[] expdnrs = { 0 };
116:                distanceTest1("word2 3n word1", expdnrs);
117:            }
118:
119:            public void test0N04r() throws Exception {
120:                int[] expdnrs = { 0 };
121:                distanceTest1("word1 3n word2", expdnrs);
122:            }
123:
124:            public void test0W05() throws Exception {
125:                int[] expdnrs = {};
126:                distanceTest1("orda1 w orda3", expdnrs);
127:            }
128:
129:            public void test0W06() throws Exception {
130:                int[] expdnrs = { 3 };
131:                distanceTest1("orda1 2w orda3", expdnrs);
132:            }
133:
134:            public void test1Wtrunc01() throws Exception {
135:                int[] expdnrs = { 0 };
136:                distanceTest1("word1* w word2", expdnrs);
137:            }
138:
139:            public void test1Wtrunc02() throws Exception {
140:                int[] expdnrs = { 0 };
141:                distanceTest1("word* w word2", expdnrs);
142:            }
143:
144:            public void test1Wtrunc02r() throws Exception {
145:                int[] expdnrs = { 0, 3 };
146:                distanceTest1("word2 w word*", expdnrs);
147:            }
148:
149:            public void test1Ntrunc02() throws Exception {
150:                int[] expdnrs = { 0, 3 };
151:                distanceTest1("word* n word2", expdnrs);
152:            }
153:
154:            public void test1Ntrunc02r() throws Exception {
155:                int[] expdnrs = { 0, 3 };
156:                distanceTest1("word2 n word*", expdnrs);
157:            }
158:
159:            public void test1Wtrunc03() throws Exception {
160:                int[] expdnrs = { 0 };
161:                distanceTest1("word1* w word2*", expdnrs);
162:            }
163:
164:            public void test1Ntrunc03() throws Exception {
165:                int[] expdnrs = { 0 };
166:                distanceTest1("word1* N word2*", expdnrs);
167:            }
168:
169:            public void test1Wtrunc04() throws Exception {
170:                int[] expdnrs = {};
171:                distanceTest1("kxork* w kxor*", expdnrs);
172:            }
173:
174:            public void test1Ntrunc04() throws Exception {
175:                int[] expdnrs = {};
176:                distanceTest1("kxork* 99n kxor*", expdnrs);
177:            }
178:
179:            public void test1Wtrunc05() throws Exception {
180:                int[] expdnrs = {};
181:                distanceTest1("word2* 2W word1*", expdnrs);
182:            }
183:
184:            public void test1Ntrunc05() throws Exception {
185:                int[] expdnrs = { 0 };
186:                distanceTest1("word2* 2N word1*", expdnrs);
187:            }
188:
189:            public void test1Wtrunc06() throws Exception {
190:                int[] expdnrs = { 3 };
191:                distanceTest1("ord* W word*", expdnrs);
192:            }
193:
194:            public void test1Ntrunc06() throws Exception {
195:                int[] expdnrs = { 3 };
196:                distanceTest1("ord* N word*", expdnrs);
197:            }
198:
199:            public void test1Ntrunc06r() throws Exception {
200:                int[] expdnrs = { 3 };
201:                distanceTest1("word* N ord*", expdnrs);
202:            }
203:
204:            public void test1Wtrunc07() throws Exception {
205:                int[] expdnrs = { 3 };
206:                distanceTest1("(orda2 OR orda3) W word*", expdnrs);
207:            }
208:
209:            public void test1Wtrunc08() throws Exception {
210:                int[] expdnrs = { 3 };
211:                distanceTest1("(orda2 OR orda3) W (word2 OR worda3)", expdnrs);
212:            }
213:
214:            public void test1Wtrunc09() throws Exception {
215:                int[] expdnrs = { 3 };
216:                distanceTest1("(orda2 OR orda3) 2W (word2 OR worda3)", expdnrs);
217:            }
218:
219:            public void test1Ntrunc09() throws Exception {
220:                int[] expdnrs = { 3 };
221:                distanceTest1("(orda2 OR orda3) 2N (word2 OR worda3)", expdnrs);
222:            }
223:
224:            public void test2Wprefix01() throws Exception {
225:                int[] expdnrs = { 0 };
226:                distanceTest2("W (w1, w2, w3)", expdnrs);
227:            }
228:
229:            public void test2Nprefix01a() throws Exception {
230:                int[] expdnrs = { 0, 1 };
231:                distanceTest2("N(w1, w2, w3)", expdnrs);
232:            }
233:
234:            public void test2Nprefix01b() throws Exception {
235:                int[] expdnrs = { 0, 1 };
236:                distanceTest2("N(w3, w1, w2)", expdnrs);
237:            }
238:
239:            public void test2Wprefix02() throws Exception {
240:                int[] expdnrs = { 0, 1 };
241:                distanceTest2("2W(w1,w2,w3)", expdnrs);
242:            }
243:
244:            public void test2Nprefix02a() throws Exception {
245:                int[] expdnrs = { 0, 1 };
246:                distanceTest2("2N(w1,w2,w3)", expdnrs);
247:            }
248:
249:            public void test2Nprefix02b() throws Exception {
250:                int[] expdnrs = { 0, 1 };
251:                distanceTest2("2N(w2,w3,w1)", expdnrs);
252:            }
253:
254:            public void test2Wnested01() throws Exception {
255:                int[] expdnrs = { 0 };
256:                distanceTest2("w1 W w2 W w3", expdnrs);
257:            }
258:
259:            public void test2Nnested01() throws Exception {
260:                int[] expdnrs = { 0 };
261:                distanceTest2("w1 N w2 N w3", expdnrs);
262:            }
263:
264:            public void test2Wnested02() throws Exception {
265:                int[] expdnrs = { 0, 1 };
266:                distanceTest2("w1 2W w2 2W w3", expdnrs);
267:            }
268:
269:            public void test2Nnested02() throws Exception {
270:                int[] expdnrs = { 0, 1 };
271:                distanceTest2("w1 2N w2 2N w3", expdnrs);
272:            }
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.