Source Code Cross Referenced for MarcOntTests.java in  » Search-Engine » semweb4j » org » ontoware » semversion » 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 » Search Engine » semweb4j » org.ontoware.semversion 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.ontoware.semversion;
002:
003:        import static org.junit.Assert.assertEquals;
004:        import static org.junit.Assert.assertNotNull;
005:        import static org.junit.Assert.assertTrue;
006:
007:        import java.io.File;
008:
009:        import org.junit.After;
010:        import org.junit.Before;
011:        import org.junit.Test;
012:        import org.ontoware.rdf2go.model.Model;
013:        import org.ontoware.rdf2go.model.Statement;
014:        import org.ontoware.rdf2go.model.node.URI;
015:        import org.ontoware.rdf2go.model.node.impl.URIImpl;
016:        import org.ontoware.semversion.impl.BlankNodeEnrichmentModel;
017:
018:        /**
019:         * 
020:         * branch - to tylko etykieta dla zbioru wersji, nie ma wlasciwie takiego
021:         * obiektu w systemie jak branch poza zwyklym stringiem jako property dla
022:         * ontologii
023:         * 
024:         * root (model) - branch (model) - branch (model)
025:         */
026:        public class MarcOntTests {
027:
028:            private SemVersion semVersion;
029:
030:            URI s1 = new URIImpl("urn:test:s1");
031:            URI s2 = new URIImpl("urn:test:s2");
032:            URI s3 = new URIImpl("urn:test:s3");
033:            URI s4 = new URIImpl("urn:test:s4");
034:            URI s5 = new URIImpl("urn:test:s5");
035:            URI s6 = new URIImpl("urn:test:s6");
036:            URI p = new URIImpl("urn:test:p");
037:            URI o = new URIImpl("urn:test:o");
038:
039:            /**
040:             * Create versionedmodel "NewThread", create a new model with two triples,
041:             * commit it as root
042:             * 
043:             * @throws Exception
044:             */
045:            @Before
046:            public void setUp() throws Exception {
047:
048:                semVersion = new SemVersion();
049:                semVersion.startup(new File("./target/tmp/MarcOntUseCase"));
050:                semVersion.deleteStore();
051:                semVersion.createUser("User", "secret");
052:                semVersion.createUser("Admin", "secret");
053:
054:                Session session = semVersion.login("Admin", "secret");
055:                VersionedModel vm = session.createVersionedModel("NewThread");
056:
057:                Model model = session.getModel();
058:                model.addStatement(s1, p, o);
059:                model.addStatement(s2, p, o);
060:                assertEquals(2, model.size());
061:                vm.commitRoot(model, "FirstMainVersion");
062:                session.close();
063:            }
064:
065:            @After
066:            public void tearDown() throws Exception {
067:                semVersion.shutdown();
068:            }
069:
070:            @Test
071:            public void testModel() throws LoginException {
072:                Session session = semVersion.login("User", "secret");
073:
074:                Model model = session.getModel();
075:
076:                Statement s = model.createStatement(s1, p, o);
077:                model.addStatement(s);
078:                assertTrue(model.contains(s1, p, o));
079:                model.removeStatement(s);
080:
081:                model.addStatement(s1, p, o);
082:                assertTrue(model.contains(s1, p, o));
083:
084:                model.addStatement(s2, p, o);
085:                assertTrue(model.contains(s2, p, o));
086:
087:                assertEquals(2, model.size());
088:                session.close();
089:            }
090:
091:            @Test
092:            public void testSV15noLabel() throws Exception {
093:                Session session = semVersion.login("User", "secret");
094:                VersionedModel vm = session.getVersionedModel("NewThread");
095:
096:                Version v = vm.getRoot();
097:                Model s1 = v.getContent();
098:                s1.addStatement(s3, p, o);
099:
100:                String label = "LABEL";
101:                String comment = "COMMENT";
102:
103:                // Note: This sets the commit 'comment' to the string "LABEL"
104:                Version childVersion = v.commit(s1, label, false);
105:
106:                // This does the same.
107:                childVersion.setComment(comment);
108:
109:                // Setting the label
110:                childVersion.setLabel(label);
111:
112:                URI uri = childVersion.getURI();
113:
114:                session.close();
115:
116:                session = semVersion.login("User", "secret");
117:                vm = session.getVersionedModel("NewThread");
118:
119:                v = vm.getVersion(uri);
120:
121:                assertTrue(v.getComment().compareTo(comment) == 0);
122:                assertNotNull(v.getLabel());
123:                assertTrue(v.getLabel().compareTo(label) == 0);
124:            }
125:
126:            /**
127:             * This one works fine
128:             */
129:            @Test
130:            public void addingFewSuggestions() throws LoginException {
131:
132:                Session session = semVersion.login("User", "secret");
133:                VersionedModel vm = session.getVersionedModel("NewThread");
134:
135:                Version v = vm.getRoot();
136:                Model suggestion1 = v.getContent();
137:                assertEquals(2, suggestion1.size());
138:                assertTrue(suggestion1.contains(s1, p, o));
139:                assertTrue(suggestion1.contains(s2, p, o));
140:                suggestion1.addStatement(s3, p, o);
141:                assertTrue(suggestion1.contains(s3, p, o));
142:
143:                // commit s1 as a suggestion to root
144:                // result: root > suggestion1
145:                v.commit(suggestion1, "first sug. comment", true);
146:
147:                Model suggestion2 = v.getContent();
148:                assertEquals(2, suggestion2.size());
149:                suggestion2.addStatement(s4, p, o);
150:                v.commit(suggestion2, "second sug. comment", true);
151:                // result: root has two children > suggestion1, suggestion2
152:
153:                Model suggestion3 = v.getContent();
154:                suggestion3.addStatement(s5, p, o);
155:                v.commit(suggestion3, "third sug. comment", true);
156:                // result: root has three children > suggestion1, suggestion2,
157:                // suggestion3
158:
159:                Model suggestion4 = v.getContent();
160:                suggestion4.addStatement(s6, p, o);
161:                v.commit(suggestion4, "fourth sug. comment", true);
162:                // result: root has four children > suggestion1, suggestion2,
163:                // suggestion3, suggestion4
164:
165:                System.out.println(vm.getAllBranches().size());
166:                System.out.println(vm.getAllVersions().size());
167:
168:                assertTrue(vm.getAllBranches().size() == 1);
169:                assertTrue(vm.getAllVersions().size() == 5);
170:
171:                // semVersion.dump();
172:
173:                session.close();
174:            }
175:
176:            /**
177:             * Here I add to a root model: 1) One suggestion 2) One sub-version 3)
178:             * Second suggestion - and I get exception - why?
179:             * 
180:             * I assume that one version can have n suggestions but only 1 sub-version
181:             * and after adding this sub-version I can't add anything more to the parent
182:             * node - suggestion, nor sub-version. Am I right?
183:             * 
184:             * @throws LoginException
185:             */
186:            @Test
187:            public void addingFewVersions() throws LoginException {
188:
189:                Session session = semVersion.login("User", "secret");
190:                VersionedModel vm = session.getVersionedModel("NewThread");
191:
192:                Version v = vm.getRoot();
193:                assertNotNull(v);
194:
195:                Model suggestion1 = v.getContent();
196:                suggestion1.addStatement(s3, p, o);
197:                v.commit(suggestion1, "first sug. comment", true);
198:                // result: root > suggestion1
199:
200:                Model childVersion1 = v.getContent();
201:                childVersion1.addStatement(s4, p, o);
202:                v.commit(childVersion1, "first subver. comment", false);
203:                // result: root > suggestion1, childVersion1
204:
205:                Model suggestion2 = v.getContent();
206:                suggestion2.addStatement(s5, p, o);
207:                v.commit(suggestion2, "second sug. comment", true);
208:                // result: root > suggestion1, childVersion1, suggestion2
209:
210:                session.close();
211:            }
212:
213:            /**
214:             * This one works fine
215:             */
216:            @Test
217:            public void addingVersions2LvlDepth() throws LoginException {
218:
219:                Session session = semVersion.login("User", "secret");
220:                VersionedModel vm = session.getVersionedModel("NewThread");
221:
222:                Version v = vm.getRoot();
223:
224:                Model s1 = v.getContent();
225:                s1.addStatement("http://third", new URIImpl("http://test/uri"),
226:                        "http://triple");
227:                Version child = v.commit(s1, "first ver. comment", false);
228:                URI uri = child.getURI();
229:
230:                Version ver = vm.getVersion(uri);
231:
232:                Model s2 = ver.getContent();
233:                s2.addStatement("http://fourth",
234:                        new URIImpl("http://test/uri"), "http://triple");
235:                ver.commit(s2, "second ver. comment", true);
236:
237:                Model s3 = ver.getContent();
238:                s3.addStatement("http://fifth", new URIImpl("http://test/uri"),
239:                        "http://triple");
240:                ver.commit(s3, "second ver. comment", false);
241:
242:                // semVersion.dump();
243:
244:                session.close();
245:            }
246:
247:            /**
248:             * Here I try to add a sub-version to root version, successfully. Then I try
249:             * to add a sub-version to added sub-version, successfully. But when I try
250:             * to add another sub-version to the latest added node, I get an exception.
251:             * Why?
252:             * 
253:             * @throws LoginException
254:             */
255:            @Test
256:            public void addingVersions3LvlDepth() throws LoginException {
257:
258:                Session session = semVersion.login("User", "secret");
259:                VersionedModel vm = session.getVersionedModel("NewThread");
260:
261:                Version rootVersion = vm.getRoot();
262:
263:                Model childVersion1 = rootVersion.getContent();
264:                assertTrue(childVersion1 instanceof  BlankNodeEnrichmentModel);
265:                childVersion1.addStatement(s3, p, o);
266:                Version child = rootVersion.commit(childVersion1,
267:                        "first ver. comment", false);
268:                URI uri = child.getURI();
269:
270:                Version ver = vm.getVersion(uri);
271:
272:                Model childVersion2 = ver.getContent();
273:                assertTrue(childVersion2 instanceof  BlankNodeEnrichmentModel);
274:                childVersion2.addStatement(s4, p, o);
275:                Version ver2 = ver.commit(childVersion2, "second ver. comment",
276:                        false);
277:
278:                Model childVersion3 = ver2.getContent();
279:                assertTrue(childVersion3 instanceof  BlankNodeEnrichmentModel);
280:                childVersion3.addStatement(s5, p, o);
281:                ver2.commit(childVersion3, "second ver. comment", false);
282:
283:                // semVersion.dump();
284:
285:                session.close();
286:            }
287:
288:            /**
289:             * Here I add to a root model: 1) One suggestion 2) One sub-version 3)
290:             * Suggestion to sub-version added in point 2 and I get exception - why? I
291:             * assume it should work. Do I understand right?
292:             * 
293:             * @throws LoginException
294:             */
295:            @Test
296:            public void addingSuggestionVersionSuggestion()
297:                    throws LoginException {
298:
299:                Session session = semVersion.login("User", "secret");
300:                VersionedModel vm = session.getVersionedModel("NewThread");
301:
302:                Version v = vm.getRoot();
303:
304:                Model s1 = v.getContent();
305:                s1.addStatement("http://third", new URIImpl("http://test/uri"),
306:                        "http://triple");
307:                v.commit(s1, "first sug. comment", true);
308:
309:                Model s2 = v.getContent();
310:                s2.addStatement("http://fourth",
311:                        new URIImpl("http://test/uri"), "http://triple");
312:                v.commit(s2, "first subver. comment", true);
313:
314:                Model s3 = v.getContent();
315:                s3.addStatement("http://fifth", new URIImpl("http://test/uri"),
316:                        "http://triple");
317:                Version ver = v.commit(s3, "second sug. comment", false);
318:
319:                Model s4 = ver.getContent();
320:                s4.addStatement("http://sixth", new URIImpl("http://test/uri"),
321:                        "http://triple");
322:                ver.commit(s4, "comment", true);
323:
324:                // semVersion.dump();
325:
326:                session.close();
327:            }
328:
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.