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
Hide 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 () {
...
@@ -132,31 +132,62 @@ test ('All tests', function () {
module
(
'
Jio Job Managing
'
);
module
(
'
Jio Job Managing
'
);
test
(
'
Add 2 same jobs
'
,
function
()
{
test
(
'
Simple Job Elimination
'
,
function
()
{
// Check possibilities when adding 2 same jobs.
var
o
=
{},
clock
=
this
.
sandbox
.
useFakeTimers
(),
id
=
0
;
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
// 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
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
dummy
'
},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
id
=
o
.
jio
.
id
;
id
=
o
.
jio
.
id
;
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f1
});
clock
.
tick
(
10
);
clock
.
tick
(
10
);
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f2
});
deepEqual
(
LocalOrCookieStorage
.
getItem
(
deepEqual
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
1
'
].
date
,
10
,
'
jio/jobObject/
'
+
id
)[
'
1
'
].
date
,
10
,
'
The first job date have to be equal to the second job date.
'
);
'
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
();
o
.
jio
.
stop
();
clock
.
tick
(
-
10
);
});
test
(
'
Simple Job Waiting
'
,
function
()
{
// Test if the second job doesn't erase the first ongoing one
// 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
'
},
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
dummy
'
},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
id
=
o
.
jio
.
id
;
id
=
o
.
jio
.
id
;
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f3
});
clock
.
tick
(
200
);
clock
.
tick
(
200
);
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
});
o
.
jio
.
saveDocument
({
'
fileName
'
:
'
file
'
,
'
fileContent
'
:
'
content
'
,
'
callback
'
:
o
.
f4
});
ok
(
LocalOrCookieStorage
.
getItem
(
ok
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
]
&&
'
jio/jobObject/
'
+
id
)[
'
2
'
]
&&
LocalOrCookieStorage
.
getItem
(
LocalOrCookieStorage
.
getItem
(
...
@@ -166,16 +197,15 @@ test ('Add 2 same jobs', function () {
...
@@ -166,16 +197,15 @@ test ('Add 2 same jobs', function () {
'
jio/jobObject/
'
+
id
)[
'
2
'
].
status
===
'
wait
'
&&
'
jio/jobObject/
'
+
id
)[
'
2
'
].
status
===
'
wait
'
&&
LocalOrCookieStorage
.
getItem
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
&&
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
&&
LocalOrCookieStorage
.
getItem
(
JSON
.
stringify
(
LocalOrCookieStorage
.
getItem
(
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobI
D
===
'
1
'
,
'
jio/jobObject/
'
+
id
)[
'
2
'
].
waitingFor
.
jobI
dArray
)
===
'
["1"]
'
,
'
The second job must be waiting for the first to end
'
);
'
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
();
o
.
jio
.
stop
();
});
});
test
(
'
Restore a previous waiting job
'
,
function
()
{
ok
(
false
,
'
not implemented yet
'
);
});
module
(
'
Jio LocalStorage
'
);
module
(
'
Jio LocalStorage
'
);
test
(
'
Check name availability
'
,
function
()
{
test
(
'
Check name availability
'
,
function
()
{
...
@@ -591,25 +621,29 @@ test ('Check name availability', function () {
...
@@ -591,25 +621,29 @@ test ('Check name availability', function () {
};
};
// DummyStorageAllOK,OK
// DummyStorageAllOK,OK
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallok
'
},{
'
type
'
:
'
dummyallok
'
}]},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllOK,OK : name available
'
,
true
);
mytest
(
'
DummyStoragesAllOK,OK : name available
'
,
true
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
// DummyStorageAllOK,Fail
// DummyStorageAllOK,Fail
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallok
'
},{
'
type
'
:
'
dummyallfail
'
}]},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllOK,Fail : name not available
'
,
false
);
mytest
(
'
DummyStoragesAllOK,Fail : name not available
'
,
false
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
// DummyStorageAllFail,OK
// DummyStorageAllFail,OK
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallfail
'
},{
'
type
'
:
'
dummyallok
'
}]},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallok
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllFail,OK : name not available
'
,
false
);
mytest
(
'
DummyStoragesAllFail,OK : name not available
'
,
false
);
o
.
jio
.
stop
();
o
.
jio
.
stop
();
// DummyStorageAllFail,Fail
// DummyStorageAllFail,Fail
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
o
.
jio
=
JIO
.
createNew
({
'
type
'
:
'
replicate
'
,
'
storageArray
'
:[
{
'
type
'
:
'
dummyallfail
'
},{
'
type
'
:
'
dummyallfail
'
}]},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
1
'
},
{
'
type
'
:
'
dummyallfail
'
,
'
userName
'
:
'
2
'
}]},
{
'
ID
'
:
'
jiotests
'
});
{
'
ID
'
:
'
jiotests
'
});
mytest
(
'
DummyStoragesAllFail,Fail : name not available
'
,
false
);
mytest
(
'
DummyStoragesAllFail,Fail : name not available
'
,
false
);
o
.
jio
.
stop
();
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 @@
...
@@ -713,6 +713,7 @@
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// ReplicateStorage
// ReplicateStorage
ReplicateStorage
=
function
(
options
)
{
ReplicateStorage
=
function
(
options
)
{
// TODO Add a tests that check if there is no duplicate storages.
this
.
queue
=
options
.
queue
;
this
.
queue
=
options
.
queue
;
this
.
id
=
null
;
this
.
id
=
null
;
this
.
length
=
options
.
storage
.
storageArray
.
length
;
this
.
length
=
options
.
storage
.
storageArray
.
length
;
...
@@ -750,7 +751,7 @@
...
@@ -750,7 +751,7 @@
job
.
callback
(
res
);
job
.
callback
(
res
);
}
}
};
};
this
.
queue
.
createJob
(
newjob
);
this
.
queue
.
createJob
(
newjob
)
;
}
}
},
},
saveDocument
:
function
(
job
,
jobendcallback
)
{
saveDocument
:
function
(
job
,
jobendcallback
)
{
...
@@ -766,9 +767,8 @@
...
@@ -766,9 +767,8 @@
// returns {'status':string,'message':string,'isSaved':boolean,
// returns {'status':string,'message':string,'isSaved':boolean,
// 'resultArray':Array} in the jobendcallback arguments.
// 'resultArray':Array} in the jobendcallback arguments.
// TODO
// TODO
},
},
loadDocument
:
function
(
job
,
jobendcallback
)
{
loadDocument
:
function
(
job
,
jobendcallback
)
{
// TODO
// 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