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
7dc260e3
Commit
7dc260e3
authored
12 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
BIS-329 SP-500 : Test accessing an expired url
SVN: 28404
parent
0fee7457
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
datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java
+45
-12
45 additions, 12 deletions
...storeserver/systemtests/JsonDssServiceRpcGenericTest.java
with
45 additions
and
12 deletions
datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java
+
45
−
12
View file @
7dc260e3
...
...
@@ -49,6 +49,8 @@ import ch.systemsx.cisd.openbis.generic.shared.util.TestInstanceHostUtils;
{
"slow"
})
public
class
JsonDssServiceRpcGenericTest
extends
SystemTestCase
{
private
static
final
String
DATA_SET_CODE
=
"20081105092159111-1"
;
private
static
final
String
OPENBIS_URL
=
TestInstanceHostUtils
.
getOpenBISUrl
()
+
IGeneralInformationService
.
JSON_SERVICE_URL
;
...
...
@@ -89,7 +91,7 @@ public class JsonDssServiceRpcGenericTest extends SystemTestCase
System
.
out
.
println
(
validationScript
);
FileInfoDssDTO
[]
result
=
dssRpcService
.
listFilesForDataSet
(
sessionToken
,
"20081105092159111-1"
,
""
,
true
);
dssRpcService
.
listFilesForDataSet
(
sessionToken
,
DATA_SET_CODE
,
""
,
true
);
for
(
FileInfoDssDTO
fileInfo
:
result
)
{
...
...
@@ -101,9 +103,27 @@ public class JsonDssServiceRpcGenericTest extends SystemTestCase
public
void
testGetDataSetContentsWithURL
()
throws
MalformedURLException
,
IOException
{
FileInfoDssDTO
fileInfoToDownload
=
getFileInfoToDownload
();
DataSetFileDTO
fileToDownload
=
new
DataSetFileDTO
(
DATA_SET_CODE
,
fileInfoToDownload
.
getPathInDataSet
(),
false
);
String
url
=
dssRpcService
.
getDownloadUrlForFileForDataSetWithTimeout
(
sessionToken
,
fileToDownload
,
-
1
);
// Download the data into a file
InputStream
input
=
new
URL
(
url
).
openStream
();
File
file
=
new
File
(
workingDirectory
,
"output"
);
FileOutputStream
output
=
new
FileOutputStream
(
file
);
IOUtils
.
copyLarge
(
input
,
output
);
assertEquals
(
file
.
length
(),
fileInfoToDownload
.
getFileSize
());
}
protected
FileInfoDssDTO
getFileInfoToDownload
()
{
FileInfoDssDTO
[]
result
=
dssRpcService
.
listFilesForDataSet
(
sessionToken
,
"20081105092159111-1"
,
""
,
true
);
assertTrue
(
"Did not find any files for the data set
20081105092159111-1"
,
result
.
length
>
0
);
dssRpcService
.
listFilesForDataSet
(
sessionToken
,
DATA_SET_CODE
,
""
,
true
);
assertTrue
(
"Did not find any files for the data set
"
+
DATA_SET_CODE
,
result
.
length
>
0
);
FileInfoDssDTO
fileInfoToDownload
=
null
;
for
(
FileInfoDssDTO
fileInfo
:
result
)
...
...
@@ -117,21 +137,34 @@ public class JsonDssServiceRpcGenericTest extends SystemTestCase
assertNotNull
(
"Could not find a file in the data set 20081105092159111-1 to download"
,
fileInfoToDownload
);
return
fileInfoToDownload
;
}
@Test
public
void
testGetDataSetContentsWithExpiredURL
()
throws
MalformedURLException
,
IOException
,
InterruptedException
{
FileInfoDssDTO
fileInfoToDownload
=
getFileInfoToDownload
();
@SuppressWarnings
(
"null"
)
DataSetFileDTO
fileToDownload
=
new
DataSetFileDTO
(
"20081105092159111-1"
,
fileInfoToDownload
.
getPathInDataSet
(),
false
);
new
DataSetFileDTO
(
DATA_SET_CODE
,
fileInfoToDownload
.
getPathInDataSet
(),
false
);
String
url
=
dssRpcService
.
getDownloadUrlForFileForDataSetWithTimeout
(
sessionToken
,
fileToDownload
,
-
1
);
fileToDownload
,
5
);
// Wait until the URL is invalid
Thread
.
sleep
(
6
*
1000L
);
// Download the data into a file
InputStream
input
=
new
URL
(
url
).
openStream
();
File
file
=
new
File
(
workingDirectory
,
"output"
);
FileOutputStream
output
=
new
FileOutputStream
(
file
);
IOUtils
.
copyLarge
(
input
,
output
);
assertEquals
(
file
.
length
(),
fileInfoToDownload
.
getFileSize
());
try
{
new
URL
(
url
).
openStream
();
fail
(
"An exception should have been thrown."
);
}
catch
(
IOException
e
)
{
assertTrue
(
e
.
getMessage
().
startsWith
(
"Server returned HTTP response code: 500"
));
}
}
public
static
IGeneralInformationService
createOpenbisService
()
...
...
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