Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xml_plugin4rosetta
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
Harbor 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
Digital Preservation
xml_plugin4rosetta
Commits
1bd16d73
Commit
1bd16d73
authored
1 year ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- increased readability
parent
dbdbec2a
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
java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java
+17
-10
17 additions, 10 deletions
.../dps/repository/plugin/Validation/TestValidateSchema.java
with
17 additions
and
10 deletions
java/org/slub/rosetta/dps/repository/plugin/Validation/TestValidateSchema.java
+
17
−
10
View file @
1bd16d73
...
...
@@ -41,7 +41,7 @@ import static org.junit.Assert.*;
@RunWith
(
JUnit4
.
class
)
public
class
TestValidateSchema
{
private
static
XmlFormatValidationPlugin
mock
;
private
XmlFormatValidationPlugin
mock
;
private
final
Map
<
String
,
String
>
initp
=
new
HashMap
<>();
private
URI
local2Uri
(
String
sUri
)
{
...
...
@@ -67,6 +67,8 @@ public class TestValidateSchema {
@org
.
junit
.
Test
public
void
schema_valid
()
{
System
.
out
.
println
(
"-----------------------------------------------------------------------------------"
);
String
testfile
=
"resources/test/valid/minimod.xml"
;
ValidationResultHandle
resultHandle
=
new
ValidationResultHandle
();
ValidationResourceResolver
validationResourceResolver
=
new
ValidationResourceResolver
(
mock
.
getNamespaceSchemaMap
(),
resultHandle
);
var
v
=
new
ValidateSchema
(
validationResourceResolver
,
resultHandle
);
...
...
@@ -74,19 +76,22 @@ public class TestValidateSchema {
var
has_exception
=
false
;
var
res
=
false
;
try
{
var
doc
=
mock
.
getDocument
(
"resources/test/valid/minimod.xml"
);
var
doc
=
mock
.
getDocument
(
testfile
);
res
=
v
.
validateAgainst
(
doc
,
local2Uri
(
"example_catalog/mods-3.8/flatten/mods-3-8.xsd"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
has_exception
=
true
;
}
System
.
out
.
println
(
resultHandle
.
getLog
());
assertFalse
(
"schema validation should not raise an exception"
,
has_exception
);
assertTrue
(
"schema validation should return true for sucessful validation"
,
res
);
assertFalse
(
"schema validation of "
+
testfile
+
" should not raise an exception"
,
has_exception
);
assertTrue
(
"schema validation of "
+
testfile
+
" should return true for sucessful validation"
,
res
);
}
@org
.
junit
.
Test
public
void
schema_invalid
()
{
System
.
out
.
println
(
"-----------------------------------------------------------------------------------"
);
String
testfile
=
"resources/test/invalid/minimod.xml"
;
ValidationResultHandle
resultHandle
=
new
ValidationResultHandle
();
ValidationResourceResolver
validationResourceResolver
=
new
ValidationResourceResolver
(
mock
.
getNamespaceSchemaMap
(),
resultHandle
);
var
v
=
new
ValidateSchema
(
validationResourceResolver
,
resultHandle
);
...
...
@@ -94,19 +99,21 @@ public class TestValidateSchema {
var
has_exception
=
false
;
var
res
=
false
;
try
{
var
doc
=
mock
.
getDocument
(
"resources/test/invalid/minimod.xml"
);
var
doc
=
mock
.
getDocument
(
testfile
);
res
=
v
.
validateAgainst
(
doc
,
local2Uri
(
"example_catalog/mods-3.8/flatten/mods-3-8.xsd"
));
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"EXCEPTION:"
+
e
.
getMessage
());
e
.
printStackTrace
();
has_exception
=
true
;
}
assertFalse
(
"schema validation should not raise an exception"
,
has_exception
);
assertFalse
(
"schema validation should return false for failed validation"
,
res
);
assertFalse
(
"schema validation
of "
+
testfile
+
"
should not raise an exception"
,
has_exception
);
assertFalse
(
"schema validation
of "
+
testfile
+
"
should return false for failed validation"
,
res
);
}
@org
.
junit
.
Test
public
void
check_import_regression
()
{
System
.
out
.
println
(
"-----------------------------------------------------------------------------------"
);
String
testfile
=
"resources/test/valid/kml/KML_Samples.kml"
;
Set
<
ValidationSchema
>
nssm
=
new
HashSet
<>();
Set
<
ValidationSchema
>
old
=
mock
.
getNamespaceSchemaMap
();
for
(
ValidationSchema
val
:
old
)
{
// filter Atoim out to trigger error
...
...
@@ -122,14 +129,14 @@ public class TestValidateSchema {
var
has_exception
=
false
;
var
res
=
false
;
try
{
var
doc
=
mock
.
getDocument
(
"resources/test/valid/kml/KML_Samples.kml"
);
var
doc
=
mock
.
getDocument
(
testfile
);
res
=
v
.
validateAgainst
(
doc
,
local2Uri
(
"example_catalog/kml-2.3.0/ogckml23.xsd"
));
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"EXCEPTION:"
+
e
.
getMessage
());
e
.
printStackTrace
();
has_exception
=
true
;
}
assertFalse
(
"schema validation should not raise an exception"
,
has_exception
);
assertFalse
(
"schema validation should return false for failed validation"
,
res
);
assertFalse
(
"schema validation
of "
+
testfile
+
"
should not raise an exception"
,
has_exception
);
assertFalse
(
"schema validation
of "
+
testfile
+
"
should return false for failed validation"
,
res
);
}
}
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