Source Code Cross Referenced for ValueComparatorTest.java in  » RSS-RDF » sesame » org » openrdf » query » algebra » evaluation » util » 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 » RSS RDF » sesame » org.openrdf.query.algebra.evaluation.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003:         *
004:         * Licensed under the Aduna BSD-style license.
005:         */
006:        package org.openrdf.query.algebra.evaluation.util;
007:
008:        import java.util.Arrays;
009:        import java.util.Collections;
010:        import java.util.List;
011:
012:        import junit.framework.TestCase;
013:
014:        import org.openrdf.model.BNode;
015:        import org.openrdf.model.Literal;
016:        import org.openrdf.model.URI;
017:        import org.openrdf.model.ValueFactory;
018:        import org.openrdf.model.impl.ValueFactoryImpl;
019:        import org.openrdf.model.vocabulary.XMLSchema;
020:
021:        /**
022:         * 
023:         * @author james
024:         * 
025:         */
026:        public class ValueComparatorTest extends TestCase {
027:
028:            private ValueFactory vf = ValueFactoryImpl.getInstance();
029:
030:            private BNode bnode1 = vf.createBNode();
031:
032:            private BNode bnode2 = vf.createBNode();
033:
034:            private URI uri1 = vf.createURI("http://script.example/Latin");
035:
036:            private URI uri2 = vf
037:                    .createURI("http://script.example/Кириллица");
038:
039:            private URI uri3 = vf.createURI("http://script.example/日本語");
040:
041:            private Literal typed1 = vf.createLiteral(
042:                    "http://script.example/Latin", XMLSchema.STRING);
043:
044:            private ValueComparator cmp = new ValueComparator();
045:
046:            public void testBothNull() throws Exception {
047:                assertTrue(cmp.compare(null, null) == 0);
048:            }
049:
050:            public void testLeftNull() throws Exception {
051:                assertTrue(cmp.compare(null, typed1) < 0);
052:            }
053:
054:            public void testRightNull() throws Exception {
055:                assertTrue(cmp.compare(typed1, null) > 0);
056:            }
057:
058:            public void testBothBnode() throws Exception {
059:                assertTrue(cmp.compare(bnode1, bnode2) == 0);
060:            }
061:
062:            public void testLeftBnode() throws Exception {
063:                assertTrue(cmp.compare(bnode1, typed1) < 0);
064:            }
065:
066:            public void testRightBnode() throws Exception {
067:                assertTrue(cmp.compare(typed1, bnode1) > 0);
068:            }
069:
070:            public void testBothURI() throws Exception {
071:                assertTrue(cmp.compare(uri1, uri1) == 0);
072:                assertTrue(cmp.compare(uri1, uri2) < 0);
073:                assertTrue(cmp.compare(uri1, uri3) < 0);
074:                assertTrue(cmp.compare(uri2, uri1) > 0);
075:                assertTrue(cmp.compare(uri2, uri2) == 0);
076:                assertTrue(cmp.compare(uri2, uri3) < 0);
077:                assertTrue(cmp.compare(uri3, uri1) > 0);
078:                assertTrue(cmp.compare(uri3, uri2) > 0);
079:                assertTrue(cmp.compare(uri3, uri3) == 0);
080:            }
081:
082:            public void testLeftURI() throws Exception {
083:                assertTrue(cmp.compare(uri1, typed1) < 0);
084:            }
085:
086:            public void testRightURI() throws Exception {
087:                assertTrue(cmp.compare(typed1, uri1) > 0);
088:            }
089:
090:            /**
091:             * Tests whether xsd:int's are properly sorted in a list with mixed value
092:             * types.
093:             */
094:            public void testOrder1() throws Exception {
095:                Literal en4 = vf.createLiteral("4", "en");
096:                Literal int10 = vf.createLiteral(10);
097:                Literal int9 = vf.createLiteral(9);
098:
099:                List<Literal> valueList = Arrays.asList(en4, int10, int9);
100:                Collections.sort(valueList, cmp);
101:
102:                assertTrue(valueList.indexOf(int9) < valueList.indexOf(int10));
103:            }
104:
105:            /**
106:             * Tests whether various numerics are properly sorted in a list with mixed
107:             * value types.
108:             */
109:            public void testOrder2() throws Exception {
110:                Literal en4 = vf.createLiteral("4", "en");
111:                Literal int10 = vf.createLiteral(10);
112:                Literal int9 = vf.createLiteral(9);
113:                Literal plain9 = vf.createLiteral("9");
114:                Literal integer5 = vf.createLiteral("5", XMLSchema.INTEGER);
115:                Literal float9 = vf.createLiteral(9f);
116:                Literal plain4 = vf.createLiteral("4");
117:                Literal plain10 = vf.createLiteral("10");
118:
119:                List<Literal> valueList = Arrays.asList(en4, int10, int9,
120:                        plain9, integer5, float9, plain4, plain10);
121:                Collections.sort(valueList, cmp);
122:
123:                assertTrue(valueList.indexOf(integer5) < valueList
124:                        .indexOf(float9));
125:                assertTrue(valueList.indexOf(integer5) < valueList
126:                        .indexOf(int9));
127:                assertTrue(valueList.indexOf(integer5) < valueList
128:                        .indexOf(int10));
129:                assertTrue(valueList.indexOf(float9) < valueList.indexOf(int10));
130:                assertTrue(valueList.indexOf(int9) < valueList.indexOf(int10));
131:                assertTrue(valueList.indexOf(int9) < valueList.indexOf(int10));
132:            }
133:
134:            /**
135:             * Tests whether numerics of different types are properly sorted. The list
136:             * also contains a datatype that would be sorted between the numerics if the
137:             * datatypes were to be sorted alphabetically.
138:             */
139:            public void testOrder3() throws Exception {
140:                Literal year1234 = vf.createLiteral("1234", XMLSchema.GYEAR);
141:                Literal float2000 = vf.createLiteral(2000f);
142:                Literal int1000 = vf.createLiteral(1000);
143:
144:                List<Literal> valueList = Arrays.asList(year1234, float2000,
145:                        int1000);
146:                Collections.sort(valueList, cmp);
147:                assertTrue(valueList.indexOf(int1000) < valueList
148:                        .indexOf(float2000));
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.