Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-file-service
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
VOSpace INAF
vospace-file-service
Commits
17f9beb3
Commit
17f9beb3
authored
3 years ago
by
nfcalabria
Browse files
Options
Downloads
Patches
Plain Diff
Fixed ArchiveServiceTest
parent
0c18894c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/java/it/inaf/ia2/transfer/service/ArchiveServiceTest.java
+15
-25
15 additions, 25 deletions
...java/it/inaf/ia2/transfer/service/ArchiveServiceTest.java
src/test/resources/test-data.sql
+8
-8
8 additions, 8 deletions
src/test/resources/test-data.sql
with
23 additions
and
33 deletions
src/test/java/it/inaf/ia2/transfer/service/ArchiveServiceTest.java
+
15
−
25
View file @
17f9beb3
...
...
@@ -109,6 +109,7 @@ public class ArchiveServiceTest {
});
}
@Test
public
void
testZipGeneration
()
throws
Exception
{
...
...
@@ -155,7 +156,6 @@ public class ArchiveServiceTest {
archiveService
.
createArchive
(
job
);
});
}
private
static
abstract
class
TestArchiveHandler
<
I
extends
InputStream
,
E
>
{
private
final
I
is
;
...
...
@@ -180,13 +180,13 @@ public class ArchiveServiceTest {
String
parent
=
"/path/to"
;
File
tmpParent
=
tmpDir
.
toPath
().
resolve
(
"test1"
).
toFile
();
File
file1
=
createFile
(
tmpParent
,
"
dir1/a/b/
file1"
);
File
file2
=
createFile
(
tmpParent
,
"
dir1/a/b/
file2"
);
File
file3
=
createFile
(
tmpParent
,
"
dir2/c/
file3"
);
File
file4
=
createFile
(
tmpParent
,
"
dir2/c/
file4"
);
File
file5
=
createFile
(
tmpParent
,
"
dir2/c/d/
file5"
);
File
file6
=
createFile
(
tmpParent
,
"file6"
);
File
file7
=
createFile
(
tmpParent
,
"portal-file"
);
File
file1
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file1"
);
File
file2
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file2"
);
File
file3
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file3"
);
File
file4
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file4"
);
File
file5
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file5"
);
File
file6
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
file6"
);
File
file7
=
createFile
(
tmpParent
,
"
2021/10/1/UUID-
portal-file"
);
ArchiveJob
job
=
new
ArchiveJob
();
job
.
setPrincipal
(
new
TokenPrincipal
(
"user1"
,
"token1"
));
...
...
@@ -258,7 +258,8 @@ public class ArchiveServiceTest {
private
FileInfo
addFileInfo
(
List
<
FileInfo
>
fileInfos
,
String
vosPath
,
File
file
)
{
FileInfo
fileInfo
=
new
FileInfo
();
fileInfo
.
setOsPath
(
file
.
getAbsolutePath
());
fileInfo
.
setActualBasePath
(
"/"
);
fileInfo
.
setFsPath
(
file
.
getAbsolutePath
());
fileInfo
.
setVirtualPath
(
vosPath
);
fileInfo
.
setVirtualName
(
vosPath
.
substring
(
vosPath
.
lastIndexOf
(
"/"
)
+
1
));
fileInfos
.
add
(
fileInfo
);
...
...
@@ -274,22 +275,11 @@ public class ArchiveServiceTest {
}
private
File
createFile
(
File
parent
,
String
path
)
throws
Exception
{
parent
.
mkdir
();
String
[]
files
=
path
.
split
(
"/"
);
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
File
file
=
parent
.
toPath
().
resolve
(
files
[
i
]).
toFile
();
if
(
i
==
files
.
length
-
1
)
{
// test os_path different from vos_path
file
.
renameTo
(
file
.
getParentFile
().
toPath
().
resolve
(
file
.
getName
()
+
"-renamed"
).
toFile
());
file
.
createNewFile
();
Files
.
write
(
file
.
toPath
(),
"some data"
.
getBytes
());
return
file
;
}
else
{
file
.
mkdir
();
parent
=
file
;
}
}
throw
new
IllegalStateException
(
"Files have to be created"
);
File
file
=
parent
.
toPath
().
resolve
(
path
).
toFile
();
file
.
getParentFile
().
mkdirs
();
file
.
createNewFile
();
Files
.
write
(
file
.
toPath
(),
"some data"
.
getBytes
());
return
file
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/test/resources/test-data.sql
+
8
−
8
View file @
17f9beb3
...
...
@@ -22,14 +22,14 @@ INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, gro
INSERT
INTO
node
(
parent_path
,
parent_relative_path
,
name
,
type
,
creator_id
,
group_read
,
group_write
,
location_id
)
VALUES
(
'2'
,
''
,
'file2.txt'
,
'data'
,
'user1'
,
'{"group1","group2"}'
,
'{"group2"}'
,
1
);
-- /test1/file2.txt
-- test data for tar/zip archive
INSERT
INTO
node
(
parent_path
,
parent_relative_path
,
name
,
type
,
creator_id
,
location_id
,
is_public
)
VALUES
(
''
,
NULL
,
'public'
,
'container'
,
'user1'
,
NULL
,
true
),
(
'5'
,
''
,
'file1'
,
'data'
,
'user1'
,
3
,
true
),
(
'5'
,
''
,
'file2'
,
'data'
,
'user1'
,
3
,
true
),
(
'5'
,
''
,
'subdir1'
,
'container'
,
'user1'
,
NULL
,
true
),
(
'5.8'
,
'8'
,
'file3'
,
'data'
,
'user1'
,
1
,
true
),
(
'5.8'
,
'8'
,
'file4'
,
'data'
,
'user1'
,
1
,
true
),
(
'5.8'
,
'8'
,
'portal-file'
,
'data'
,
'user1'
,
4
,
true
);
INSERT
INTO
node
(
parent_path
,
parent_relative_path
,
name
,
fs_path
,
type
,
creator_id
,
location_id
,
is_public
)
VALUES
(
''
,
NULL
,
'public'
,
NULL
,
'container'
,
'user1'
,
NULL
,
true
),
(
'5'
,
''
,
'file1'
,
'2021/9/30/file1-UUID'
,
'data'
,
'user1'
,
3
,
true
),
(
'5'
,
''
,
'file2'
,
'2021/9/30/file2-UUID'
,
'data'
,
'user1'
,
3
,
true
),
(
'5'
,
''
,
'subdir1'
,
NULL
,
'container'
,
'user1'
,
NULL
,
true
),
(
'5.8'
,
'8'
,
'file3'
,
'2021/9/30/file3-UUID'
,
'data'
,
'user1'
,
1
,
true
),
(
'5.8'
,
'8'
,
'file4'
,
'2021/9/30/file4-UUID'
,
'data'
,
'user1'
,
1
,
true
),
(
'5.8'
,
'8'
,
'portal-file'
,
NULL
,
'data'
,
'user1'
,
4
,
true
);
INSERT
INTO
node
(
parent_path
,
parent_relative_path
,
name
,
type
,
creator_id
,
content_length
,
quota
)
VALUES
(
''
,
NULL
,
'test_quota'
,
'container'
,
'user1'
,
0
,
900000
),
...
...
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