Source Code Cross Referenced for NewRegressionStatementMethods.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » regression » 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 » Jena 2.5.5 » com.hp.hpl.jena.regression 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         	(c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         	All rights reserved - see end of file.
004:         	$Id: NewRegressionStatementMethods.java,v 1.10 2008/01/02 12:07:03 andy_seaborne Exp $
005:         */
006:
007:        package com.hp.hpl.jena.regression;
008:
009:        import com.hp.hpl.jena.rdf.model.*;
010:        import com.hp.hpl.jena.vocabulary.RDF;
011:        import com.hp.hpl.jena.regression.Regression.*;
012:
013:        import junit.framework.*;
014:
015:        public class NewRegressionStatementMethods extends NewRegressionBase {
016:            public NewRegressionStatementMethods(String name) {
017:                super (name);
018:            }
019:
020:            public static Test suite() {
021:                return new TestSuite(NewRegressionStatementMethods.class);
022:            }
023:
024:            protected Model getModel() {
025:                return ModelFactory.createDefaultModel();
026:            }
027:
028:            protected Model m;
029:            protected Resource r;
030:
031:            public void setUp() {
032:                m = getModel();
033:                r = m.createResource();
034:            }
035:
036:            public void testGetResource() {
037:                assertEquals(r, m.createStatement(r, RDF.value, r)
038:                        .getResource());
039:            }
040:
041:            public void testGetResourceFailure() {
042:                try {
043:                    m.createLiteralStatement(r, RDF.value, false).getResource();
044:                    fail("should trap non-resource object");
045:                } catch (ResourceRequiredException e) {
046:                    pass();
047:                }
048:            }
049:
050:            public void testGetTrueBoolean() {
051:                assertEquals(true, m.createLiteralStatement(r, RDF.value, true)
052:                        .getLiteral().getBoolean());
053:            }
054:
055:            public void testGetLiteralFailure() {
056:                try {
057:                    m.createStatement(r, RDF.value, r).getLiteral();
058:                    fail("should trap non-literal object");
059:                } catch (LiteralRequiredException e) {
060:                    pass();
061:                }
062:            }
063:
064:            public void testBoolean() {
065:                Statement s = m.createLiteralStatement(r, RDF.value, true);
066:                assertEquals(m.createTypedLiteral(true), s.getObject());
067:                assertEquals(true, s.getBoolean());
068:            }
069:
070:            public void testByte() {
071:                Statement s = m.createLiteralStatement(r, RDF.value, tvByte);
072:                assertEquals(m.createTypedLiteral(tvByte), s.getObject());
073:                assertEquals(tvByte, s.getLong());
074:            }
075:
076:            public void testShort() {
077:                Statement s = m.createLiteralStatement(r, RDF.value, tvShort);
078:                assertEquals(m.createTypedLiteral(tvShort), s.getObject());
079:                assertEquals(tvShort, s.getShort());
080:            }
081:
082:            public void testInt() {
083:                Statement s = m.createLiteralStatement(r, RDF.value, tvInt);
084:                assertEquals(m.createTypedLiteral(tvInt), s.getObject());
085:                assertEquals(tvInt, s.getInt());
086:            }
087:
088:            public void testLong() {
089:                Statement s = m.createLiteralStatement(r, RDF.value, tvLong);
090:                assertEquals(m.createTypedLiteral(tvLong), s.getObject());
091:                assertEquals(tvLong, s.getLong());
092:            }
093:
094:            public void testChar() {
095:                Statement s = m.createLiteralStatement(r, RDF.value, tvChar);
096:                assertEquals(m.createTypedLiteral(tvChar), s.getObject());
097:                assertEquals(tvChar, s.getChar());
098:            }
099:
100:            public void testFloat() {
101:                Statement s = m.createLiteralStatement(r, RDF.value, tvFloat);
102:                assertEquals(m.createTypedLiteral(tvFloat), s.getObject());
103:                assertEquals(tvFloat, s.getFloat(), fDelta);
104:            }
105:
106:            public void testDouble() {
107:                Statement s = m.createLiteralStatement(r, RDF.value, tvDouble);
108:                assertEquals(m.createTypedLiteral(tvDouble), s.getObject());
109:                assertEquals(tvDouble, s.getDouble(), dDelta);
110:            }
111:
112:            public void testString() {
113:                assertEquals(tvString, m
114:                        .createStatement(r, RDF.value, tvString).getString());
115:            }
116:
117:            public void testStringWithLanguage() {
118:                String lang = "fr";
119:                assertEquals(tvString, m.createStatement(r, RDF.value,
120:                        tvString, lang).getString());
121:                assertEquals(lang, m.createStatement(r, RDF.value, tvString,
122:                        lang).getLanguage());
123:            }
124:
125:            public void testResObj() {
126:                Resource tvResObj = m.createResource(new ResTestObjF());
127:                assertEquals(tvResObj, m
128:                        .createStatement(r, RDF.value, tvResObj).getResource());
129:            }
130:
131:            public void testLitObj() {
132:                assertEquals(tvLitObj, m.createLiteralStatement(r, RDF.value,
133:                        tvLitObj).getObject(new LitTestObjF()));
134:            }
135:
136:            public void testBag() {
137:                Bag tvBag = m.createBag();
138:                assertEquals(tvBag, m.createStatement(r, RDF.value, tvBag)
139:                        .getBag());
140:            }
141:
142:            public void testSeq() {
143:                Seq tvSeq = m.createSeq();
144:                assertEquals(tvSeq, m.createStatement(r, RDF.value, tvSeq)
145:                        .getSeq());
146:            }
147:
148:            public void testAlt() {
149:                Alt tvAlt = m.createAlt();
150:                assertEquals(tvAlt, m.createStatement(r, RDF.value, tvAlt)
151:                        .getAlt());
152:            }
153:
154:            public void testChangeObjectBoolean() {
155:                Statement sTrue = loadInitialStatement();
156:                Statement sFalse = sTrue.changeLiteralObject(false);
157:                checkChangedStatementSP(sFalse);
158:                assertEquals(m.createTypedLiteral(false), sFalse.getObject());
159:                assertEquals(false, sFalse.getBoolean());
160:                checkCorrectStatements(sTrue, sFalse);
161:                assertTrue(m.containsLiteral(r, RDF.value, false));
162:            }
163:
164:            public void testChangeObjectByte() {
165:                Statement sTrue = loadInitialStatement();
166:                Statement changed = sTrue.changeLiteralObject(tvByte);
167:                checkChangedStatementSP(changed);
168:                assertEquals(m.createTypedLiteral(tvByte), changed.getObject());
169:                assertEquals(tvByte, changed.getByte());
170:                checkCorrectStatements(sTrue, changed);
171:                assertTrue(m.containsLiteral(r, RDF.value, tvByte));
172:            }
173:
174:            public void testChangeObjectShort() {
175:                Statement sTrue = loadInitialStatement();
176:                Statement changed = sTrue.changeLiteralObject(tvShort);
177:                checkChangedStatementSP(changed);
178:                assertEquals(m.createTypedLiteral(tvShort), changed.getObject());
179:                assertEquals(tvShort, changed.getShort());
180:                checkCorrectStatements(sTrue, changed);
181:                assertTrue(m.containsLiteral(r, RDF.value, tvShort));
182:            }
183:
184:            public void testChangeObjectInt() {
185:                Statement sTrue = loadInitialStatement();
186:                Statement changed = sTrue.changeLiteralObject(tvInt);
187:                checkChangedStatementSP(changed);
188:                assertEquals(m.createTypedLiteral(tvInt), changed.getObject());
189:                assertEquals(tvInt, changed.getInt());
190:                checkCorrectStatements(sTrue, changed);
191:                assertTrue(m.containsLiteral(r, RDF.value, tvInt));
192:            }
193:
194:            public void testChangeObjectLong() {
195:                Statement sTrue = loadInitialStatement();
196:                Statement changed = sTrue.changeLiteralObject(tvLong);
197:                checkChangedStatementSP(changed);
198:                assertEquals(m.createTypedLiteral(tvLong), changed.getObject());
199:                assertEquals(tvLong, changed.getLong());
200:                checkCorrectStatements(sTrue, changed);
201:                assertTrue(m.containsLiteral(r, RDF.value, tvLong));
202:            }
203:
204:            public void testChangeObjectChar() {
205:                Statement sTrue = loadInitialStatement();
206:                Statement changed = sTrue.changeLiteralObject(tvChar);
207:                checkChangedStatementSP(changed);
208:                assertEquals(tvChar, changed.getChar());
209:                assertEquals(m.createTypedLiteral(tvChar), changed.getObject());
210:                checkCorrectStatements(sTrue, changed);
211:                assertTrue(m.containsLiteral(r, RDF.value, tvChar));
212:            }
213:
214:            public void testChangeObjectFloat() {
215:                Statement sTrue = loadInitialStatement();
216:                Statement changed = sTrue.changeLiteralObject(tvFloat);
217:                checkChangedStatementSP(changed);
218:                assertEquals(m.createTypedLiteral(tvFloat), changed.getObject());
219:                assertEquals(tvFloat, changed.getFloat(), fDelta);
220:                checkCorrectStatements(sTrue, changed);
221:                assertTrue(m.containsLiteral(r, RDF.value, tvFloat));
222:            }
223:
224:            public void testChangeObjectDouble() {
225:                Statement sTrue = loadInitialStatement();
226:                Statement changed = sTrue.changeLiteralObject(tvDouble);
227:                checkChangedStatementSP(changed);
228:                assertEquals(m.createTypedLiteral(tvDouble), changed
229:                        .getObject());
230:                assertEquals(tvDouble, changed.getDouble(), dDelta);
231:                checkCorrectStatements(sTrue, changed);
232:                assertTrue(m.containsLiteral(r, RDF.value, tvDouble));
233:            }
234:
235:            public void testChangeObjectString() {
236:                Statement sTrue = loadInitialStatement();
237:                Statement changed = sTrue.changeObject(tvString);
238:                checkChangedStatementSP(changed);
239:                assertEquals(tvString, changed.getString());
240:                checkCorrectStatements(sTrue, changed);
241:                assertTrue(m.contains(r, RDF.value, tvString));
242:            }
243:
244:            public void testChangeObjectStringWithLanguage() {
245:                String lang = "en";
246:                Statement sTrue = loadInitialStatement();
247:                Statement changed = sTrue.changeObject(tvString, lang);
248:                checkChangedStatementSP(changed);
249:                assertEquals(tvString, changed.getString());
250:                assertEquals(lang, changed.getLanguage());
251:                checkCorrectStatements(sTrue, changed);
252:                assertTrue(m.contains(r, RDF.value, tvString, lang));
253:            }
254:
255:            public void testChangeObjectResObject() {
256:                Resource tvResObj = m.createResource(new ResTestObjF());
257:                Statement sTrue = loadInitialStatement();
258:                Statement changed = sTrue.changeObject(tvResObj);
259:                checkChangedStatementSP(changed);
260:                assertEquals(tvResObj, changed.getResource());
261:                checkCorrectStatements(sTrue, changed);
262:                assertTrue(m.contains(r, RDF.value, tvResObj));
263:            }
264:
265:            public void testChangeObjectLiteral() {
266:                Statement sTrue = loadInitialStatement();
267:                m.remove(sTrue);
268:                assertFalse(m.contains(sTrue));
269:                assertFalse(m.containsLiteral(r, RDF.value, true));
270:            }
271:
272:            public void testChangeObjectYByte() {
273:                Statement sTrue = loadInitialStatement();
274:                Statement changed = sTrue.changeLiteralObject(tvByte);
275:                checkChangedStatementSP(changed);
276:                assertEquals(tvByte, changed.getByte());
277:                checkCorrectStatements(sTrue, changed);
278:                assertTrue(m.containsLiteral(r, RDF.value, tvByte));
279:            }
280:
281:            protected void checkCorrectStatements(Statement sTrue,
282:                    Statement changed) {
283:                assertFalse(m.contains(sTrue));
284:                assertFalse(m.containsLiteral(r, RDF.value, true));
285:                assertTrue(m.contains(changed));
286:            }
287:
288:            protected void checkChangedStatementSP(Statement changed) {
289:                assertEquals(r, changed.getSubject());
290:                assertEquals(RDF.value, changed.getPredicate());
291:            }
292:
293:            protected Statement loadInitialStatement() {
294:                Statement sTrue = m.createLiteralStatement(r, RDF.value, true);
295:                m.add(sTrue);
296:                return sTrue;
297:            }
298:        }
299:
300:        /*
301:         * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
302:         * All rights reserved.
303:         *
304:         * Redistribution and use in source and binary forms, with or without
305:         * modification, are permitted provided that the following conditions
306:         * are met:
307:         * 1. Redistributions of source code must retain the above copyright
308:         *    notice, this list of conditions and the following disclaimer.
309:         * 2. Redistributions in binary form must reproduce the above copyright
310:         *    notice, this list of conditions and the following disclaimer in the
311:         *    documentation and/or other materials provided with the distribution.
312:         * 3. The name of the author may not be used to endorse or promote products
313:         *    derived from this software without specific prior written permission.
314:         *
315:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
316:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
317:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
318:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
319:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
320:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
321:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
322:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
323:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
324:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
325:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.