Class: WirisPlugin::TestImpl

Inherits:
Object
  • Object
show all
Extended by:
TestInterface
Includes:
Wiris
Defined in:
lib/com/wiris/plugin/impl/TestImpl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TestInterface

Test

Constructor Details

#initialize(plugin) ⇒ TestImpl

Returns a new instance of TestImpl.



16
17
18
19
# File 'lib/com/wiris/plugin/impl/TestImpl.rb', line 16

def initialize(plugin)
    super()
    self.plugin = plugin
end

Instance Attribute Details

#confObject

Returns the value of attribute conf.



15
16
17
# File 'lib/com/wiris/plugin/impl/TestImpl.rb', line 15

def conf
  @conf
end

#pluginObject

Returns the value of attribute plugin.



14
15
16
# File 'lib/com/wiris/plugin/impl/TestImpl.rb', line 14

def plugin
  @plugin
end

Instance Method Details

#createTableRow(testName, reportText, solutionLink, condition) ⇒ Object



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/com/wiris/plugin/impl/TestImpl.rb', line 169

def createTableRow(testName, reportText, solutionLink, condition)
    output = ""
    output += "<tr>"
    output += ("<td>" + testName) + "</td>"
    output += ("<td>" + reportText) + "</td>"
    output += "<td>"
    if condition
        output += "<span class=\"ok\">OK</span><br/>"
    else 
        output += "<span class=\"error\">ERROR</span><br/>"
    end
    output += "</td>"
    output += "</tr>\r\n"
    return output
end

#getTestPageObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/com/wiris/plugin/impl/TestImpl.rb', line 20

def getTestPage()
    random = "" + (Math::random()*9999).to_s
    mml = ("<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mrow><msqrt><mn>" + random) + "</mn></msqrt></mrow></math>"
    self.conf = self.plugin::getConfiguration()
    output = ""
    output += "<html><head>\r\n"
    output += "<title>MathType integration test page</title><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><style type=\"text/css\">/*<!--*/html {font-family: sans-serif;}h2 {margin-left: 1em;}h3 {margin-left: 2em;}p {margin-left: 3em;}p.concrete {margin-left: 4em;}.ok {font-weight: bold;color: #0c0;}.error {font-weight: bold;color: #f00;}/*-->*/</style><style type=\"text/css\">body{font-family: Arial;}span{font-weight: bold;}span.ok {color: #009900;}span.error {color: #dd0000;}table, th, td, tr {border: solid 1px #000000;border-collapse:collapse;padding: 5px;}th{background-color: #eeeeee;}img{border:none;}</style>\r\n"
    output += "<script src=\"../core/WIRISplugins.js?viewer=image\" ></script>\r\n"
    output += "</head><body><h1>MathType integration test page</h1>\r\n"
    output += "<table><tr><th>Test</th><th>Report</th><th>Status</th></tr>\r\n"
    testName = "MathType integration version"
    begin
    s = Storage::newResourceStorage("VERSION")::read()
    reportText = ("<b>" + s) + "</b>"
    solutionLink = ""
    condition = true
    end
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "Creating and storing data"
    solutionLink = ""
    param = PropertiesTools::newProperties()
    outp = PropertiesTools::newProperties()
    provider = @plugin::newGenericParamsProvider(param)
    imageUrl = self.plugin::newRender()::createImage(mml,provider,outp)
    reportText = ((("<a href=\"" + imageUrl) + "\" />") + imageUrl) + "</a>"
    condition = true
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "Retrieving data"
    solutionLink = ""
    if (self.conf::getProperty("wirispluginperformance","false") == "true")
        self.plugin::newRender()::showImage(nil,mml,provider)
        digest = self.plugin::newRender()::computeDigest(mml,provider::getRenderParameters(self.plugin::getConfiguration()))
        imageUrlJson = self.plugin::newRender()::showImageJson(digest,"en")
        imageJson = (JSon::decode(imageUrlJson))
        result = (imageJson::get("result"))
        content = (result::get("content"))
        if (self.conf::getProperty("wirisimageformat","svg") == "svg")
            reportText = (("<img src=\"" + "data:image/svg+xml;charset=utf8,") + UrlUtils::urlComponentEncode(content)) + "\" />"
        else 
            reportText = (("<img src=\'" + "data:image/png;base64,") + content) + "\' />"
        end
    else 
        reportText = ("<img src=\'" + imageUrl) + "\' />"
    end
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "JavaScript MathML filter"
    solutionLink = ""
    reportText = mml
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "Host platform"
    solutionLink = ""
    platform = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::HOST_PLATFORM,"failed")
    reportText = platform
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "Filter test"
    solutionLink = ""
    condition = true
    p = PropertiesTools::newProperties()
    PropertiesTools::setProperty(p,"savemode","safeXml")
    s2 = StringTools::replace(mml,"<",Std::fromCharCode(171))
    s2 = StringTools::replace(s2,">",Std::fromCharCode(187))
    s2 = StringTools::replace(s2,"\"",Std::fromCharCode(168))
    reportText = self.plugin::newTextService()::filter("square root: " + s2,p)
    output += createTableRow(testName,reportText,solutionLink,condition)
    testName = "Connecting to www.wiris.net"
    solutionLink = ""
    condition = true
    begin
    h = HttpImpl.new("http://www.wiris.net",nil)
    h::request(true)
    end
    reportText = "Checking if server is reachable"
    output += createTableRow(testName,reportText,solutionLink,condition)
    if Type::resolveClass("com.wiris.editor.services.PublicServices") != nil
        condition = true
        testName = "Testing integrated services"
        reportText = "WIRIS Services installed"
        solutionLink = ""
        output += createTableRow(testName,reportText,solutionLink,condition)
        isLicensed = self.plugin::isEditorLicensed()
        condition = false
        testName = "MathType license"
        reportText = "Checking MathType valid license"
        output += createTableRow(testName,reportText,solutionLink,isLicensed)
    else 
        reportText = "MathType services not installed"
    end
    debug = (self.plugin::getConfiguration()::getProperty(ConfigurationKeys::DEBUG,"false") == "true")
    if debug
        testName = "Font family"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::FONT_FAMILY,"")
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "Configuration file"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CONFIGURATION_PATH,"") + "\\configuration.ini"
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "Cache path"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CACHE_FOLDER,"")
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "Formula path"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::FORMULA_FOLDER,"")
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "Integration path"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::INTEGRATION_PATH,"")
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "Context path"
        solutionLink = ""
        condition = true
        reportText = self.plugin::getConfiguration()::getProperty(ConfigurationKeys::CONTEXT_PATH,"")
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "default-configuration.ini load"
        solutionLink = ""
        defaultConfiguration = Storage::newResourceStorage("default-configuration.ini")::read()
        condition = (defaultConfiguration != nil) && (defaultConfiguration::length() > 0)
        if condition
            reportText = "Length: " + defaultConfiguration::length().to_s
        else 
            reportText = "Not found!"
        end
        output += createTableRow(testName,reportText,solutionLink,condition)
        testName = "cas.png load"
        solutionLink = ""
        casPng = Storage::newResourceStorage("cas.png")::readBinary()
        casPngLength = 0
        if casPng != nil
            casPngLength = Bytes::ofData(casPng)::length()
            condition = casPngLength > 0
        else 
            condition = false
        end
        if condition
            reportText = "Length: " + casPngLength.to_s
        else 
            reportText = "Not found!"
        end
        output += createTableRow(testName,reportText,solutionLink,condition)
    end
    output += "<div id=\"haxe:trace\"></div>"
    return output
end