Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vollt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sonia Zorba
vollt
Commits
3d22e42a
Commit
3d22e42a
authored
6 years ago
by
Grégory Mantelet
Browse files
Options
Downloads
Patches
Plain Diff
[UWS] JUnit test going with the commit
cb5cdd73
.
parent
0d3c7841
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/uws/service/backup/TestDefaultUWSBackupManager.java
+65
-0
65 additions, 0 deletions
test/uws/service/backup/TestDefaultUWSBackupManager.java
with
65 additions
and
0 deletions
test/uws/service/backup/TestDefaultUWSBackupManager.java
0 → 100644
+
65
−
0
View file @
3d22e42a
package
uws.service.backup
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.junit.Test
;
import
uws.job.jobInfo.JobInfo
;
import
uws.job.jobInfo.SingleValueJobInfo
;
public
class
TestDefaultUWSBackupManager
{
@Test
public
void
testBase64
(){
final
DefaultUWSBackupManager
backupManager
=
new
DefaultUWSBackupManager
(
null
);
// Encoding an empty bytes array => Empty string!
assertEquals
(
0
,
backupManager
.
toBase64
(
new
byte
[
0
]).
length
());
// Decoding an empty string => Empty bytes array!
assertEquals
(
0
,
backupManager
.
fromBase64
(
""
).
length
);
// Test encoding a simple string:
final
String
strToEncode
=
"Blabla to encore!!!"
;
final
String
expectedEncoding
=
"QmxhYmxhIHRvIGVuY29yZSEhIQ=="
;
final
String
encodedStr
=
backupManager
.
toBase64
(
strToEncode
.
getBytes
());
assertEquals
(
expectedEncoding
,
encodedStr
);
// Test decoding this string:
assertEquals
(
strToEncode
,
new
String
(
backupManager
.
fromBase64
(
encodedStr
)));
}
@Test
public
void
testBackupAndRestoreJobInfo
(){
final
DefaultUWSBackupManager
backupManager
=
new
DefaultUWSBackupManager
(
null
);
// Test encoding a simple JobInfo:
final
SingleValueJobInfo
jobInfo
=
new
SingleValueJobInfo
(
"ASuperName"
,
"A super blabla to encode..."
);
final
String
expectedJSON
=
"rO0ABXNyACJ1d3Muam9iLmpvYkluZm8uU2luZ2xlVmFsdWVKb2JJbmZvAAAAAAAAAAECAANMAARuYW1ldAASTGphdmEvbGFuZy9TdHJpbmc7TAAFdmFsdWVxAH4AAUwAEXhtbFJlcHJlc2VudGF0aW9ucQB+AAF4cHQACkFTdXBlck5hbWV0ABtBIHN1cGVyIGJsYWJsYSB0byBlbmNvZGUuLi50ADQ8QVN1cGVyTmFtZT5BIHN1cGVyIGJsYWJsYSB0byBlbmNvZGUuLi48L0FTdXBlck5hbWU+"
;
String
encodedJobInfo
=
null
;
try
{
encodedJobInfo
=
(
String
)
backupManager
.
getJSONJobInfo
(
jobInfo
);
assertEquals
(
expectedJSON
,
encodedJobInfo
);
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
fail
(
"Unexpected exception while encoding a JobInfo into a base-64 string! (see console for more details)"
);
}
// Test decoding this JobInfo:
JobInfo
decodedJobInfo
;
try
{
decodedJobInfo
=
backupManager
.
restoreJobInfo
(
encodedJobInfo
);
assertNotNull
(
decodedJobInfo
);
assertEquals
(
SingleValueJobInfo
.
class
,
decodedJobInfo
.
getClass
());
assertEquals
(
jobInfo
.
getName
(),
((
SingleValueJobInfo
)
decodedJobInfo
).
getName
());
assertEquals
(
jobInfo
.
getValue
(),
((
SingleValueJobInfo
)
decodedJobInfo
).
getValue
());
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
fail
(
"Unexpected exception while decoding a JobInfo from a base-64 string! (see console for more details)"
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment