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
121bd274
Commit
121bd274
authored
12 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
SP-332, BIS-225: more tests
SVN: 27944
parent
3fcdbd52
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
openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/DataStoreServerBasedDataSourceProviderTest.java
+53
-2
53 additions, 2 deletions
...ataaccess/DataStoreServerBasedDataSourceProviderTest.java
with
53 additions
and
2 deletions
openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/DataStoreServerBasedDataSourceProviderTest.java
+
53
−
2
View file @
121bd274
...
@@ -39,6 +39,7 @@ import org.testng.annotations.BeforeMethod;
...
@@ -39,6 +39,7 @@ import org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase
;
import
ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase
;
import
ch.systemsx.cisd.common.exceptions.ConfigurationFailureException
;
import
ch.systemsx.cisd.common.exceptions.EnvironmentFailureException
;
import
ch.systemsx.cisd.common.exceptions.EnvironmentFailureException
;
import
ch.systemsx.cisd.common.filesystem.FileUtilities
;
import
ch.systemsx.cisd.common.filesystem.FileUtilities
;
import
ch.systemsx.cisd.common.shared.basic.string.CommaSeparatedListBuilder
;
import
ch.systemsx.cisd.common.shared.basic.string.CommaSeparatedListBuilder
;
...
@@ -55,6 +56,11 @@ import ch.systemsx.cisd.openbis.generic.shared.util.IDataSourceFactory;
...
@@ -55,6 +56,11 @@ import ch.systemsx.cisd.openbis.generic.shared.util.IDataSourceFactory;
*/
*/
public
class
DataStoreServerBasedDataSourceProviderTest
extends
AbstractFileSystemTestCase
public
class
DataStoreServerBasedDataSourceProviderTest
extends
AbstractFileSystemTestCase
{
{
private
static
final
String
HEADER_LINE_OF_ERROR_MESSAGE
=
"Error(s) in mapping file targets/unit-test-wd/"
+
DataStoreServerBasedDataSourceProviderTest
.
class
.
getName
()
+
"/mapping.txt:\n"
;
private
static
final
String
PLUGIN_KEY
=
"key"
;
private
static
final
String
PLUGIN_KEY
=
"key"
;
private
static
final
String
DRIVER_CLASS
=
DatabaseEngine
.
POSTGRESQL
.
getDriverClass
();
private
static
final
String
DRIVER_CLASS
=
DatabaseEngine
.
POSTGRESQL
.
getDriverClass
();
...
@@ -166,6 +172,37 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
...
@@ -166,6 +172,37 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
context
.
assertIsSatisfied
();
context
.
assertIsSatisfied
();
}
}
@Test
public
void
testMappingFileWithInvalidType
()
{
assertFailedMappingFile
(
"Line 1: Unknown type 'CONFIG', possible values are: "
+
"host-part, username, password, sid, config, data-source-code"
,
"*.*.CONFIG = DSS\n"
);
}
@Test
public
void
testMappingFileWithMissingValue
()
{
assertFailedMappingFile
(
"Line 3: Missing '='"
,
"# example\n\n"
+
"alpha.beta*.sid\n"
);
}
@Test
public
void
testMappingFileWithInvalidMappingDescription
()
{
assertFailedMappingFile
(
"Line 1: Mapping description should have three parts separated by '.'"
,
"a.b = c\n"
);
assertFailedMappingFile
(
"Line 1: Mapping description should have three parts separated by '.'"
,
"a.b.c.d = c\n"
);
}
@Test
public
void
testMappingFileWithInvalidDataStoreCodePattern
()
{
assertFailedMappingFile
(
"Line 1: Unclosed group near index 3\n"
+
"A(B\n"
+
" ^"
,
"a(b.a.sid=b\n"
);
}
@Test
@Test
public
void
testMappingFileWithUnspecifiedDataSourceCodeAndConfigMappingAllOnOne
()
public
void
testMappingFileWithUnspecifiedDataSourceCodeAndConfigMappingAllOnOne
()
{
{
...
@@ -216,7 +253,7 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
...
@@ -216,7 +253,7 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
@Test
@Test
public
void
testMappingOnFixedDataStoreCode
()
public
void
testMappingOnFixedDataStoreCode
()
{
{
FileUtilities
.
writeToFile
(
mappingFile
,
"*.*.config =
D
SS2[*]\n"
);
FileUtilities
.
writeToFile
(
mappingFile
,
"*.*.config =
d
SS2[*]\n"
);
prepareListDataStores
();
prepareListDataStores
();
DataStoreServerBasedDataSourceProvider
dataSourceProvider
=
createDataSourceProvider
();
DataStoreServerBasedDataSourceProvider
dataSourceProvider
=
createDataSourceProvider
();
...
@@ -387,7 +424,7 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
...
@@ -387,7 +424,7 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
props
=
builder
.
get
();
props
=
builder
.
get
();
FileUtilities
.
writeToFile
(
mappingFile
,
"# example mapping file\n"
FileUtilities
.
writeToFile
(
mappingFile
,
"# example mapping file\n"
+
"*.proteomics.config = all[proteomics]\n"
+
"*.proteomics.config = all[proteomics]\n"
+
"*.proteomics.data-source-code = proteomics_db\n"
+
"*.proteomics.data-source-code = proteomics_db\n"
+
" \n"
+
"*.screening.config = all[screening]\n"
+
"*.screening.config = all[screening]\n"
+
"*.screening.data-source-code = imaging_db\n"
+
"*.screening.data-source-code = imaging_db\n"
+
"*.screening.host-part = localhost:1234\n"
+
"*.screening.username = openbis\n"
+
"*.screening.host-part = localhost:1234\n"
+
"*.screening.username = openbis\n"
...
@@ -448,6 +485,20 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
...
@@ -448,6 +485,20 @@ public class DataStoreServerBasedDataSourceProviderTest extends AbstractFileSyst
assertEquals
(
expectedProps
,
sortedProps
.
toString
());
assertEquals
(
expectedProps
,
sortedProps
.
toString
());
}
}
private
void
assertFailedMappingFile
(
String
expectedErrorMessage
,
String
mappingFileContent
)
{
FileUtilities
.
writeToFile
(
mappingFile
,
mappingFileContent
);
try
{
createDataSourceProvider
();
fail
(
"ConfigurationFailureException expected"
);
}
catch
(
ConfigurationFailureException
e
)
{
assertEquals
(
HEADER_LINE_OF_ERROR_MESSAGE
+
expectedErrorMessage
,
e
.
getMessage
());
}
context
.
assertIsSatisfied
();
}
private
void
prepareListDataStores
(
final
DataStorePE
...
dataStores
)
private
void
prepareListDataStores
(
final
DataStorePE
...
dataStores
)
{
{
context
.
checking
(
new
Expectations
()
context
.
checking
(
new
Expectations
()
...
...
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