Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
jio
Commits
71f4dca9
Commit
71f4dca9
authored
Jun 07, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into queries
parents
921c87d1
bd7e841b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
685 additions
and
125 deletions
+685
-125
Makefile
Makefile
+4
-0
jio.js
jio.js
+1
-1
src/jio.storage/s3storage.js
src/jio.storage/s3storage.js
+10
-55
src/jio/jobs/jobRules.js
src/jio/jobs/jobRules.js
+1
-1
test/jiotests.js
test/jiotests.js
+602
-5
test/run-qunit.js
test/run-qunit.js
+67
-63
No files found.
Makefile
View file @
71f4dca9
...
@@ -56,6 +56,10 @@ uglify:
...
@@ -56,6 +56,10 @@ uglify:
lint
:
lint
:
$(LINT_CMD)
$(LINT_FILES)
$(LINT_CMD)
$(LINT_FILES)
phantom
:
~/node_modules/phantomjs/bin/phantomjs
test
/run-qunit.js
test
/jiotests_withoutrequirejs.html |
awk
'BEGIN {print "<!DOCTYPE html><html>"} /^<head>$$/, /^<\/body>$$/ {print} END {print "</html>"}'
|
sed
-e
's,^ *<\(/\|\)script.*>$$,,g'
>
test
/unit_test_result.html
grep
'^ <title>✔ '
test
/unit_test_result.html
>
/dev/null
.phony
:
clean
.phony
:
clean
clean
:
clean
:
find
-name
'*~'
-delete
find
-name
'*~'
-delete
...
...
jio.js
View file @
71f4dca9
...
@@ -2215,7 +2215,7 @@ var jobRules = (function () {
...
@@ -2215,7 +2215,7 @@ var jobRules = (function () {
that
.
sameAttachmentId
that
.
sameAttachmentId
],
that
.
wait
);
],
that
.
wait
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
remove
"
,
that
.
addActionRule
(
"
removeAttachment
"
,
"
remove
"
,
[
that
.
sameDocumentId
,
that
.
sameRevision
],
that
.
update
);
[
that
.
sameDocumentId
,
that
.
sameRevision
],
that
.
wait
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
that
.
sameDocument
],
that
.
update
);
[
that
.
sameDocument
],
that
.
update
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
...
...
src/jio.storage/s3storage.js
View file @
71f4dca9
...
@@ -15,8 +15,6 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -15,8 +15,6 @@ jIO.addStorageType("s3", function (spec, my) {
priv
.
AWSIdentifier
=
spec
.
AWSIdentifier
||
''
;
priv
.
AWSIdentifier
=
spec
.
AWSIdentifier
||
''
;
priv
.
password
=
spec
.
password
||
''
;
priv
.
password
=
spec
.
password
||
''
;
priv
.
server
=
spec
.
server
||
''
;
/*|| jiobucket ||*/
priv
.
server
=
spec
.
server
||
''
;
/*|| jiobucket ||*/
priv
.
url
=
spec
.
url
||
''
;
/*||> https://s3-eu-west-1.amazonaws.com <||*/
priv
.
acl
=
spec
.
acl
||
''
;
priv
.
acl
=
spec
.
acl
||
''
;
/*||> "private,
/*||> "private,
...
@@ -194,7 +192,6 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -194,7 +192,6 @@ jIO.addStorageType("s3", function (spec, my) {
return
{
return
{
"
username
"
:
priv
.
username
,
"
username
"
:
priv
.
username
,
"
password
"
:
priv
.
password
,
"
password
"
:
priv
.
password
,
"
url
"
:
priv
.
url
,
"
server
"
:
priv
.
server
,
"
server
"
:
priv
.
server
,
"
acl
"
:
priv
.
acl
"
acl
"
:
priv
.
acl
};
};
...
@@ -210,9 +207,6 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -210,9 +207,6 @@ jIO.addStorageType("s3", function (spec, my) {
if
(
typeof
priv
.
password
===
"
string
"
&&
priv
.
password
===
''
)
{
if
(
typeof
priv
.
password
===
"
string
"
&&
priv
.
password
===
''
)
{
return
'
Need at least one parameter "password".
'
;
return
'
Need at least one parameter "password".
'
;
}
}
if
(
typeof
priv
.
url
===
"
string
"
&&
priv
.
url
===
''
)
{
return
'
Need at least one parameter "url".
'
;
}
if
(
typeof
priv
.
server
===
"
string
"
&&
priv
.
server
===
''
)
{
if
(
typeof
priv
.
server
===
"
string
"
&&
priv
.
server
===
''
)
{
return
'
Need at least one parameter "server".
'
;
return
'
Need at least one parameter "server".
'
;
}
}
...
@@ -415,9 +409,7 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -415,9 +409,7 @@ jIO.addStorageType("s3", function (spec, my) {
doc
=
JSON
.
stringify
(
doc
);
doc
=
JSON
.
stringify
(
doc
);
break
;
break
;
case
"
update
"
:
case
"
update
"
:
console
.
log
(
doc
.
_attachments
);
doc
.
_attachments
[
attachid
]
=
data
;
doc
.
_attachments
[
attachid
]
=
data
;
console
.
log
(
doc
.
_attachments
);
//update happened in the put request
//update happened in the put request
doc
=
JSON
.
stringify
(
doc
);
doc
=
JSON
.
stringify
(
doc
);
break
;
break
;
...
@@ -529,7 +521,7 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -529,7 +521,7 @@ jIO.addStorageType("s3", function (spec, my) {
**/
**/
that
.
post
=
function
(
command
)
{
that
.
post
=
function
(
command
)
{
//as S3 encoding key are directly inserted within the FormData(),
//as S3 encoding key are directly inserted within the FormData(),
//use of XHRwrapper function ain't pertinent
//use of XHRwrapper function ain't pertinent
var
doc
,
doc_id
,
mime
;
var
doc
,
doc_id
,
mime
;
...
@@ -539,7 +531,7 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -539,7 +531,7 @@ jIO.addStorageType("s3", function (spec, my) {
function
postDocument
()
{
function
postDocument
()
{
var
http_response
,
fd
,
Signature
,
xhr
;
var
http_response
,
fd
,
Signature
,
xhr
;
doc_id
=
priv
.
secureName
(
priv
.
idsToFileName
(
doc_id
));
doc_id
=
priv
.
secureName
(
priv
.
idsToFileName
(
doc_id
));
//Meant to deep-serialize in order to avoid
//Meant to deep-serialize in order to avoid
//conflicts due to the multipart enctype
//conflicts due to the multipart enctype
doc
=
JSON
.
stringify
(
doc
);
doc
=
JSON
.
stringify
(
doc
);
http_response
=
''
;
http_response
=
''
;
...
@@ -872,9 +864,12 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -872,9 +864,12 @@ jIO.addStorageType("s3", function (spec, my) {
requestUTC
,
requestUTC
,
parse
,
parse
,
checkCounter
;
checkCounter
;
keys
=
$
(
mon_document
).
find
(
'
Key
'
);
keys
=
$
(
mon_document
).
find
(
'
Key
'
);
resultTable
=
[];
resultTable
=
[];
counter
=
0
;
counter
=
0
;
keys
.
each
(
function
(
index
)
{
keys
.
each
(
function
(
index
)
{
var
that
,
filename
,
docId
;
var
that
,
filename
,
docId
;
that
=
$
(
this
);
that
=
$
(
this
);
...
@@ -899,6 +894,7 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -899,6 +894,7 @@ jIO.addStorageType("s3", function (spec, my) {
//needed to save the index within the $.ajax.success() callback
//needed to save the index within the $.ajax.success() callback
count
=
resultTable
.
length
-
1
;
count
=
resultTable
.
length
-
1
;
countB
=
0
;
countB
=
0
;
dealCallback
=
function
(
i
,
countB
,
allDoc
)
{
dealCallback
=
function
(
i
,
countB
,
allDoc
)
{
return
function
(
doc
,
statustext
,
response
)
{
return
function
(
doc
,
statustext
,
response
)
{
allDoc
.
rows
[
i
].
doc
=
response
.
responseText
;
allDoc
.
rows
[
i
].
doc
=
response
.
responseText
;
...
@@ -925,13 +921,16 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -925,13 +921,16 @@ jIO.addStorageType("s3", function (spec, my) {
};
};
i
=
resultTable
.
length
-
1
;
i
=
resultTable
.
length
-
1
;
if
(
command
.
getOption
(
"
include_docs
"
)
===
true
)
{
if
(
command
.
getOption
(
"
include_docs
"
)
===
true
)
{
for
(
i
;
i
>=
0
;
i
-=
1
)
{
for
(
i
;
i
>=
0
;
i
-=
1
)
{
keyId
=
resultTable
[
i
];
keyId
=
resultTable
[
i
];
Signature
=
that
.
encodeAuthorization
(
keyId
);
Signature
=
that
.
encodeAuthorization
(
keyId
);
callURL
=
priv
.
url
+
keyId
;
callURL
=
'
http://
'
+
priv
.
server
+
'
.s3.amazonaws.com/
'
+
keyId
;
requestUTC
=
new
Date
().
toUTCString
();
requestUTC
=
new
Date
().
toUTCString
();
parse
=
true
;
parse
=
true
;
allDocResponse
.
rows
[
i
]
=
{
allDocResponse
.
rows
[
i
]
=
{
"
id
"
:
priv
.
fileNameToIds
(
keyId
).
join
(),
"
id
"
:
priv
.
fileNameToIds
(
keyId
).
join
(),
"
key
"
:
keyId
,
"
key
"
:
keyId
,
...
@@ -950,7 +949,6 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -950,7 +949,6 @@ jIO.addStorageType("s3", function (spec, my) {
+
priv
.
AWSIdentifier
+
priv
.
AWSIdentifier
+
"
:
"
+
"
:
"
+
Signature
,
+
Signature
,
//'Host' : priv.url,
'
x-amz-date
'
:
requestUTC
,
'
x-amz-date
'
:
requestUTC
,
'
Content-Type
'
:
'
application/json
'
'
Content-Type
'
:
'
application/json
'
//'Content-MD5' : ''
//'Content-MD5' : ''
...
@@ -991,46 +989,3 @@ jIO.addStorageType("s3", function (spec, my) {
...
@@ -991,46 +989,3 @@ jIO.addStorageType("s3", function (spec, my) {
};
};
return
that
;
return
that
;
});
});
/*
// It is not possible to attach listeners to xhr level 2 events
// AND validate the Qunit tests through sinon.js
// therefore, below methods are deprecated
var S3specifics = {};
S3specifics.uploadProgress = function(evt){
if (evt.lengthComputable) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
console.log(percentComplete.toString() + '%');
} else {
console.log('Unable to compute.');
}
};
S3specifics.uploadComplete = function(evt){
var evt_txt = evt.target.responseText;
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(evt_txt, "text/xml");
var responseURL = $(xmlDoc.getElementsByTagName('Location'))[0].text();
console.log(responseURL);
};
S3specifics.uploadFailed = function(evt){
var evt_txt = evt.target.responseText;
console.log("Erreur lors de la tentative d'upload : " + evt_txt);
};
S3specifics.uploadCanceled = function(evt){
console.log("Upload annulé par l'utilisateur ou le navigateur.");
};
S3specifics.onReadyStateChange = function(req, those, that) {
if (req.readyState === 4 && those.status === 200){
that.success({
ok: true,
id: command.getDocId()
});
}
};
*/
src/jio/jobs/jobRules.js
View file @
71f4dca9
...
@@ -326,7 +326,7 @@ var jobRules = (function () {
...
@@ -326,7 +326,7 @@ var jobRules = (function () {
that
.
sameAttachmentId
that
.
sameAttachmentId
],
that
.
wait
);
],
that
.
wait
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
remove
"
,
that
.
addActionRule
(
"
removeAttachment
"
,
"
remove
"
,
[
that
.
sameDocumentId
,
that
.
sameRevision
],
that
.
update
);
[
that
.
sameDocumentId
,
that
.
sameRevision
],
that
.
wait
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
that
.
sameDocument
],
that
.
update
);
[
that
.
sameDocument
],
that
.
update
);
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
that
.
addActionRule
(
"
removeAttachment
"
,
"
removeAttachment
"
,
[
...
...
test/jiotests.js
View file @
71f4dca9
This diff is collapsed.
Click to expand it.
test/run-qunit.js
View file @
71f4dca9
/*jslint indent: 2, maxlen: 80 */
/*global require: true, phantom: true, document: true */
"
use strict
"
;
var
system
=
require
(
'
system
'
);
var
system
=
require
(
'
system
'
);
/**
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
*
* @param testFx javascript condition that evaluates to a boolean,
* @method waitFor
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* @param {Function} testFx Condition that evaluates to a boolean
* as a callback function.
* @param {Function} onReady What to do when testFx condition is fulfilled
* @param onReady what to do when testFx condition is fulfilled,
* @param {Number} time_out_millis The max amount of time to wait.
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* If not specified, 10 sec is used.
* as a callback function.
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
*/
*/
function
waitFor
(
testFx
,
onReady
,
timeOutMillis
)
{
function
waitFor
(
testFx
,
onReady
,
time_out_millis
)
{
var
maxtimeOutMillis
=
timeOutMillis
?
timeOutMillis
:
3001
,
//< Default Max Timout is 3s
var
maxtime_out_millis
,
start
,
condition
,
interval
;
start
=
new
Date
().
getTime
(),
maxtime_out_millis
=
time_out_millis
||
10001
;
condition
=
false
,
start
=
new
Date
().
getTime
();
interval
=
setInterval
(
function
()
{
condition
=
false
;
if
(
(
new
Date
().
getTime
()
-
start
<
maxtimeOutMillis
)
&&
!
condition
)
{
interval
=
setInterval
(
function
()
{
// If not time-out yet and condition not yet fulfilled
if
((
new
Date
().
getTime
()
-
start
<
maxtime_out_millis
)
&&
!
condition
)
{
condition
=
(
typeof
(
testFx
)
===
"
string
"
?
eval
(
testFx
)
:
testFx
());
//< defensive code
// If not time-out yet and condition not yet fulfilled
}
else
{
condition
=
testFx
();
if
(
!
condition
)
{
}
else
{
// If condition still not fulfilled (timeout but condition is 'false')
if
(
!
condition
)
{
console
.
log
(
"
'waitFor()' timeout
"
);
// If condition still not fulfilled (timeout but condition is 'false')
phantom
.
exit
(
1
);
console
.
log
(
"
'waitFor()' timeout
"
);
}
else
{
phantom
.
exit
(
1
);
// Condition fulfilled (timeout and/or condition is 'true')
}
else
{
console
.
log
(
"
'waitFor()' finished in
"
+
(
new
Date
().
getTime
()
-
start
)
+
"
ms.
"
);
// Condition fulfilled (timeout and/or condition is 'true')
typeof
(
onReady
)
===
"
string
"
?
eval
(
onReady
)
:
onReady
();
//< Do what it's supposed to do once the condition is fulfilled
console
.
log
(
"
'waitFor()' finished in
"
+
clearInterval
(
interval
);
//< Stop this interval
(
new
Date
().
getTime
()
-
start
)
+
"
ms.
"
);
}
onReady
();
}
clearInterval
(
interval
);
//< Stop this interval
},
100
);
//< repeat check every 250ms
}
};
}
},
100
);
//< repeat check every 100ms
}
if
(
system
.
args
.
length
!==
2
)
{
if
(
system
.
args
.
length
!==
2
)
{
console
.
log
(
'
Usage: run-qunit.js URL
'
);
console
.
log
(
'
Usage: run-qunit.js URL
'
);
phantom
.
exit
(
1
);
phantom
.
exit
(
1
);
}
}
var
page
=
require
(
'
webpage
'
).
create
();
var
page
=
require
(
'
webpage
'
).
create
();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
// Route "console.log()" calls from within the Page context to the main Phantom
page
.
onConsoleMessage
=
function
(
msg
)
{
// context (i.e. current "this")
console
.
log
(
msg
);
page
.
onConsoleMessage
=
function
(
msg
)
{
console
.
log
(
msg
);
};
};
page
.
open
(
system
.
args
[
1
],
function
(
status
){
page
.
open
(
system
.
args
[
1
],
function
(
status
)
{
if
(
status
!==
"
success
"
)
{
if
(
status
!==
"
success
"
)
{
console
.
log
(
"
Unable to access network
"
);
console
.
log
(
"
Unable to access network
"
);
phantom
.
exit
(
1
);
phantom
.
exit
(
1
);
}
else
{
}
waitFor
(
function
(){
waitFor
(
function
()
{
return
page
.
evaluate
(
function
(){
return
page
.
evaluate
(
function
()
{
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
if
(
el
&&
el
.
innerText
.
match
(
'
completed
'
))
{
if
(
el
&&
el
.
innerText
.
match
(
'
completed
'
))
{
return
true
;
return
true
;
}
}
return
false
;
return
false
;
});
});
},
function
(){
},
function
()
{
var
failedNum
=
page
.
evaluate
(
function
(){
var
failedNum
=
page
.
evaluate
(
function
()
{
console
.
log
(
"
========================================================
"
)
console
.
log
(
"
========================================================
"
);
console
.
log
(
document
.
documentElement
.
innerHTML
);
console
.
log
(
document
.
documentElement
.
innerHTML
);
console
.
log
(
"
========================================================
"
)
console
.
log
(
"
========================================================
"
);
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
console
.
log
(
el
.
innerText
);
console
.
log
(
el
.
innerText
);
try
{
try
{
return
el
.
getElementsByClassName
(
'
failed
'
)[
0
].
innerHTML
;
return
el
.
getElementsByClassName
(
'
failed
'
)[
0
].
innerHTML
;
}
catch
(
e
)
{
}
}
catch
(
e
)
{
}
return
10000
;
return
10000
;
});
});
phantom
.
exit
((
parseInt
(
failedNum
,
10
)
>
0
)
?
1
:
0
);
phantom
.
exit
((
parseInt
(
failedNum
,
10
)
>
0
)
?
1
:
0
);
});
});
}
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment