[isidorus-cvs] r465 - in trunk/src: . base-tools json/JTM unit_tests
Lukas Giessmann
lgiessmann at common-lisp.net
Tue May 10 09:38:25 UTC 2011
Author: lgiessmann
Date: Tue May 10 05:38:24 2011
New Revision: 465
Log:
JTM: added unit-tests for importing jtm-strings containing entire topic maps
Added:
trunk/src/unit_tests/jtm_1.0_test.jtm
trunk/src/unit_tests/jtm_1.1_test.jtm
Modified:
trunk/src/base-tools/base-tools.lisp
trunk/src/isidorus.asd
trunk/src/json/JTM/jtm_importer.lisp
trunk/src/unit_tests/jtm_test.lisp
Modified: trunk/src/base-tools/base-tools.lisp
==============================================================================
--- trunk/src/base-tools/base-tools.lisp (original)
+++ trunk/src/base-tools/base-tools.lisp Tue May 10 05:38:24 2011
@@ -47,7 +47,7 @@
:get-store-spec
:open-tm-store
:close-tm-store
- :read-file))
+ :read-file-to-string))
(in-package :base-tools)
@@ -587,7 +587,7 @@
(elephant:close-store))
-(defun read-file (file-path)
+(defun read-file-to-string (file-path)
"A helper function that reads a file and returns the content as a string."
(with-open-file (stream file-path)
(let ((file-string ""))
Modified: trunk/src/isidorus.asd
==============================================================================
--- trunk/src/isidorus.asd (original)
+++ trunk/src/isidorus.asd Tue May 10 05:38:24 2011
@@ -117,6 +117,8 @@
"json" "threading" "base-tools"))
(:module "unit_tests"
:components ((:static-file "textgrid.xtm")
+ (:static-file "jtm_1.0_test.jtm")
+ (:static-file "jtm_1.1_test.jtm")
(:static-file "textgrid_old.xtm")
(:static-file "dangling_topicref.xtm")
(:static-file "inconsistent.xtm")
Modified: trunk/src/json/JTM/jtm_importer.lisp
==============================================================================
--- trunk/src/json/JTM/jtm_importer.lisp (original)
+++ trunk/src/json/JTM/jtm_importer.lisp Tue May 10 05:38:24 2011
@@ -35,8 +35,9 @@
is a topicmap and it has no item-identifiers defined, a JTM-error
is thrown."
(declare (String jtm-string)
- (type (or Null String) tm-id))
-
+ (type (or Null String) tm-id)
+ (Integer revision)
+ (Keyword jtm-format))
(let* ((jtm-list (json:decode-json-from-string jtm-string))
(version (get-item :VERSION jtm-list))
(item_type (get-item :ITEM--TYPE jtm-list))
@@ -51,7 +52,7 @@
(unless (string= version "1.1")
(error (make-condition 'exceptions:JTM-error :message (format nil "From import-construct-from-jtm-string(): the member version must be set to \"1.1\" in JTM version 1.1, but is ~a" version)))))
(t
- (error (make-condition 'exceptions:JTM-error :message (format nil "From import-construct-from-jtm-string(): only JTM format 1.0 and 1.1 is supported, but found: ~a" jtm-format)))))
+ (error (make-condition 'exceptions:JTM-error :message (format nil "From import-construct-from-jtm-string(): only JTM format \"1.0\" and \"1.1\" is supported, but found: \"~a\"" jtm-format)))))
(cond ((or (not item_type)
(string= item_type item_type-topicmap))
(import-topic-map-from-jtm-list
@@ -88,7 +89,8 @@
(Keyword jtm-format)
(Integer revision))
(open-tm-store repository-path)
- (import-construct-from-jtm-string (read-file jtm-path) :tm-id tm-id :revision revision
+ (import-construct-from-jtm-string (read-file-to-string jtm-path)
+ :tm-id tm-id :revision revision
:jtm-format jtm-format)
(close-tm-store))
@@ -105,8 +107,9 @@
(get-item :ITEM--IDENTIFIERS jtm-list)
:prefixes prefixes)
(when tm-id
- (make-construct 'ItemIdentifierC
- :uri tm-id)))))
+ (list
+ (make-construct 'ItemIdentifierC
+ :uri tm-id))))))
(unless value
(error (make-condition 'JTM-error :message (format nil "From import-topic-map-from-jtm-list(): no topic-map item-identifier is set for ~a" jtm-list))))
value))
@@ -234,6 +237,7 @@
:roles role-lists)))
(dolist (tm local-parent)
(add-to-tm tm assoc))
+ (format t "a")
assoc)))
@@ -374,6 +378,7 @@
(add-name top name :revision revision))
(dolist (occ top-occs)
(add-occurrence top occ :revision revision))
+ (format t "t")
top))
Added: trunk/src/unit_tests/jtm_1.0_test.jtm
==============================================================================
--- (empty file)
+++ trunk/src/unit_tests/jtm_1.0_test.jtm Tue May 10 05:38:24 2011
@@ -0,0 +1 @@
+{"version":"1.0","item_identifiers":null,"topics":[{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#topic"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#association"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#occurrence"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#class-instance"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#class"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#supertype-subtype"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#supertype"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#subtype"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#sort"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#display"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/iso13250\/model\/type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/iso13250\/model\/instance"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/topic-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/association-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/written-by"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/role-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/written"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/writer"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/name-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/psi.topicmaps.org\/tmcl\/scope-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/author"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/poem"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/first-name"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/last-name"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/title"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/display-name"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/de"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/date-of-birth"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/date-of-death"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/poem-content"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/years"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/isDead"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/isAlive"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/reifier-type"],"subject_locators":null,"item_identifiers":null,"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/tmsparql\/author\/goethe"],"subject_locators":null,"item_identifiers":["http:\/\/some.where\/ii\/goethe"],"names":[{"item_identifiers":null,"value":"Johann Wolfgang","type":"si:http:\/\/some.where\/tmsparql\/first-name","scope":null,"variants":null,"reifier":null},{"item_identifiers":null,"value":"von Goethe","type":"si:http:\/\/some.where\/tmsparql\/last-name","scope":null,"variants":[{"item_identifiers":["http:\/\/some.where\/ii\/goethe-variant"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#string","value":"Goethe","scope":["si:http:\/\/some.where\/tmsparql\/display-name"],"reifier":null}],"reifier":"ii:http:\/\/some.where\/ii\/goethe-name-reifier"},{"item_identifiers":["http:\/\/some.where\/ii\/goethe-untyped-name"],"value":"Johann Wolfgang von Goethe","type":null,"scope":null,"variants":null,"reifier":null}],"occurrences":[{"item_identifiers":["http:\/\/some.where\/ii\/goethe-occ"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#date","type":"si:http:\/\/some.where\/tmsparql\/date-of-birth","value":"28.08.1749","scope":null,"reifier":"ii:http:\/\/some.where\/ii\/goethe-occ-reifier"},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#date","type":"si:http:\/\/some.where\/tmsparql\/date-of-death","value":"22.03.1832","scope":null,"reifier":null},{"item_identifiers":["http:\/\/some.where\/ii\/goethe-years-occ"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#integer","type":"si:http:\/\/some.where\/tmsparql\/years","value":"82","scope":null,"reifier":null},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#boolean","type":"si:http:\/\/some.where\/tmsparql\/isDead","value":"true","scope":null,"reifier":null},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#boolean","type":"si:http:\/\/some.where\/tmsparql\/isAlive","value":"false","scope":null,"reifier":null}]},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["http:\/\/some.where\/ii\/goethe-occ-reifier"],"names":null,"occurrences":null},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["http:\/\/some.where\/ii\/goethe-name-reifier"],"names":null,"occurrences":null},{"subject_identifiers":["http:\/\/some.where\/psis\/poem\/zauberlehrling"],"subject_locators":null,"item_identifiers":null,"names":[{"item_identifiers":null,"value":"Der Zauberlehrling","type":"si:http:\/\/some.where\/tmsparql\/title","scope":null,"variants":null,"reifier":null}],"occurrences":[{"item_identifiers":["http:\/\/some.where\/ii\/zb\/occurrence"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#string","type":"si:http:\/\/some.where\/tmsparql\/poem-content","value":"Hat der alte Hexenmeister\n\tsich doch einmal wegbegeben!\n\t...","scope":["si:http:\/\/some.where\/tmsparql\/de"],"reifier":null}]},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["http:\/\/some.where\/ii\/association-reifier"],"names":null,"occurrences":null},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["http:\/\/some.where\/ii\/role-reifier"],"names":null,"occurrences":null}],"associations":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/association-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/association-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/written-by"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/role-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/role-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/written"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/role-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/writer"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/name-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/scope-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/author"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/poem"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/name-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/first-name"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/name-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/last-name"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/name-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/title"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/scope-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/display-name"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/scope-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/de"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/date-of-birth"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/date-of-death"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/poem-content"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/years"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/isDead"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/occurrence-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/isAlive"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/psi.topicmaps.org\/tmcl\/topic-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/reifier-type"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/author"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/author\/goethe"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/reifier-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"ii:http:\/\/some.where\/ii\/goethe-occ-reifier"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/reifier-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"ii:http:\/\/some.where\/ii\/goethe-name-reifier"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/poem"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"si:http:\/\/some.where\/psis\/poem\/zauberlehrling"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/reifier-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"ii:http:\/\/some.where\/ii\/association-reifier"}]},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type-instance","reifier":null,"scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/type","reifier":null,"player":"si:http:\/\/some.where\/tmsparql\/reifier-type"},{"item_identifiers":null,"type":"si:http:\/\/psi.topicmaps.org\/iso13250\/model\/instance","reifier":null,"player":"ii:http:\/\/some.where\/ii\/role-reifier"}]},{"item_identifiers":["http:\/\/some.where\/ii\/association"],"type":"si:http:\/\/some.where\/tmsparql\/written-by","reifier":"ii:http:\/\/some.where\/ii\/association-reifier","scope":null,"roles":[{"item_identifiers":null,"type":"si:http:\/\/some.where\/tmsparql\/writer","reifier":"ii:http:\/\/some.where\/ii\/role-reifier","player":"si:http:\/\/some.where\/tmsparql\/author\/goethe"},{"item_identifiers":["http:\/\/some.where\/ii\/role-2"],"type":"si:http:\/\/some.where\/tmsparql\/written","reifier":null,"player":"si:http:\/\/some.where\/psis\/poem\/zauberlehrling"}]}],"item_type":"topicmap","reifier":null}
Added: trunk/src/unit_tests/jtm_1.1_test.jtm
==============================================================================
--- (empty file)
+++ trunk/src/unit_tests/jtm_1.1_test.jtm Tue May 10 05:38:24 2011
@@ -0,0 +1 @@
+{"version":"1.1","prefixes":{"pref_1":"http:\/\/www.topicmaps.org\/xtm\/1.0\/core.xtm#","pref_2":"http:\/\/psi.topicmaps.org\/iso13250\/model\/","pref_5":"http:\/\/some.where\/tmsparql\/author\/","xsd":"http:\/\/www.w3.org\/2001\/XMLSchema#","pref_3":"http:\/\/psi.topicmaps.org\/tmcl\/","pref_6":"http:\/\/some.where\/psis\/poem\/","pref_4":"http:\/\/some.where\/tmsparql\/","pref_7":"http:\/\/some.where\/ii\/zb\/","pref_8":"http:\/\/some.where\/ii\/"},"item_identifiers":["[pref_4:jtm-tm]"],"topics":[{"subject_identifiers":["[pref_1:topic]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:association]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:occurrence]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:class-instance]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:class]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:supertype-subtype]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:supertype]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:subtype]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:sort]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_1:display]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_2:type-instance]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_2:type]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_2:instance]"],"subject_locators":null,"item_identifiers":null,"instance_of":null,"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:topic-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:occurrence-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:association-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:written-by]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:association-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:role-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:written]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:role-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:writer]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:role-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:name-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_3:scope-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:author]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:poem]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:first-name]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:name-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:last-name]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:name-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:title]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:name-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:display-name]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:scope-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:de]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:scope-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:date-of-birth]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:date-of-death]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:poem-content]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:years]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:isDead]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:isAlive]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:occurrence-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_4:reifier-type]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_3:topic-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_5:goethe]"],"subject_locators":null,"item_identifiers":["[pref_8:goethe]"],"instance_of":["si:[pref_4:author]"],"names":[{"item_identifiers":null,"value":"Johann Wolfgang","type":"si:[pref_4:first-name]","scope":null,"variants":null,"reifier":null},{"item_identifiers":null,"value":"von Goethe","type":"si:[pref_4:last-name]","scope":null,"variants":[{"item_identifiers":["[pref_8:goethe-variant]"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#string","value":"Goethe","scope":["si:[pref_4:display-name]"],"reifier":null}],"reifier":"ii:[pref_8:goethe-name-reifier]"},{"item_identifiers":["[pref_8:goethe-untyped-name]"],"value":"Johann Wolfgang von Goethe","type":null,"scope":null,"variants":null,"reifier":null}],"occurrences":[{"item_identifiers":["[pref_8:goethe-occ]"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#date","type":"si:[pref_4:date-of-birth]","value":"28.08.1749","scope":null,"reifier":"ii:[pref_8:goethe-occ-reifier]"},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#date","type":"si:[pref_4:date-of-death]","value":"22.03.1832","scope":null,"reifier":null},{"item_identifiers":["[pref_8:goethe-years-occ]"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#integer","type":"si:[pref_4:years]","value":"82","scope":null,"reifier":null},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#boolean","type":"si:[pref_4:isDead]","value":"true","scope":null,"reifier":null},{"item_identifiers":null,"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#boolean","type":"si:[pref_4:isAlive]","value":"false","scope":null,"reifier":null}]},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["[pref_8:goethe-occ-reifier]"],"instance_of":["si:[pref_4:reifier-type]"],"names":null,"occurrences":null},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["[pref_8:goethe-name-reifier]"],"instance_of":["si:[pref_4:reifier-type]"],"names":null,"occurrences":null},{"subject_identifiers":["[pref_6:zauberlehrling]"],"subject_locators":null,"item_identifiers":null,"instance_of":["si:[pref_4:poem]"],"names":[{"item_identifiers":null,"value":"Der Zauberlehrling","type":"si:[pref_4:title]","scope":null,"variants":null,"reifier":null}],"occurrences":[{"item_identifiers":["[pref_7:occurrence]"],"datatype":"http:\/\/www.w3.org\/2001\/XMLSchema#string","type":"si:[pref_4:poem-content]","value":"Hat der alte Hexenmeister\n\tsich doch einmal wegbegeben!\n\t...","scope":["si:[pref_4:de]"],"reifier":null}]},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["[pref_8:association-reifier]"],"instance_of":["si:[pref_4:reifier-type]"],"names":null,"occurrences":null},{"subject_identifiers":null,"subject_locators":null,"item_identifiers":["[pref_8:role-reifier]"],"instance_of":["si:[pref_4:reifier-type]"],"names":null,"occurrences":null}],"associations":[{"item_identifiers":["[pref_8:association]"],"type":"si:[pref_4:written-by]","reifier":"ii:[pref_8:association-reifier]","scope":null,"roles":[{"item_identifiers":null,"type":"si:[pref_4:writer]","reifier":"ii:[pref_8:role-reifier]","player":"si:[pref_5:goethe]"},{"item_identifiers":["[pref_8:role-2]"],"type":"si:[pref_4:written]","reifier":null,"player":"si:[pref_6:zauberlehrling]"}]}],"item_type":"topicmap","reifier":null}
Modified: trunk/src/unit_tests/jtm_test.lisp
==============================================================================
--- trunk/src/unit_tests/jtm_test.lisp (original)
+++ trunk/src/unit_tests/jtm_test.lisp Tue May 10 05:38:24 2011
@@ -44,7 +44,12 @@
:test-import-topics
:test-merge-topics
:test-import-associations
- :test-import-roles))
+ :test-import-roles
+ :test-import-topic-maps-1
+ :test-import-topic-maps-2
+ :test-import-topic-maps-3
+ :test-import-topic-maps-4
+ :test-import-topic-maps-5))
(in-package :jtm-test)
@@ -1022,10 +1027,10 @@
(export-as-jtm jtm-path-2 :tm-id nil :revision 0 :jtm-format :1.0)
(export-as-jtm jtm-path-3 :tm-id fixtures::tm-id :revision 0 :jtm-format :1.1)
(export-as-jtm jtm-path-4 :tm-id fixtures::tm-id :revision 0 :jtm-format :1.0)
- (let ((jtm-str-1 (read-file jtm-path-1))
- (jtm-str-2 (read-file jtm-path-2))
- (jtm-str-3 (read-file jtm-path-3))
- (jtm-str-4 (read-file jtm-path-4))
+ (let ((jtm-str-1 (read-file-to-string jtm-path-1))
+ (jtm-str-2 (read-file-to-string jtm-path-2))
+ (jtm-str-3 (read-file-to-string jtm-path-3))
+ (jtm-str-4 (read-file-to-string jtm-path-4))
(prefixes (list
(list :pref "pref_1"
:value "http://www.topicmaps.org/xtm/1.0/core.xtm#")
@@ -2291,10 +2296,592 @@
(json:decode-json-from-string "{\"version\":\"1.0\",\"item_identifiers\":null,\"type\":null,\"item_type\":\"role\",\"reifier\":null,\"player\":\"ii:http:\\/\\/some.where\\/ii-1\"}")
parent-1 :revision 100)))))
+
+(test test-import-topic-maps-1
+ "Tests the function import-topic-map-from-jtm-list."
+ (with-fixture with-empty-db ("data_base")
+ (let ((jtm-str
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.1_test.jtm"))))
+ (let ((tm (import-construct-from-jtm-string
+ jtm-str :revision 100 :jtm-format :1.1)))
+ (is-true tm)
+ (is (= (length (elephant:get-instances-by-class 'TopicC)) 42))
+ (loop for top in (elephant:get-instances-by-class 'TopicC) do
+ (cond ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#topic"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#association"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#occurrence"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class-instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype-subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#sort"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#display")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-false (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find (uri (first (psis top :revision 0)))
+ (list "http://psi.topicmaps.org/iso13250/model/type-instance"
+ "http://psi.topicmaps.org/iso13250/model/type"
+ "http://psi.topicmaps.org/iso13250/model/instance")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is (= (length (used-as-type top :revision 0)) 29))
+ (is-false (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/written-by"
+ "http://some.where/tmsparql/written"
+ "http://some.where/tmsparql/writer"
+ "http://some.where/tmsparql/first-name"
+ "http://some.where/tmsparql/last-name"
+ "http://some.where/tmsparql/title"
+ "http://some.where/tmsparql/date-of-birth"
+ "http://some.where/tmsparql/date-of-death"
+ "http://some.where/tmsparql/years"
+ "http://some.where/tmsparql/isDead"
+ "http://some.where/tmsparql/isAlive"
+ "http://some.where/tmsparql/poem-content")
+ :test 'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-true (used-as-type top :revision 0))
+ (is (= (length (player-in-roles top :revision 0)) 1))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://psi.topicmaps.org/tmcl/topic-type"
+ "http://psi.topicmaps.org/tmcl/occurrence-type"
+ "http://psi.topicmaps.org/tmcl/association-type"
+ "http://psi.topicmaps.org/tmcl/name-type"
+ "http://psi.topicmaps.org/tmcl/scope-type"
+ "http://psi.topicmaps.org/tmcl/role-type")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((or (and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/author/goethe"
+ "http://some.where/tmsparql/author"
+ "http://some.where/psis/poem/zauberlehrling"
+ "http://some.where/tmsparql/poem"
+ "http://some.where/tmsparql/display-name"
+ "http://some.where/tmsparql/de"
+ "http://some.where/tmsparql/reifier-type")
+ :test #'string=))
+ (and
+ (= (length (item-identifiers top :revision 0)) 1)
+ (find
+ (uri (first (item-identifiers top :revision 0)))
+ (list
+ "http://some.where/ii/goethe-occ-reifier"
+ "http://some.where/ii/goethe-name-reifier"
+ "http://some.where/ii/association-reifier"
+ "http://some.where/ii/role-reifier")
+ :test #'string=)))
+ nil) ;is checked in the next unit-test
+ (t
+ (is-false top))))))))
+
+
+
+
+(test test-import-topic-maps-2
+ "Tests the function import-topic-map-from-jtm-list."
+ (with-fixture with-empty-db ("data_base")
+ (let ((jtm-str
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.1_test.jtm"))))
+ (let ((tm (import-construct-from-jtm-string
+ jtm-str :revision 100 :jtm-format :1.1)))
+ (is-true tm)
+ (is (= (length (elephant:get-instances-by-class 'TopicC)) 42))
+ (loop for top in (elephant:get-instances-by-class 'TopicC) do
+ (cond ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://psi.topicmaps.org/iso13250/model/type-instance"
+ "http://psi.topicmaps.org/iso13250/model/type"
+ "http://psi.topicmaps.org/iso13250/model/instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#topic"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#association"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#occurrence"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class-instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype-subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#sort"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#display"
+ "http://some.where/tmsparql/written-by"
+ "http://some.where/tmsparql/written"
+ "http://some.where/tmsparql/writer"
+ "http://some.where/tmsparql/first-name"
+ "http://some.where/tmsparql/last-name"
+ "http://some.where/tmsparql/title"
+ "http://some.where/tmsparql/date-of-birth"
+ "http://some.where/tmsparql/date-of-death"
+ "http://some.where/tmsparql/years"
+ "http://some.where/tmsparql/isDead"
+ "http://some.where/tmsparql/isAlive"
+ "http://some.where/tmsparql/poem-content"
+ "http://psi.topicmaps.org/tmcl/topic-type"
+ "http://psi.topicmaps.org/tmcl/occurrence-type"
+ "http://psi.topicmaps.org/tmcl/association-type"
+ "http://psi.topicmaps.org/tmcl/name-type"
+ "http://psi.topicmaps.org/tmcl/scope-type"
+ "http://psi.topicmaps.org/tmcl/role-type")
+ :test #'string=))
+ nil) ;is checked in the unit-test before
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/author"
+ "http://some.where/tmsparql/poem"
+ "http://some.where/tmsparql/display-name"
+ "http://some.where/tmsparql/de"
+ "http://some.where/tmsparql/reifier-type")
+ :test #'string=))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (item-identifiers top :revision 0)) 1)
+ (find
+ (uri (first (item-identifiers top :revision 0)))
+ (list
+ "http://some.where/ii/goethe-occ-reifier"
+ "http://some.where/ii/goethe-name-reifier"
+ "http://some.where/ii/association-reifier"
+ "http://some.where/ii/role-reifier")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-true (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (psis top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and (= (length (psis top :revision 0)) 1)
+ (string= (uri (first (psis top :revision 0)))
+ "http://some.where/tmsparql/author/goethe"))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is (= (length (occurrences top :revision 0)) 5))
+ (is (= (length (names top :revision 0)) 3))
+ (is (= (length (item-identifiers top :revision 0)) 1))
+ (is (string=
+ "http://some.where/ii/goethe"
+ (uri (first (item-identifiers top :revision 0)))))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and (= (length (psis top :revision 0)) 1)
+ (string= (uri (first (psis top :revision 0)))
+ "http://some.where/psis/poem/zauberlehrling"))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is (= (length (occurrences top :revision 0)) 1))
+ (is (= (length (names top :revision 0)) 1))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ (t
+ (is-false top))))
+ (is (= (length (elephant:get-instances-by-class 'TopicMapC)) 1))
+ (is (= (length (elephant:get-instances-by-class 'AssociationC)) 30))
+ (let ((assoc
+ (get-item-by-item-identifier "http://some.where/ii/association"
+ :revision 0)))
+ (is (typep assoc 'AssociationC))
+ (is (= (length (roles assoc :revision 0)) 2))
+ (is (= (length (item-identifiers assoc :revision 0)) 1))
+ (is (eql (instance-of assoc :revision 0)
+ (get-item-by-psi "http://some.where/tmsparql/written-by"
+ :revision 0)))
+ (is (eql (reifier assoc :revision 0)
+ (get-item-by-item-identifier
+ "http://some.where/ii/association-reifier"
+ :revision 0))))))))
+
+
+(test test-import-topic-maps-3
+ "Tests the function import-topic-map-from-jtm-list."
+ (with-fixture with-empty-db ("data_base")
+ (let* ((jtm-str
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.0_test.jtm")))
+ (tm (import-construct-from-jtm-string
+ jtm-str :revision 100 :jtm-format :1.0
+ :tm-id "http://some.where/jtm-tm")))
+ (is-true tm)
+ (is (= (length (elephant:get-instances-by-class 'TopicC)) 42))
+ (loop for top in (elephant:get-instances-by-class 'TopicC) do
+ (cond ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#topic"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#association"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#occurrence"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class-instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype-subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#sort"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#display")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-false (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find (uri (first (psis top :revision 0)))
+ (list "http://psi.topicmaps.org/iso13250/model/type-instance"
+ "http://psi.topicmaps.org/iso13250/model/type"
+ "http://psi.topicmaps.org/iso13250/model/instance")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is (= (length (used-as-type top :revision 0)) 29))
+ (is-false (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/written-by"
+ "http://some.where/tmsparql/written"
+ "http://some.where/tmsparql/writer"
+ "http://some.where/tmsparql/first-name"
+ "http://some.where/tmsparql/last-name"
+ "http://some.where/tmsparql/title"
+ "http://some.where/tmsparql/date-of-birth"
+ "http://some.where/tmsparql/date-of-death"
+ "http://some.where/tmsparql/years"
+ "http://some.where/tmsparql/isDead"
+ "http://some.where/tmsparql/isAlive"
+ "http://some.where/tmsparql/poem-content")
+ :test 'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-true (used-as-type top :revision 0))
+ (is (= (length (player-in-roles top :revision 0)) 1))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://psi.topicmaps.org/tmcl/topic-type"
+ "http://psi.topicmaps.org/tmcl/occurrence-type"
+ "http://psi.topicmaps.org/tmcl/association-type"
+ "http://psi.topicmaps.org/tmcl/name-type"
+ "http://psi.topicmaps.org/tmcl/scope-type"
+ "http://psi.topicmaps.org/tmcl/role-type")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((or (and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/author/goethe"
+ "http://some.where/tmsparql/author"
+ "http://some.where/psis/poem/zauberlehrling"
+ "http://some.where/tmsparql/poem"
+ "http://some.where/tmsparql/display-name"
+ "http://some.where/tmsparql/de"
+ "http://some.where/tmsparql/reifier-type")
+ :test #'string=))
+ (and
+ (= (length (item-identifiers top :revision 0)) 1)
+ (find
+ (uri (first (item-identifiers top :revision 0)))
+ (list
+ "http://some.where/ii/goethe-occ-reifier"
+ "http://some.where/ii/goethe-name-reifier"
+ "http://some.where/ii/association-reifier"
+ "http://some.where/ii/role-reifier")
+ :test #'string=)))
+ nil) ;is checked in the next unit-test
+ (t
+ (is-false top)))))))
+
+
+(test test-import-topic-maps-4
+ "Tests the function import-topic-map-from-jtm-list."
+ (with-fixture with-empty-db ("data_base")
+ (let* ((jtm-str
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.0_test.jtm")))
+ (tm (import-construct-from-jtm-string
+ jtm-str :revision 100 :jtm-format :1.0
+ :tm-id "http://some.where/jtm-tm")))
+ (is-true tm)
+ (is (= (length (elephant:get-instances-by-class 'TopicC)) 42))
+ (loop for top in (elephant:get-instances-by-class 'TopicC) do
+ (cond ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://psi.topicmaps.org/iso13250/model/type-instance"
+ "http://psi.topicmaps.org/iso13250/model/type"
+ "http://psi.topicmaps.org/iso13250/model/instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#topic"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#association"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#occurrence"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class-instance"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#class"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype-subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#supertype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#subtype"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#sort"
+ "http://www.topicmaps.org/xtm/1.0/core.xtm#display"
+ "http://some.where/tmsparql/written-by"
+ "http://some.where/tmsparql/written"
+ "http://some.where/tmsparql/writer"
+ "http://some.where/tmsparql/first-name"
+ "http://some.where/tmsparql/last-name"
+ "http://some.where/tmsparql/title"
+ "http://some.where/tmsparql/date-of-birth"
+ "http://some.where/tmsparql/date-of-death"
+ "http://some.where/tmsparql/years"
+ "http://some.where/tmsparql/isDead"
+ "http://some.where/tmsparql/isAlive"
+ "http://some.where/tmsparql/poem-content"
+ "http://psi.topicmaps.org/tmcl/topic-type"
+ "http://psi.topicmaps.org/tmcl/occurrence-type"
+ "http://psi.topicmaps.org/tmcl/association-type"
+ "http://psi.topicmaps.org/tmcl/name-type"
+ "http://psi.topicmaps.org/tmcl/scope-type"
+ "http://psi.topicmaps.org/tmcl/role-type")
+ :test #'string=))
+ nil) ;is checked in the unit-test before
+ ((and
+ (= (length (psis top :revision 0)) 1)
+ (find
+ (uri (first (psis top :revision 0)))
+ (list
+ "http://some.where/tmsparql/author"
+ "http://some.where/tmsparql/poem"
+ "http://some.where/tmsparql/display-name"
+ "http://some.where/tmsparql/de"
+ "http://some.where/tmsparql/reifier-type")
+ :test #'string=))
+ (is-false (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and
+ (= (length (item-identifiers top :revision 0)) 1)
+ (find
+ (uri (first (item-identifiers top :revision 0)))
+ (list
+ "http://some.where/ii/goethe-occ-reifier"
+ "http://some.where/ii/goethe-name-reifier"
+ "http://some.where/ii/association-reifier"
+ "http://some.where/ii/role-reifier")
+ :test #'string=))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-true (reified-construct top :revision 0))
+ (is-false (occurrences top :revision 0))
+ (is-false (names top :revision 0))
+ (is-false (psis top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and (= (length (psis top :revision 0)) 1)
+ (string= (uri (first (psis top :revision 0)))
+ "http://some.where/tmsparql/author/goethe"))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is (= (length (occurrences top :revision 0)) 5))
+ (is (= (length (names top :revision 0)) 3))
+ (is (= (length (item-identifiers top :revision 0)) 1))
+ (is (string=
+ "http://some.where/ii/goethe"
+ (uri (first (item-identifiers top :revision 0)))))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ ((and (= (length (psis top :revision 0)) 1)
+ (string= (uri (first (psis top :revision 0)))
+ "http://some.where/psis/poem/zauberlehrling"))
+ (is-false (used-as-theme top :revision 0))
+ (is-false (used-as-type top :revision 0))
+ (is-true (player-in-roles top :revision 0))
+ (is-false (reified-construct top :revision 0))
+ (is (= (length (occurrences top :revision 0)) 1))
+ (is (= (length (names top :revision 0)) 1))
+ (is-false (item-identifiers top :revision 0))
+ (is-false (locators top :revision 0))
+ (is (= (length (in-topicmaps top :revision 0)) 1))
+ (is (eql tm (first (in-topicmaps top :revision 0)))))
+ (t
+ (is-false top))))
+ (is (= (length (elephant:get-instances-by-class 'AssociationC)) 30))
+ (let ((assoc
+ (get-item-by-item-identifier "http://some.where/ii/association"
+ :revision 0)))
+ (is (= (length (elephant:get-instances-by-class 'TopicMapC)) 1))
+ (is (typep assoc 'AssociationC))
+ (is (= (length (roles assoc :revision 0)) 2))
+ (is (= (length (item-identifiers assoc :revision 0)) 1))
+ (is (eql (instance-of assoc :revision 0)
+ (get-item-by-psi "http://some.where/tmsparql/written-by"
+ :revision 0)))
+ (is (eql (reifier assoc :revision 0)
+ (get-item-by-item-identifier
+ "http://some.where/ii/association-reifier"
+ :revision 0)))))))
+
+
+(test test-import-topic-maps-5
+ "Tests the function import-topic-map-from-jtm-list."
+ (with-fixture with-empty-db ("data_base")
+ (let* ((jtm-str-1
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.0_test.jtm")))
+ (jtm-str-2
+ (read-file-to-string
+ (merge-pathnames
+ (asdf:component-pathname
+ (asdf:find-component constants:*isidorus-system* "unit_tests"))
+ "jtm_1.1_test.jtm"))))
+ (signals exceptions::JTM-error
+ (import-construct-from-jtm-string
+ jtm-str-1 :revision 100 :jtm-format :1.1))
+ (let ((tm (import-construct-from-jtm-string
+ jtm-str-2 :revision 100 :jtm-format :1.1
+ :tm-id "http://some.where/new-tm-id")))
+ (is-false (set-exclusive-or
+ (list "http://some.where/new-tm-id"
+ "http://some.where/tmsparql/jtm-tm")
+ (map 'list #'uri (item-identifiers tm :revision 0))
+ :test #'string=))
+ (is (= (length (elephant:get-instances-by-class 'TopicMapC)) 1))))))
+
+
+
+
+
+
;TODO:
-; *import-construct-from-jtm-string
; *import-from-jtm
-; *import-topic-map-from-jtm-list
(defun run-jtm-tests()
"Runs all tests of this test-suite."
More information about the Isidorus-cvs
mailing list