1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
var TestApp = {
serverUrl:
'http://localhost:8080'
//'http://fjson/cgi-bin/fossil-json.cgi'
//'http://192.168.1.62:8080'
,
verbose:true
};
(function bootstrap() {
var srcdir = '../js/';
var includes = [srcdir+'json2.js',
srcdir+'whajaj.js',
srcdir+'fossil-ajaj.js'
];
for( var i in includes ) {
load(includes[i]);
}
WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino;
TestApp.fossil = new FossilAjaj({
asynchronous:false, /* rhino-based impl doesn't support asynch. */
url:TestApp.serverUrl,
beforeSend:function(req,opt){
if(!TestApp.verbose) return;
print("SENDING REQUEST: opt="+JSON.stringify(opt));
if(req) print("Request="+WhAjaj.stringify(req));
},
afterSend:function(req,opt){
if(!TestApp.verbose) return;
print("SENT REQUEST: opt="+JSON.stringify(opt));
if(req) print("Request="+WhAjaj.stringify(req));
},
onError:function(req,opt){
if(!TestApp.verbose) return;
print("ERROR: "+WhAjaj.stringify(opt));
},
onResponse:function(resp,req){
if(!TestApp.verbose) return;
|
|
>
|
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
var TestApp = {
serverUrl:
'http://localhost:8080'
//'http://fjson/cgi-bin/fossil-json.cgi'
//'http://192.168.1.62:8080'
,
verbose:true,
wiki:{}
};
(function bootstrap() {
var srcdir = '../js/';
var includes = [srcdir+'json2.js',
srcdir+'whajaj.js',
srcdir+'fossil-ajaj.js'
];
for( var i in includes ) {
load(includes[i]);
}
WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino;
TestApp.fossil = new FossilAjaj({
asynchronous:false, /* rhino-based impl doesn't support asynch. */
url:TestApp.serverUrl,
beforeSend:function(req,opt){
if(!TestApp.verbose) return;
print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt));
if(req) print("Request envelope="+WhAjaj.stringify(req));
},
afterSend:function(req,opt){
//if(!TestApp.verbose) return;
//print("REQUEST RETURNED: opt="+JSON.stringify(opt));
//if(req) print("Request="+WhAjaj.stringify(req));
},
onError:function(req,opt){
if(!TestApp.verbose) return;
print("ERROR: "+WhAjaj.stringify(opt));
},
onResponse:function(resp,req){
if(!TestApp.verbose) return;
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
function testAnonymousLogin(){
TestApp.fossil.login();
assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken);
assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName);
}
testAnonymousLogin.description = 'Perform anonymous login.';
(function runAllTests(){
var testList = [
testHAI,
testIAmNobody,
testAnonymousLogin
];
var i, f;
for( i = 0; i < testList.length; ++i ){
f = testList[i];
try{
print("Running #"+(i+1)+": "+(f.description || "no description."));
f();
|
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|
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
169
|
function testAnonymousLogin(){
TestApp.fossil.login();
assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken);
assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName);
}
testAnonymousLogin.description = 'Perform anonymous login.';
function testAnonWikiList(){
TestApp.fossil.sendCommand('/json/wiki/list',undefined,{
beforeSend:function(req,opt){
TestApp.fossil.ajaj.options.beforeSend(req,opt);
assert( req && (req.authToken==TestApp.fossil.authToken) );
},
onResponse:function(resp,req){
assertResponseOK(resp);
assert( (typeof [] === typeof resp.payload) && resp.payload.length,
"Wiki list seems to be okay.");
TestApp.wiki.list = resp.payload;
}
});
}
testAnonWikiList.description = 'Fetch wiki list as anonymous uses.';
function testAnonLogout(){
TestApp.fossil.logout({
onResponse:function(resp,req){
assertResponseOK(resp);
}
});
TestApp.fossil.logout({
onResponse:function(resp,req){
assertResponseError(resp);
}
});
}
testAnonLogout.description = 'Fetch wiki list as anonymous uses.';
(function runAllTests(){
var testList = [
testHAI,
testIAmNobody,
testAnonymousLogin,
testAnonWikiList,
testAnonLogout
];
var i, f;
for( i = 0; i < testList.length; ++i ){
f = testList[i];
try{
print("Running #"+(i+1)+": "+(f.description || "no description."));
f();
|