jsonParserTests.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. # jsonParser.py
  2. #
  3. # Copyright (c) 2006, Paul McGuire
  4. #
  5. test1 = """
  6. {
  7. "glossary": {
  8. "title": "example glossary",
  9. "GlossDiv": {
  10. "title": "S",
  11. "GlossList": [{
  12. "ID": "SGML",
  13. "SortAs": "SGML",
  14. "GlossTerm": "Standard Generalized Markup Language",
  15. "Acronym": "SGML",
  16. "LargestPrimeLessThan100": 97,
  17. "AvogadroNumber": 6.02E23,
  18. "EvenPrimesGreaterThan2": null,
  19. "PrimesLessThan10" : [2,3,5,7],
  20. "WMDsFound" : false,
  21. "IraqAlQaedaConnections" : null,
  22. "Abbrev": "ISO 8879:1986",
  23. "GlossDef":
  24. "A meta-markup language, used to create markup languages such as DocBook.",
  25. "GlossSeeAlso": ["GML", "XML", "markup"],
  26. "EmptyDict" : {},
  27. "EmptyList" : []
  28. }]
  29. }
  30. }
  31. }
  32. """
  33. test2 = """
  34. {"menu": {
  35. "id": "file",
  36. "value": "File:",
  37. "popup": {
  38. "menuitem": [
  39. {"value": "New", "onclick": "CreateNewDoc()"},
  40. {"value": "Open", "onclick": "OpenDoc()"},
  41. {"value": "Close", "onclick": "CloseDoc()"}
  42. ]
  43. }
  44. }}
  45. """
  46. test3 = """
  47. {"widget": {
  48. "debug": "on",
  49. "window": {
  50. "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500
  51. }, "image": {
  52. "src": "Images/Sun.png",
  53. "name": "sun1", "hOffset": 250, "vOffset": 250, "alignment": "center"
  54. }, "text": {
  55. "data": "Click Here",
  56. "size": 36,
  57. "style": "bold", "name": "text1", "hOffset": 250, "vOffset": 100, "alignment": "center",
  58. "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
  59. }
  60. }}
  61. """
  62. test4 = """
  63. {"web-app": {
  64. "servlet": [ // Defines the CDSServlet
  65. {
  66. "servlet-name": "cofaxCDS",
  67. "servlet-class": "org.cofax.cds.CDSServlet",
  68. /*
  69. Defines glossary variables that template designers
  70. can use across the site. You can add new
  71. variables to this set by creating a new init-param, with
  72. the param-name prefixed with "configGlossary:".
  73. */
  74. "init-param": {
  75. "configGlossary:installationAt": "Philadelphia, PA",
  76. "configGlossary:adminEmail": "ksm@pobox.com",
  77. "configGlossary:poweredBy": "Cofax",
  78. "configGlossary:poweredByIcon": "/images/cofax.gif",
  79. "configGlossary:staticPath": "/content/static",
  80. /*
  81. Defines the template loader and template processor
  82. classes. These are implementations of org.cofax.TemplateProcessor
  83. and org.cofax.TemplateLoader respectively. Simply create new
  84. implementation of these classes and set them here if the default
  85. implementations do not suit your needs. Leave these alone
  86. for the defaults.
  87. */
  88. "templateProcessorClass": "org.cofax.WysiwygTemplate",
  89. "templateLoaderClass": "org.cofax.FilesTemplateLoader",
  90. "templatePath": "templates",
  91. "templateOverridePath": "",
  92. /*
  93. Defines the names of the default templates to look for
  94. when acquiring WYSIWYG templates. Leave these at their
  95. defaults for most usage.
  96. */
  97. "defaultListTemplate": "listTemplate.htm",
  98. "defaultFileTemplate": "articleTemplate.htm",
  99. /*
  100. New! useJSP switches on JSP template processing.
  101. jspListTemplate and jspFileTemplate are the names
  102. of the default templates to look for when aquiring JSP
  103. templates. Cofax currently in production at KR has useJSP
  104. set to false, since our sites currently use WYSIWYG
  105. templating exclusively.
  106. */
  107. "useJSP": false,
  108. "jspListTemplate": "listTemplate.jsp",
  109. "jspFileTemplate": "articleTemplate.jsp",
  110. /*
  111. Defines the packageTag cache. This cache keeps
  112. Cofax from needing to interact with the database
  113. to look up packageTag commands.
  114. */
  115. "cachePackageTagsTrack": 200,
  116. "cachePackageTagsStore": 200,
  117. "cachePackageTagsRefresh": 60,
  118. /*
  119. Defines the template cache. Keeps Cofax from needing
  120. to go to the file system to load a raw template from
  121. the file system.
  122. */
  123. "cacheTemplatesTrack": 100,
  124. "cacheTemplatesStore": 50,
  125. "cacheTemplatesRefresh": 15,
  126. /*
  127. Defines the page cache. Keeps Cofax from processing
  128. templates to deliver to users.
  129. */
  130. "cachePagesTrack": 200,
  131. "cachePagesStore": 100,
  132. "cachePagesRefresh": 10,
  133. "cachePagesDirtyRead": 10,
  134. /*
  135. Defines the templates Cofax will use when
  136. being browsed by a search engine identified in
  137. searchEngineRobotsDb
  138. */
  139. "searchEngineListTemplate": "forSearchEnginesList.htm",
  140. "searchEngineFileTemplate": "forSearchEngines.htm",
  141. "searchEngineRobotsDb": "WEB-INF/robots.db",
  142. /*
  143. New! useDataStore enables/disables the Cofax database pool
  144. */
  145. "useDataStore": true,
  146. /*
  147. Defines the implementation of org.cofax.DataStore that Cofax
  148. will use. If this DataStore class does not suit your needs
  149. simply implement a new DataStore class and set here.
  150. */
  151. "dataStoreClass": "org.cofax.SqlDataStore",
  152. /*
  153. Defines the implementation of org.cofax.Redirection that
  154. Cofax will use. If this Redirection class does not suit
  155. your needs simply implenet a new Redirection class
  156. and set here.
  157. */
  158. "redirectionClass": "org.cofax.SqlRedirection",
  159. /*
  160. Defines the data store name. Keep this at the default
  161. */
  162. "dataStoreName": "cofax",
  163. /*
  164. Defines the JDBC driver that Cofax's database pool will use
  165. */
  166. "dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
  167. /*
  168. Defines the JDBC connection URL to connect to the database
  169. */
  170. "dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
  171. /*
  172. Defines the user name to connect to the database
  173. */
  174. "dataStoreUser": "sa",
  175. /*
  176. Defines the password to connect to the database
  177. */
  178. "dataStorePassword": "dataStoreTestQuery",
  179. /*
  180. A query that will run to test the validity of the
  181. connection in the pool.
  182. */
  183. "dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
  184. /*
  185. A log file to print out database information
  186. */
  187. "dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
  188. /*
  189. The number of connection to initialize on startup
  190. */
  191. "dataStoreInitConns": 10,
  192. /*
  193. The maximum number of connection to use in the pool
  194. */
  195. "dataStoreMaxConns": 100,
  196. /*
  197. The number of times a connection will be utilized from the
  198. pool before disconnect
  199. */
  200. "dataStoreConnUsageLimit": 100,
  201. /*
  202. The level of information to print to the log
  203. */
  204. "dataStoreLogLevel": "debug",
  205. /*
  206. The maximum URL length allowable by the CDS Servlet
  207. Helps to prevent hacking
  208. */
  209. "maxUrlLength": 500}},
  210. /*
  211. Defines the Email Servlet
  212. */
  213. {
  214. "servlet-name": "cofaxEmail",
  215. "servlet-class": "org.cofax.cds.EmailServlet",
  216. "init-param": {
  217. /*
  218. The mail host to be used by the mail servlet
  219. */
  220. "mailHost": "mail1",
  221. /*
  222. An override
  223. */
  224. "mailHostOverride": "mail2"}},
  225. /*
  226. Defines the Admin Servlet - used to refresh cache on
  227. demand and see statistics
  228. */
  229. {
  230. "servlet-name": "cofaxAdmin",
  231. "servlet-class": "org.cofax.cds.AdminServlet"},
  232. /*
  233. Defines the File Servlet - used to display files like Apache
  234. */
  235. {
  236. "servlet-name": "fileServlet",
  237. "servlet-class": "org.cofax.cds.FileServlet"},
  238. {
  239. "servlet-name": "cofaxTools",
  240. "servlet-class": "org.cofax.cms.CofaxToolsServlet",
  241. "init-param": {
  242. /*
  243. Path to the template folder relative to the tools tomcat installation.
  244. */
  245. "templatePath": "toolstemplates/",
  246. /*
  247. Logging boolean 1 = on, 0 = off
  248. */
  249. "log": 1,
  250. /*
  251. Location of log. If empty, log will be written System.out
  252. */
  253. "logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
  254. /*
  255. Max size of log in BITS. If size is empty, no limit to log.
  256. If size is defined, log will be overwritten upon reaching defined size.
  257. */
  258. "logMaxSize": "",
  259. /*
  260. DataStore logging boolean 1 = on, 0 = off
  261. */
  262. "dataLog": 1,
  263. /*
  264. DataStore location of log. If empty, log will be written System.out
  265. */
  266. "dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
  267. /*
  268. Max size of log in BITS. If size is empty, no limit to log.
  269. If size is defined, log will be overwritten upon reaching defined size.
  270. */
  271. "dataLogMaxSize": "",
  272. /*
  273. Http string relative to server root to call for page cache
  274. removal to Cofax Servlet.
  275. */
  276. "removePageCache": "/content/admin/remove?cache=pages&id=",
  277. /*
  278. Http string relative to server root to call for template
  279. cache removal to Cofax Servlet.
  280. */
  281. "removeTemplateCache": "/content/admin/remove?cache=templates&id=",
  282. /*
  283. Location of folder from root of drive that will be used for
  284. ftp transfer from beta server or user hard drive to live servers.
  285. Note that Edit Article will not function without this variable
  286. set correctly. MultiPart request relies upon access to this folder.
  287. */
  288. "fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
  289. /*
  290. Defines whether the Server should look in another path for
  291. config files or variables.
  292. */
  293. "lookInContext": 1,
  294. /*
  295. Number of the ID of the top level administration group in tblPermGroups.
  296. */
  297. "adminGroupID": 4,
  298. /*
  299. Is the tools app running on the 'beta server'.
  300. */
  301. "betaServer": true}}],
  302. "servlet-mapping": {
  303. /*
  304. URL mapping for the CDS Servlet
  305. */
  306. "cofaxCDS": "/",
  307. /*
  308. URL mapping for the Email Servlet
  309. */
  310. "cofaxEmail": "/cofaxutil/aemail/*",
  311. /*
  312. URL mapping for the Admin servlet
  313. */
  314. "cofaxAdmin": "/admin/*",
  315. /*
  316. URL mapping for the Files servlet
  317. */
  318. "fileServlet": "/static/*",
  319. "cofaxTools": "/tools/*"},
  320. /*
  321. New! The cofax taglib descriptor file
  322. */
  323. "taglib": {
  324. "taglib-uri": "cofax.tld",
  325. "taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
  326. """
  327. test5 = """
  328. {"menu": {
  329. "header": "SVG Viewer",
  330. "items": [
  331. {"id": "Open"},
  332. {"id": "OpenNew", "label": "Open New"},
  333. null,
  334. {"id": "ZoomIn", "label": "Zoom In"},
  335. {"id": "ZoomOut", "label": "Zoom Out"},
  336. {"id": "OriginalView", "label": "Original View"},
  337. null,
  338. {"id": "Quality"},
  339. {"id": "Pause"},
  340. {"id": "Mute"},
  341. null,
  342. {"id": "Find", "label": "Find..."},
  343. {"id": "FindAgain", "label": "Find Again"},
  344. {"id": "Copy"},
  345. {"id": "CopyAgain", "label": "Copy Again"},
  346. {"id": "CopySVG", "label": "Copy SVG"},
  347. {"id": "ViewSVG", "label": "View SVG"},
  348. {"id": "ViewSource", "label": "View Source"},
  349. {"id": "SaveAs", "label": "Save As"},
  350. null,
  351. {"id": "Help"},
  352. {"id": "About", "label": "About Adobe CVG Viewer..."}
  353. ]
  354. }}
  355. """