Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
e74f4914
Commit
e74f4914
authored
May 04, 2012
by
Tristan Cavelier
Committed by
Sebastien Robin
May 18, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Job management.
parent
c96a5bc7
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
264 additions
and
46 deletions
+264
-46
jiotest/jiotests.js
jiotest/jiotests.js
+53
-19
jiotest/unhosted/jio.js
jiotest/unhosted/jio.js
+208
-24
jiotest/unhosted/jio.storage.js
jiotest/unhosted/jio.storage.js
+3
-3
No files found.
jiotest/jiotests.js
View file @
e74f4914
...
...
@@ -132,31 +132,62 @@ test ('All tests', function () {
module
(
'
Jio Job Managing
'
);
test
(
'
Add 2 same jobs
'
,
function
()
{
// Check possibilities when adding 2 same jobs.
test
(
'
Simple Job Elimination
'
,
function
()
{
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
o
.
f1
=
this
.
spy
();
o
.
f2
=
this
.
spy
()
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
dummy
'
},
{
'
ID
'
:
'
jiotests
'
});
id
=
o
.
jio
.
id
;
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f1
});
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
1
'
],
'
job creation
'
);
clock
.
tick
(
10
);
o
.
jio
.
removeDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
});
deepEqual
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
1
'
],
undefined
,
'
job elimination
'
);
});
test
(
'
Simple Job Replacement
'
,
function
()
{
// Test if the second job write over the first one
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
o
.
f1
=
this
.
spy
();
o
.
f2
=
this
.
spy
()
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
dummy
'
},
{
'
ID
'
:
'
jiotests
'
});
id
=
o
.
jio
.
id
;
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f1
});
clock
.
tick
(
10
);
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
});
deepEqual
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
1
'
].
date
,
10
,
'
The first job date have to be equal to the second job date.
'
);
clock
.
tick
(
500
);
ok
(
!
o
.
f1
.
calledOnce
,
'
no callback for the first save request
'
);
ok
(
o
.
f2
.
calledOnce
,
'
second callback is called once
'
);
o
.
jio
.
stop
();
clock
.
tick
(
-
10
);
});
test
(
'
Simple Job Waiting
'
,
function
()
{
// Test if the second job doesn't erase the first ongoing one
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
o
.
f3
=
this
.
spy
();
o
.
f4
=
this
.
spy
();
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
dummy
'
},
{
'
ID
'
:
'
jiotests
'
});
id
=
o
.
jio
.
id
;
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f3
});
clock
.
tick
(
200
);
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f4
});
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
]
&&
LocalOrCookieStorage
.
getItem
(
...
...
@@ -166,16 +197,15 @@ test ('Add 2 same jobs', function () {
'
jio/jobObject/
'
+
id
)[
'
2
'
].
status
===
'
wait
'
&&
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
&&
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobI
D
===
'
1
'
,
JSON
.
stringify
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobI
dArray
)
===
'
["1"]
'
,
'
The second job must be waiting for the first to end
'
);
clock
.
tick
(
500
);
ok
(
o
.
f3
.
calledOnce
,
'
first request passed
'
);
ok
(
o
.
f4
.
calledOnce
,
'
restore waiting job
'
);
o
.
jio
.
stop
();
});
test
(
'
Restore a previous waiting job
'
,
function
()
{
ok
(
false
,
'
not implemented yet
'
);
});
module
(
'
Jio LocalStorage
'
);
test
(
'
Check name availability
'
,
function
()
{
...
...
@@ -591,25 +621,29 @@ test ('Check name availability', function () {
};
// DummyStorageAllOK,OK
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallok
'
},{
'
type
'
:
'
dummyallok
'
}]},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllOK,OK : name available
'
,
true
);
o
.
jio
.
stop
();
// DummyStorageAllOK,Fail
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallok
'
},{
'
type
'
:
'
dummyallfail
'
}]},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllOK,Fail : name not available
'
,
false
);
o
.
jio
.
stop
();
// DummyStorageAllFail,OK
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallfail
'
},{
'
type
'
:
'
dummyallok
'
}]},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllFail,OK : name not available
'
,
false
);
o
.
jio
.
stop
();
// DummyStorageAllFail,Fail
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallfail
'
},{
'
type
'
:
'
dummyallfail
'
}]},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllFail,Fail : name not available
'
,
false
);
o
.
jio
.
stop
();
...
...
jiotest/unhosted/jio.js
View file @
e74f4914
This diff is collapsed.
Click to expand it.
jiotest/unhosted/jio.storage.js
View file @
e74f4914
...
...
@@ -713,6 +713,7 @@
////////////////////////////////////////////////////////////////////////////
// ReplicateStorage
ReplicateStorage
=
function
(
options
)
{
// TODO Add a tests that check if there is no duplicate storages.
this
.
queue
=
options
.
queue
;
this
.
id
=
null
;
this
.
length
=
options
.
storage
.
storageArray
.
length
;
...
...
@@ -750,7 +751,7 @@
job
.
callback
(
res
);
}
};
this
.
queue
.
createJob
(
newjob
);
this
.
queue
.
createJob
(
newjob
)
;
}
},
saveDocument
:
function
(
job
,
jobendcallback
)
{
...
...
@@ -768,7 +769,6 @@
// 'resultArray':Array} in the jobendcallback arguments.
// TODO
},
loadDocument
:
function
(
job
,
jobendcallback
)
{
// TODO
...
...
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