Commit 9755404f authored by Riegel's avatar Riegel
Browse files

Test: Setup database test-case

parent 4e6dafd4
Pipeline #11389 passed with stage
in 1 minute and 37 seconds
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);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment