Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
a9a5780b
Commit
a9a5780b
authored
Jun 26, 2025
by
Riegel
Browse files
Test: Extend database marshalling testcase
parent
25b56fba
Changes
1
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/DataBaseHandlerTest.java
View file @
a9a5780b
package
de.hft.stuttgart.citydoctor2.database
;
package
de.hft.stuttgart.citydoctor2.database
;
import
de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityObject
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParseException
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParseException
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParser
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParser
;
import
de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException
;
import
de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Copy
;
import
de.hft.stuttgart.citydoctor2.utils.visitors.CityObjectCollector
;
import
org.h2gis.functions.factory.H2GISDBFactory
;
import
org.h2gis.functions.factory.H2GISDBFactory
;
import
org.h2gis.utilities.wrapper.ConnectionWrapper
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
@@ -45,16 +47,28 @@ public class DataBaseHandlerTest {
...
@@ -45,16 +47,28 @@ public class DataBaseHandlerTest {
try
(
Connection
con
=
H2GISDBFactory
.
openSpatialDataBase
(
"cd_db"
))
{
try
(
Connection
con
=
H2GISDBFactory
.
openSpatialDataBase
(
"cd_db"
))
{
assertNotNull
(
con
);
assertNotNull
(
con
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
CityGmlParser
.
parseCityGmlFile
(
"src/test/resources/
SimpleSolid_SrefBS
.gml"
,
config
);
CityDoctorModel
model
=
CityGmlParser
.
parseCityGmlFile
(
"src/test/resources/
FZK_haus
.gml"
,
config
);
Building
b
=
model
.
getBuildings
().
get
(
0
);
Building
b
=
model
.
getBuildings
().
get
(
0
);
Copy
.
copy
(
b
);
assertNotNull
(
b
);
assertNotNull
(
b
);
assertEquals
(
0
,
DatabaseHandler
.
getFeatureCount
());
assertEquals
(
0
,
DatabaseHandler
.
getFeatureCount
());
DatabaseHandler
.
marshallCityObject
(
b
);
DatabaseHandler
.
marshallCityObject
(
b
);
assertEquals
(
1
,
DatabaseHandler
.
getFeatureCount
());
assertEquals
(
1
,
DatabaseHandler
.
getFeatureCount
());
// Building b2 = (Building) DatabaseHandler.unmarshallCityObject(b.getGmlId());
CityObject
b2
=
DatabaseHandler
.
unmarshallCityObject
(
b
.
getGmlId
());
// assertNotNull(b2);
assertNotNull
(
b2
);
// assertEquals(1, DatabaseHandler.getFeatureCount());
assertEquals
(
1
,
DatabaseHandler
.
getFeatureCount
());
assertEquals
(
b
.
getGmlId
(),
b2
.
getGmlId
());
assertEquals
(
b
.
getFeatureType
(),
b2
.
getFeatureType
());
CityObjectCollector
collector
=
new
CityObjectCollector
();
b
.
accept
(
collector
);
Set
<
CityObject
>
coB
=
collector
.
getCityObjects
();
collector
=
new
CityObjectCollector
();
b2
.
accept
(
collector
);
Set
<
CityObject
>
coB2
=
collector
.
getCityObjects
();
assertEquals
(
coB
.
size
(),
coB2
.
size
());
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment