Source Code Cross Referenced for QueryOptimizerTest.java in  » Database-ORM » smyle » drjava » smyle » tests » 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 » Database ORM » smyle » drjava.smyle.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        This source file is part of Smyle, a database library.
003:        For up-to-date information, see http://www.drjava.de/smyle
004:        Copyright (C) 2001 Stefan Reich (doc@drjava.de)
005:
006:        This library is free software; you can redistribute it and/or
007:        modify it under the terms of the GNU Lesser General Public
008:        License as published by the Free Software Foundation; either
009:        version 2.1 of the License, or (at your option) any later version.
010:
011:        This library is distributed in the hope that it will be useful,
012:        but WITHOUT ANY WARRANTY; without even the implied warranty of
013:        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:        Lesser General Public License for more details.
015:
016:        You should have received a copy of the GNU Lesser General Public
017:        License along with this library; if not, write to the Free Software
018:        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:
020:        For full license text, see doc/license/lgpl.txt in this distribution
021:         */
022:
023:        package drjava.smyle.tests;
024:
025:        import junit.framework.*;
026:        import drjava.smyle.core.indexing.*;
027:        import drjava.smyle.meta.*;
028:        import drjava.smyle.testtypes.*;
029:
030:        public class QueryOptimizerTest extends TestCase {
031:            public QueryOptimizerTest(String name) {
032:                super (name);
033:            }
034:
035:            static final Function[] nil = new Function[0];
036:            static final IndexProfile profile_nil_nil = new IndexProfile(nil,
037:                    nil), profile_l_nil = new IndexProfile(
038:                    new Function[] { DataTypes.f_l }, nil),
039:                    profile_nil_l = new IndexProfile(nil,
040:                            new Function[] { DataTypes.f_l }),
041:                    profile_l_ll = new IndexProfile(
042:                            new Function[] { DataTypes.f_l },
043:                            new Function[] { DataTypes.f_ll }),
044:                    profile_b$s_l$ll = new IndexProfile(new Function[] {
045:                            DataTypes.f_b, DataTypes.f_s }, new Function[] {
046:                            DataTypes.f_l, DataTypes.f_ll }),
047:                    profile_l$ll_nil = new IndexProfile(new Function[] {
048:                            DataTypes.f_l, DataTypes.f_ll }, nil);
049:
050:            static final IndexProfile[] someProfiles = { profile_nil_nil,
051:                    profile_l_nil, profile_nil_l, profile_b$s_l$ll };
052:
053:            static final Function[][] someFieldLists = { nil,
054:                    { DataTypes.f_l }, { DataTypes.f_l, DataTypes.f_s } };
055:
056:            public void testCreateProfile() {
057:                assertEquals(new IndexProfile(nil, nil), QueryOptimizer
058:                        .createProfile(new Filter()));
059:                assertEquals(profile_l_nil, QueryOptimizer
060:                        .createProfile(new DataTypes_filter().lEquals(0)));
061:                assertEquals(profile_nil_l, QueryOptimizer
062:                        .createProfile(new DataTypes_filter().orderByL()));
063:                assertEquals(profile_b$s_l$ll, QueryOptimizer
064:                        .createProfile(new DataTypes_filter().bEquals(true)
065:                                .sEquals("test").orderByL().orderByLl()));
066:            }
067:
068:            public void testIndexProfileEquality() {
069:                assertEquals(profile_nil_nil, profile_nil_nil);
070:                assertTrue(!profile_nil_nil.equals(new IndexProfile(
071:                        new Function[] { new Field(0) }, nil)));
072:                assertTrue(!profile_nil_nil.equals(new IndexProfile(nil,
073:                        new Function[] { new Field(0) })));
074:            }
075:
076:            public void testIndexProfileHashCode() {
077:                assertEquals(profile_nil_nil.hashCode(), new IndexProfile(nil,
078:                        nil).hashCode());
079:                assertEquals(profile_nil_l.hashCode(), new IndexProfile(nil,
080:                        new Function[] { DataTypes.f_l }).hashCode());
081:            }
082:
083:            public void testIndexProfileToString() {
084:                assertEquals("perm=[] ord=[]", profile_nil_nil.toString());
085:                assertEquals(
086:                        "perm=[Field #4 Field #1] ord=[Field #3 Field #2]",
087:                        new IndexProfile(new Function[] { DataTypes.f_strct,
088:                                DataTypes.f_l }, new Function[] {
089:                                DataTypes.f_s, DataTypes.f_ll }).toString());
090:            }
091:
092:            public void testIndexScore() {
093:                // nil profile always gives score 0
094:                for (int i = 0; i < someFieldLists.length; i++)
095:                    assertEquals(0, QueryOptimizer.indexScore(profile_nil_nil,
096:                            someFieldLists[i]));
097:
098:                // empty field list always gives score 0
099:                for (int i = 0; i < someProfiles.length; i++)
100:                    assertEquals(0, QueryOptimizer.indexScore(someProfiles[i],
101:                            nil));
102:
103:                assertEquals(1, QueryOptimizer.indexScore(profile_l_nil,
104:                        new Function[] { DataTypes.f_l }));
105:                assertEquals(1, QueryOptimizer.indexScore(profile_l_nil,
106:                        new Function[] { DataTypes.f_l, DataTypes.f_ll }));
107:
108:                // index can't be used because first field isn't in profile
109:                assertEquals(0, QueryOptimizer.indexScore(profile_l_nil,
110:                        new Function[] { DataTypes.f_ll, DataTypes.f_l }));
111:
112:                assertEquals(2, QueryOptimizer.indexScore(profile_l_ll,
113:                        new Function[] { DataTypes.f_l, DataTypes.f_ll }));
114:
115:                assertEquals(2, QueryOptimizer.indexScore(profile_l$ll_nil,
116:                        new Function[] { DataTypes.f_l, DataTypes.f_ll,
117:                                DataTypes.f_strct }));
118:                assertEquals(2, QueryOptimizer.indexScore(profile_l$ll_nil,
119:                        new Function[] { DataTypes.f_ll, DataTypes.f_l,
120:                                DataTypes.f_strct }));
121:
122:                // wrong order in ord part => only 2 points
123:                assertEquals(2, QueryOptimizer.indexScore(profile_b$s_l$ll,
124:                        new Function[] { DataTypes.f_b, DataTypes.f_s,
125:                                DataTypes.f_ll }));
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.