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
3d6d4f21
Commit
3d6d4f21
authored
13 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-1586] refactored common code in test
SVN: 20981
parent
8c133ffd
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
common/sourceTest/java/ch/systemsx/cisd/common/io/DefaultFileBasedHierarchicalContentTest.java
+30
-52
30 additions, 52 deletions
...sd/common/io/DefaultFileBasedHierarchicalContentTest.java
with
30 additions
and
52 deletions
common/sourceTest/java/ch/systemsx/cisd/common/io/DefaultFileBasedHierarchicalContentTest.java
+
30
−
52
View file @
3d6d4f21
...
@@ -191,15 +191,8 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -191,15 +191,8 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
public
void
testGetRootNode
()
public
void
testGetRootNode
()
{
{
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
prepareCreateRootNode
(
rootContent
);
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it twice
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
IHierarchicalContentNode
root1
=
rootContent
.
getRootNode
();
IHierarchicalContentNode
root1
=
rootContent
.
getRootNode
();
assertSame
(
rootDir
,
root1
.
getFile
());
assertSame
(
rootDir
,
root1
.
getFile
());
IHierarchicalContentNode
root2
=
rootContent
.
getRootNode
();
IHierarchicalContentNode
root2
=
rootContent
.
getRootNode
();
...
@@ -212,15 +205,8 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -212,15 +205,8 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
public
void
testGetNodeWithBlankPath
()
public
void
testGetNodeWithBlankPath
()
{
{
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
prepareCreateRootNode
(
rootContent
);
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it twice
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
IHierarchicalContentNode
rootNode
=
rootContent
.
getRootNode
();
IHierarchicalContentNode
rootNode
=
rootContent
.
getRootNode
();
IHierarchicalContentNode
nullNode
=
rootContent
.
getNode
(
null
);
IHierarchicalContentNode
nullNode
=
rootContent
.
getNode
(
null
);
IHierarchicalContentNode
emptyNode
=
rootContent
.
getNode
(
""
);
IHierarchicalContentNode
emptyNode
=
rootContent
.
getNode
(
""
);
...
@@ -272,16 +258,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -272,16 +258,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
createHDF5Container
(
subContainerDir
,
subDir
);
createHDF5Container
(
subContainerDir
,
subDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
prepareCreateRootNode
(
rootContent
);
// access to root dir is needed to get relative path of a file inside container
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it many times
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
final
List
<
File
>
subDirFiles
=
Arrays
.
asList
(
subFile1
,
subFile2
,
subFile3
,
subSubFile
);
final
List
<
File
>
subDirFiles
=
Arrays
.
asList
(
subFile1
,
subFile2
,
subFile3
,
subSubFile
);
for
(
File
subDirFile
:
subDirFiles
)
for
(
File
subDirFile
:
subDirFiles
)
...
@@ -330,15 +307,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -330,15 +307,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
public
void
testListMatchingNodesWithRelativePathPattern
()
public
void
testListMatchingNodesWithRelativePathPattern
()
{
{
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
prepareCreateRootNode
(
rootContent
);
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it many times
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
// nothing matches
// nothing matches
assertEquals
(
0
,
rootContent
.
listMatchingNodes
(
".*non-mathching-pattern.*"
).
size
());
assertEquals
(
0
,
rootContent
.
listMatchingNodes
(
".*non-mathching-pattern.*"
).
size
());
...
@@ -388,14 +357,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -388,14 +357,7 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
public
void
testListMatchingNodesWithStartingPath
()
public
void
testListMatchingNodesWithStartingPath
()
{
{
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
prepareCreateNode
(
rootContent
,
subDir
);
context
.
checking
(
new
Expectations
()
{
{
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
subDir
);
will
(
returnValue
(
createDummyFileBasedNode
(
rootDir
,
subDir
)));
}
});
List
<
IHierarchicalContentNode
>
matchingNodes
=
List
<
IHierarchicalContentNode
>
matchingNodes
=
rootContent
.
listMatchingNodes
(
"subDir"
,
".*[fF]ile.*"
);
rootContent
.
listMatchingNodes
(
"subDir"
,
".*[fF]ile.*"
);
...
@@ -419,15 +381,6 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -419,15 +381,6 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
final
DefaultFileBasedHierarchicalContent
rootContent
=
createContent
(
rootDir
);
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it many times
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
final
String
relativePath
=
FileUtilities
.
getRelativeFile
(
rootDir
,
subSubDir
);
final
String
relativePath
=
FileUtilities
.
getRelativeFile
(
rootDir
,
subSubDir
);
final
String
containerRelativePath
=
final
String
containerRelativePath
=
relativePath
.
replace
(
subDir
.
getName
(),
subContainerDir
.
getName
());
relativePath
.
replace
(
subDir
.
getName
(),
subContainerDir
.
getName
());
...
@@ -457,6 +410,31 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
...
@@ -457,6 +410,31 @@ public class DefaultFileBasedHierarchicalContentTest extends AbstractFileSystemT
context
.
assertIsSatisfied
();
context
.
assertIsSatisfied
();
}
}
private
void
prepareCreateNode
(
final
DefaultFileBasedHierarchicalContent
rootContent
,
final
File
file
)
{
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it many times
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
file
);
will
(
returnValue
(
createDummyFileBasedNode
(
rootDir
,
file
)));
}
});
}
private
void
prepareCreateRootNode
(
final
DefaultFileBasedHierarchicalContent
rootContent
)
{
context
.
checking
(
new
Expectations
()
{
{
// root node should be created only once even though we access it many times
one
(
hierarchicalContentFactory
).
asHierarchicalContentNode
(
rootContent
,
rootDir
);
will
(
returnValue
(
createDummyFileBasedRootNode
(
rootDir
)));
}
});
}
private
static
String
METHOD_NOT_IMPLEMENTED
=
"method not implemented in dummy node"
;
private
static
String
METHOD_NOT_IMPLEMENTED
=
"method not implemented in dummy node"
;
private
static
void
checkNodeMatchesFile
(
IHierarchicalContentNode
node
,
File
expectedFile
)
private
static
void
checkNodeMatchesFile
(
IHierarchicalContentNode
node
,
File
expectedFile
)
...
...
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