Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
1e15fc95
Commit
1e15fc95
authored
9 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-1930: MonitoredIOStreamCopierTest fixed and more tests added.
SVN: 34031
parent
64149372
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/sourceTest/java/ch/systemsx/cisd/common/io/MonitoredIOStreamCopierTest.java
+41
-4
41 additions, 4 deletions
.../systemsx/cisd/common/io/MonitoredIOStreamCopierTest.java
with
41 additions
and
4 deletions
common/sourceTest/java/ch/systemsx/cisd/common/io/MonitoredIOStreamCopierTest.java
+
41
−
4
View file @
1e15fc95
...
...
@@ -56,9 +56,9 @@ public class MonitoredIOStreamCopierTest extends AssertJUnit
copier
.
close
();
assertEquals
(
"INFO: Reading statistics for input stream: 2.50 MB bytes in 3 chunks took 5sec. "
+
"Average speed: 489.95 KB/sec
, m
edian speed: 605.70 KB/sec.\n"
+
"Average speed: 489.95 KB/sec
. M
edian speed: 605.70 KB/sec.\n"
+
"INFO: Writing statistics for output stream: 2.50 MB bytes in 3 chunks took 11sec. "
+
"Average speed: 239.48 KB/sec
, m
edian speed: 280.21 KB/sec.\n"
,
logger
.
toString
());
+
"Average speed: 239.48 KB/sec
. M
edian speed: 280.21 KB/sec.\n"
,
logger
.
toString
());
}
@Test
...
...
@@ -76,11 +76,48 @@ public class MonitoredIOStreamCopierTest extends AssertJUnit
copier
.
close
();
assertEquals
(
"INFO: Reading statistics for input stream: 3.50 MB bytes in 4 chunks took 11sec. "
+
"Average speed: 328.05 KB/sec
, m
edian speed: 301.18 KB/sec.\n"
+
"Average speed: 328.05 KB/sec
. M
edian speed: 301.18 KB/sec.\n"
+
"INFO: Writing statistics for output stream: 3.50 MB bytes in 4 chunks took 18sec. "
+
"Average speed: 194.36 KB/sec, median speed: 150.81 KB/sec.\n"
,
logger
.
toString
());
+
"Average speed: 194.36 KB/sec. Median speed: 150.81 KB/sec.\n"
,
logger
.
toString
());
}
@Test
public
void
testCopyingWithChunksToSmallForMedianCalculation
()
{
MonitoredIOStreamCopier
copier
=
new
MonitoredIOStreamCopier
((
int
)
FileUtils
.
ONE_MB
);
ITimeProvider
timeProvider
=
new
MockTimeProvider
(
123456789
,
1125
,
0
,
2500
,
0
,
0
,
0
,
3400
,
0
,
6790
);
copier
.
setTimeProvider
(
timeProvider
);
MockLogger
logger
=
new
MockLogger
();
copier
.
setLogger
(
logger
);
copy
(
copier
,
(
int
)
(
0.5
*
FileUtils
.
ONE_MB
));
copy
(
copier
,
(
int
)
(
0.5
*
FileUtils
.
ONE_MB
));
copier
.
close
();
assertEquals
(
"INFO: Reading statistics for input stream: 1.00 MB bytes in 2 chunks took 5sec. "
+
"Average speed: 226.30 KB/sec.\n"
+
"INFO: Writing statistics for output stream: 1.00 MB bytes in 2 chunks took 9sec. "
+
"Average speed: 110.23 KB/sec.\n"
,
logger
.
toString
());
}
@Test
public
void
testCopyingWithChunksToSmallForAverageCalculation
()
{
MonitoredIOStreamCopier
copier
=
new
MonitoredIOStreamCopier
((
int
)
FileUtils
.
ONE_MB
);
ITimeProvider
timeProvider
=
new
MockTimeProvider
(
123456789
,
1125
,
0
,
2500
,
0
,
0
,
0
,
3400
,
0
,
6790
);
copier
.
setTimeProvider
(
timeProvider
);
MockLogger
logger
=
new
MockLogger
();
copier
.
setLogger
(
logger
);
copy
(
copier
,
(
int
)
(
0.25
*
FileUtils
.
ONE_MB
));
copy
(
copier
,
(
int
)
(
0.5
*
FileUtils
.
ONE_MB
));
copier
.
close
();
assertEquals
(
"INFO: Reading statistics for input stream: 768.00 KB bytes in 2 chunks took 5sec.\n"
+
"INFO: Writing statistics for output stream: 768.00 KB bytes in 2 chunks took 9sec.\n"
,
logger
.
toString
());
}
private
void
copy
(
MonitoredIOStreamCopier
copier
,
int
numberOfBytes
)
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
...
...
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