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
9755404f
Commit
9755404f
authored
Jun 23, 2025
by
Riegel
Browse files
Test: Setup database test-case
parent
4e6dafd4
Pipeline
#11389
passed with stage
in 1 minute and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/database/DataBaseHandlerTest.java
0 → 100644
View file @
9755404f
package
de.hft.stuttgart.citydoctor2.database
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParseException
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParser
;
import
de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.h2gis.functions.factory.H2GISDBFactory
;
import
org.h2gis.utilities.wrapper.ConnectionWrapper
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
fail
;
public
class
DataBaseHandlerTest
{
@BeforeClass
public
static
void
setUpBeforeClass
()
throws
Exception
{
DatabaseHandler
.
setupDatabase
();
try
(
Connection
con
=
H2GISDBFactory
.
openSpatialDataBase
(
"cd_db"
))
{
assertNotNull
(
con
);
}
}
@Before
public
void
prepareDatabase
()
{
try
{
DatabaseHandler
.
setupFeaturesTable
();
}
catch
(
Exception
e
)
{
fail
(
e
.
getMessage
());
}
}
@Test
public
void
cityObjectMarshallingTest
()
throws
InvalidGmlFileException
,
CityGmlParseException
{
try
(
Connection
con
=
H2GISDBFactory
.
openSpatialDataBase
(
"cd_db"
))
{
assertNotNull
(
con
);
ParserConfiguration
config
=
new
ParserConfiguration
(
8
,
false
);
CityDoctorModel
model
=
CityGmlParser
.
parseCityGmlFile
(
"src/test/resources/SimpleSolid_SrefBS.gml"
,
config
);
Building
b
=
model
.
getBuildings
().
get
(
0
);
assertNotNull
(
b
);
assertEquals
(
0
,
DatabaseHandler
.
getFeatureCount
());
DatabaseHandler
.
marshallCityObject
(
b
);
assertEquals
(
1
,
DatabaseHandler
.
getFeatureCount
());
// Building b2 = (Building) DatabaseHandler.unmarshallCityObject(b.getGmlId());
// assertNotNull(b2);
// assertEquals(1, DatabaseHandler.getFeatureCount());
}
catch
(
SQLException
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