eJson tests initial import
This commit is contained in:
162
json_test/application.e
Normal file
162
json_test/application.e
Normal file
@@ -0,0 +1,162 @@
|
||||
indexing
|
||||
description : "System's root class"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make is
|
||||
-- Run application.
|
||||
do
|
||||
print ("JSON OBJECT%N")
|
||||
test_json_object
|
||||
|
||||
print ("%NJSON STRING%N")
|
||||
test_json_string
|
||||
|
||||
print ("%NJSON NUMBER%N")
|
||||
test_json_number
|
||||
|
||||
print ("%NJSON NULL%N")
|
||||
test_json_null
|
||||
|
||||
print ("%NJSON BOOLEAN%N")
|
||||
test_json_boolean
|
||||
|
||||
print ("%NJSON ARRAY%N")
|
||||
test_json_array
|
||||
|
||||
print ("%NJSON READER%N")
|
||||
test_json_reader
|
||||
|
||||
print ("%NJSON PARSER%N")
|
||||
test_json_parser
|
||||
|
||||
end
|
||||
|
||||
test_json_object is
|
||||
--
|
||||
local
|
||||
jo:JSON_OBJECT
|
||||
do
|
||||
create jo.make
|
||||
jo.put (create {JSON_STRING}.make_json("myKey"), create {JSON_STRING}.make_json ("MyValue"))
|
||||
print (jo.to_json)
|
||||
end
|
||||
|
||||
test_json_string is
|
||||
--
|
||||
local
|
||||
js:JSON_STRING
|
||||
do
|
||||
create js.make_json ("Json String example")
|
||||
print (js.to_json)
|
||||
end
|
||||
|
||||
test_json_number is
|
||||
--
|
||||
local
|
||||
jnr,jni:JSON_NUMBER
|
||||
do
|
||||
create jnr.make_real (12.3)
|
||||
print (jnr.to_json)
|
||||
print ("%N")
|
||||
create jni.make_integer (123)
|
||||
print (jni.to_json)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
test_json_null is
|
||||
--
|
||||
local
|
||||
jnull:JSON_NULL
|
||||
do
|
||||
|
||||
create jnull
|
||||
print (jnull.to_json)
|
||||
|
||||
end
|
||||
|
||||
test_json_boolean is
|
||||
--
|
||||
local
|
||||
jbt,jbf:JSON_BOOLEAN
|
||||
do
|
||||
create jbt.make_boolean (true)
|
||||
print (jbt.to_json)
|
||||
|
||||
print ("%N")
|
||||
create jbf.make_boolean (false)
|
||||
print (jbf.to_json)
|
||||
|
||||
end
|
||||
|
||||
|
||||
test_json_array is
|
||||
--
|
||||
local
|
||||
ja:JSON_ARRAY
|
||||
|
||||
jo: JSON_OBJECT
|
||||
do
|
||||
create ja.make_array
|
||||
ja.add (create{JSON_STRING}.make_json ("valor1"))
|
||||
ja.add (create{JSON_NUMBER}.make_integer (10))
|
||||
ja.add (create{JSON_NULL} )
|
||||
ja.add (create{JSON_BOOLEAN}.make_boolean (true))
|
||||
|
||||
create jo.make
|
||||
jo.put (create {JSON_STRING}.make_json("myKey"), create {JSON_STRING}.make_json ("MyValue"))
|
||||
|
||||
ja.add (jo)
|
||||
print (ja.to_json)
|
||||
|
||||
end
|
||||
|
||||
test_json_reader is
|
||||
--
|
||||
local
|
||||
jr:EXAMPLE_JSON_READER
|
||||
do
|
||||
create jr.make
|
||||
jr.test_create_reader
|
||||
end
|
||||
|
||||
test_json_parser is
|
||||
--
|
||||
local
|
||||
jp:EXAMPLE_JSON_PARSER
|
||||
do
|
||||
create jp
|
||||
print("%N ARRAY PARSING %N")
|
||||
jp.test_json_array
|
||||
|
||||
print("%N GLOSSATY PARSING %N")
|
||||
jp.test_json_glossary_from_file
|
||||
|
||||
print("%N NUMBER PARSING %N")
|
||||
jp.test_json_number
|
||||
|
||||
print("%N OBJECTS PARSING %N")
|
||||
jp.test_json_objects_with_string
|
||||
|
||||
print("%N STRING PARSING %N")
|
||||
jp.test_json_string
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end -- class APPLICATION
|
||||
22
json_test/json_glossary_example.txt
Normal file
22
json_test/json_glossary_example.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"glossary": {
|
||||
"title": "example glossary",
|
||||
"GlossDiv": {
|
||||
"title": "S",
|
||||
"GlossList": {
|
||||
"GlossEntry": {
|
||||
"ID": "SGML",
|
||||
"SortAs": "SGML",
|
||||
"GlossTerm": "Standard Generalized Markup Language",
|
||||
"Acronym": "SGML",
|
||||
"Abbrev": "ISO 8879:1986",
|
||||
"GlossDef": {
|
||||
"para": "A meta-markup language, used to create markup languages such as DocBook.",
|
||||
"GlossSeeAlso": ["GML", "XML"]
|
||||
},
|
||||
"GlossSee": "markup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
json_test/json_menu2_example.txt
Normal file
27
json_test/json_menu2_example.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
{"menu": {
|
||||
"header": "SVG Viewer",
|
||||
"items": [
|
||||
{"id": "Open"},
|
||||
{"id": "OpenNew", "label": "Open New"},
|
||||
null,
|
||||
{"id": "ZoomIn", "label": "Zoom In"},
|
||||
{"id": "ZoomOut", "label": "Zoom Out"},
|
||||
{"id": "OriginalView", "label": "Original View"},
|
||||
null,
|
||||
{"id": "Quality"},
|
||||
{"id": "Pause"},
|
||||
{"id": "Mute"},
|
||||
null,
|
||||
{"id": "Find", "label": "Find..."},
|
||||
{"id": "FindAgain", "label": "Find Again"},
|
||||
{"id": "Copy"},
|
||||
{"id": "CopyAgain", "label": "Copy Again"},
|
||||
{"id": "CopySVG", "label": "Copy SVG"},
|
||||
{"id": "ViewSVG", "label": "View SVG"},
|
||||
{"id": "ViewSource", "label": "View Source"},
|
||||
{"id": "SaveAs", "label": "Save As"},
|
||||
null,
|
||||
{"id": "Help"},
|
||||
{"id": "About", "label": "About Adobe CVG Viewer..."}
|
||||
]
|
||||
}}
|
||||
11
json_test/json_menu_example.txt
Normal file
11
json_test/json_menu_example.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
{"menu": {
|
||||
"id": "file",
|
||||
"value": "File",
|
||||
"popup": {
|
||||
"menuitem": [
|
||||
{"value": "New", "onclick": "CreateNewDoc()"},
|
||||
{"value": "Open", "onclick": "OpenDoc()"},
|
||||
{"value": "Close", "onclick": "CloseDoc()"}
|
||||
]
|
||||
}
|
||||
}}
|
||||
24
json_test/json_test.ecf
Normal file
24
json_test/json_test.ecf
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-3-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-3-0 http://www.eiffel.com/developers/xml/configuration-1-3-0.xsd" name="json_test" uuid="6184F667-395B-4211-8149-EC90F66A66B7">
|
||||
<target name="json_test">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<cdd extract="false" execute="true"/>
|
||||
<option warning="true">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<precompile name="base_pre" location="$ISE_PRECOMP\base.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="json" location="\home\jvelilla\work\eiffel_work\json\json.ecf"/>
|
||||
<cluster name="json_test" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/cdd_tests$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="json_test_dotnet" extends="json_test">
|
||||
<setting name="msil_generation" value="true"/>
|
||||
</target>
|
||||
</system>
|
||||
88
json_test/json_webxml_example.txt
Normal file
88
json_test/json_webxml_example.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
{"web-app": {
|
||||
"servlet": [
|
||||
{
|
||||
"servlet-name": "cofaxCDS",
|
||||
"servlet-class": "org.cofax.cds.CDSServlet",
|
||||
"init-param": {
|
||||
"configGlossary:installationAt": "Philadelphia, PA",
|
||||
"configGlossary:adminEmail": "ksm@pobox.com",
|
||||
"configGlossary:poweredBy": "Cofax",
|
||||
"configGlossary:poweredByIcon": "/images/cofax.gif",
|
||||
"configGlossary:staticPath": "/content/static",
|
||||
"templateProcessorClass": "org.cofax.WysiwygTemplate",
|
||||
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
|
||||
"templatePath": "templates",
|
||||
"templateOverridePath": "",
|
||||
"defaultListTemplate": "listTemplate.htm",
|
||||
"defaultFileTemplate": "articleTemplate.htm",
|
||||
"useJSP": false,
|
||||
"jspListTemplate": "listTemplate.jsp",
|
||||
"jspFileTemplate": "articleTemplate.jsp",
|
||||
"cachePackageTagsTrack": 200,
|
||||
"cachePackageTagsStore": 200,
|
||||
"cachePackageTagsRefresh": 60,
|
||||
"cacheTemplatesTrack": 100,
|
||||
"cacheTemplatesStore": 50,
|
||||
"cacheTemplatesRefresh": 15,
|
||||
"cachePagesTrack": 200,
|
||||
"cachePagesStore": 100,
|
||||
"cachePagesRefresh": 10,
|
||||
"cachePagesDirtyRead": 10,
|
||||
"searchEngineListTemplate": "forSearchEnginesList.htm",
|
||||
"searchEngineFileTemplate": "forSearchEngines.htm",
|
||||
"searchEngineRobotsDb": "WEB-INF/robots.db",
|
||||
"useDataStore": true,
|
||||
"dataStoreClass": "org.cofax.SqlDataStore",
|
||||
"redirectionClass": "org.cofax.SqlRedirection",
|
||||
"dataStoreName": "cofax",
|
||||
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
|
||||
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
|
||||
"dataStoreUser": "sa",
|
||||
"dataStorePassword": "dataStoreTestQuery",
|
||||
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
|
||||
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
|
||||
"dataStoreInitConns": 10,
|
||||
"dataStoreMaxConns": 100,
|
||||
"dataStoreConnUsageLimit": 100,
|
||||
"dataStoreLogLevel": "debug",
|
||||
"maxUrlLength": 500}},
|
||||
{
|
||||
"servlet-name": "cofaxEmail",
|
||||
"servlet-class": "org.cofax.cds.EmailServlet",
|
||||
"init-param": {
|
||||
"mailHost": "mail1",
|
||||
"mailHostOverride": "mail2"}},
|
||||
{
|
||||
"servlet-name": "cofaxAdmin",
|
||||
"servlet-class": "org.cofax.cds.AdminServlet"},
|
||||
|
||||
{
|
||||
"servlet-name": "fileServlet",
|
||||
"servlet-class": "org.cofax.cds.FileServlet"},
|
||||
{
|
||||
"servlet-name": "cofaxTools",
|
||||
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
|
||||
"init-param": {
|
||||
"templatePath": "toolstemplates/",
|
||||
"log": 1,
|
||||
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
|
||||
"logMaxSize": "",
|
||||
"dataLog": 1,
|
||||
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
|
||||
"dataLogMaxSize": "",
|
||||
"removePageCache": "/content/admin/remove?cache=pages&id=",
|
||||
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
|
||||
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
|
||||
"lookInContext": 1,
|
||||
"adminGroupID": 4,
|
||||
"betaServer": true}}],
|
||||
"servlet-mapping": {
|
||||
"cofaxCDS": "/",
|
||||
"cofaxEmail": "/cofaxutil/aemail/*",
|
||||
"cofaxAdmin": "/admin/*",
|
||||
"fileServlet": "/static/*",
|
||||
"cofaxTools": "/tools/*"},
|
||||
|
||||
"taglib": {
|
||||
"taglib-uri": "cofax.tld",
|
||||
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
|
||||
26
json_test/json_widget_example.txt
Normal file
26
json_test/json_widget_example.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
{"widget": {
|
||||
"debug": "on",
|
||||
"window": {
|
||||
"title": "Sample Konfabulator Widget",
|
||||
"name": "main_window",
|
||||
"width": 500,
|
||||
"height": 500
|
||||
},
|
||||
"image": {
|
||||
"src": "Images/Sun.png",
|
||||
"name": "sun1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 250,
|
||||
"alignment": "center"
|
||||
},
|
||||
"text": {
|
||||
"data": "Click Here",
|
||||
"size": 36,
|
||||
"style": "bold",
|
||||
"name": "text1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 100,
|
||||
"alignment": "center",
|
||||
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
|
||||
}
|
||||
}}
|
||||
160
json_test/test_json_parser.e
Normal file
160
json_test/test_json_parser.e
Normal file
@@ -0,0 +1,160 @@
|
||||
indexing
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EXAMPLE_JSON_PARSER
|
||||
|
||||
feature -- Access
|
||||
|
||||
test_json_string is
|
||||
--
|
||||
local
|
||||
parse_json:JSON_PARSER
|
||||
json_value:JSON_VALUE
|
||||
do
|
||||
create parse_json.make_parser("%"key %N This is a test %"")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
end
|
||||
|
||||
test_json_objects_with_string is
|
||||
--
|
||||
local
|
||||
parse_json:JSON_PARSER
|
||||
json_value:JSON_VALUE
|
||||
do
|
||||
create parse_json.make_parser("{}")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
create parse_json.make_parser("{%"key%":%"value%"}")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser("{%"key%" :%"value%"}")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser("{%"key%" : %"value%"}")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser("{%"key%" : %"value%" }")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser("{ %N%"key%" : %"value%" }")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser("{ %N%"key%" ; %"value%" }")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
end
|
||||
|
||||
test_json_array is
|
||||
--
|
||||
local
|
||||
parse_json:JSON_PARSER
|
||||
json_value:JSON_VALUE
|
||||
do
|
||||
create parse_json.make_parser ("[]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser ("[%"value%"]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
create parse_json.make_parser ("[%"value%",%"value2%"]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
--create parse_json.make_parser ("[%"value%";%"value2%"]")
|
||||
--json_value:=parse_json.parse
|
||||
--print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser ("[null]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
create parse_json.make_parser ("[false]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
create parse_json.make_parser ("[true]")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
end
|
||||
|
||||
test_json_number is
|
||||
--
|
||||
local
|
||||
parse_json:JSON_PARSER
|
||||
json_value:JSON_VALUE
|
||||
do
|
||||
create parse_json.make_parser ("1234.5")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
create parse_json.make_parser ("1234.e5")
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
end
|
||||
|
||||
test_json_glossary_from_file is
|
||||
--
|
||||
local
|
||||
file_reader:JSON_FILE_READER
|
||||
parse_json:JSON_PARSER
|
||||
json_value:JSON_VALUE
|
||||
|
||||
do
|
||||
|
||||
create file_reader
|
||||
create parse_json.make_parser (file_reader.read_json_from ("./json_glossary_example.txt"))
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
print ("%N JSON MENU %N")
|
||||
create parse_json.make_parser (file_reader.read_json_from ("./json_menu_example.txt"))
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
print ("%N JSON WIDGET %N")
|
||||
create parse_json.make_parser (file_reader.read_json_from ("./json_widget_example.txt"))
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
print ("%N JSON WEBXML %N")
|
||||
create parse_json.make_parser (file_reader.read_json_from ("./json_webxml_example.txt"))
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
print ("%N JSON MENU2 %N")
|
||||
create parse_json.make_parser (file_reader.read_json_from ("./json_menu2_example.txt"))
|
||||
json_value:=parse_json.parse
|
||||
print (json_value.to_json)
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
41
json_test/test_json_reader.e
Normal file
41
json_test/test_json_reader.e
Normal file
@@ -0,0 +1,41 @@
|
||||
indexing
|
||||
description: "Objects that ..."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EXAMPLE_JSON_READER
|
||||
|
||||
create
|
||||
make
|
||||
feature -- Access
|
||||
make is
|
||||
--
|
||||
do
|
||||
test_create_reader
|
||||
end
|
||||
|
||||
test_create_reader is
|
||||
--
|
||||
local
|
||||
reader:JSON_READER
|
||||
condition:BOOLEAN
|
||||
do
|
||||
create reader.make("{%"key%":%"value%"}")
|
||||
|
||||
from
|
||||
condition:=false
|
||||
until condition
|
||||
|
||||
loop
|
||||
if reader.has_next then
|
||||
print (reader.read)
|
||||
reader.next
|
||||
else
|
||||
condition:=true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user