Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
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
Service Desk
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
Verlässliche Systemsoftware
projects
osv
Commits
1e66b4eb
Commit
1e66b4eb
authored
11 years ago
by
Guy Zana
Browse files
Options
Downloads
Patches
Plain Diff
tests: make the TCPDownloadFile test a bit more stressful
now it downloads a ~200MB file and validating md5 on it.
parent
cc6ff2f9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/cli/com/cloudius/cli/tests/TCPDownloadFile.java
+58
-8
58 additions, 8 deletions
java/cli/com/cloudius/cli/tests/TCPDownloadFile.java
static/etc/hosts
+1
-1
1 addition, 1 deletion
static/etc/hosts
with
59 additions
and
9 deletions
java/cli/com/cloudius/cli/tests/TCPDownloadFile.java
+
58
−
8
View file @
1e66b4eb
package
com.cloudius.cli.tests
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.nio.channels.Channels
;
import
java.nio.channels.ReadableByteChannel
;
import
java.security.MessageDigest
;
import
com.cloudius.util.MD5
;
public
class
TCPDownloadFile
implements
Test
{
public
static
final
String
_url
=
"http://mirror.isoc.org.il/pub/fedora/releases/18/Fedora/x86_64/iso/Fedora-18-x86_64-netinst.iso"
;
public
static
final
int
_chunk_size
=
0x10000
;
public
static
final
String
_expected_md5
=
"227acebbc5392a4600349ae0c2d0ffcf"
;
@Override
public
boolean
run
()
{
try
{
URL
website
=
new
URL
(
"http://212.58.244.66/"
);
ReadableByteChannel
rbc
=
Channels
.
newChannel
(
website
.
openStream
());
FileOutputStream
fos
=
new
FileOutputStream
(
"/tmp/bbc.co.uk.html"
);
fos
.
getChannel
().
transferFrom
(
rbc
,
0
,
1
<<
24
);
fos
.
close
();
URL
url
=
new
URL
(
_url
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
int
rc
=
conn
.
getResponseCode
();
if
(
rc
!=
HttpURLConnection
.
HTTP_OK
)
{
System
.
out
.
format
(
"error: HTTP response code %d, not 200\n"
,
rc
);
return
(
false
);
}
int
totlen
=
conn
.
getContentLength
();
InputStream
is
=
conn
.
getInputStream
();
MessageDigest
m
=
MessageDigest
.
getInstance
(
"MD5"
);
m
.
reset
();
System
.
out
.
println
(
"Begining file download..."
);
int
bytes
=
0
;
int
total_bytes
=
0
;
byte
[]
buf
=
new
byte
[
_chunk_size
];
do
{
bytes
=
is
.
read
(
buf
);
total_bytes
+=
bytes
;
System
.
out
.
format
(
"\rDownloaded %.2f%%"
,
((
float
)
total_bytes
/
(
float
)
totlen
)*
100
);
if
(
bytes
>
0
)
{
m
.
update
(
buf
,
0
,
bytes
);
}
}
while
(
bytes
!=
-
1
);
System
.
out
.
println
(
"\nFinished downloading"
);
is
.
close
();
conn
.
disconnect
();
byte
[]
digest
=
m
.
digest
();
String
dl_md5
=
MD5
.
toHex
(
digest
);
System
.
out
.
format
(
"Downloaded md5: %s\n"
,
dl_md5
);
System
.
out
.
format
(
"Expected md5: %s\n"
,
_expected_md5
);
if
(!
dl_md5
.
equals
(
_expected_md5
))
{
System
.
out
.
println
(
"error: md5 does not match!"
);
return
(
false
);
}
else
{
System
.
out
.
println
(
"success: md5 match!"
);
}
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
return
(
false
);
}
return
(
true
);
}
...
...
This diff is collapsed.
Click to expand it.
static/etc/hosts
+
1
−
1
View file @
1e66b4eb
127.0.0.1 localhost osv.local
212.58.244.66 www.bbc.co.uk
192.115.211.70 mirror.isoc.org.il
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