-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOT-6264] JDBC FeatureWriter-implementation annihilates input-data.
- Loading branch information
burkhard
committed
Mar 12, 2019
1 parent
aff650a
commit 8c68d9d
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ nb-configuration.xml | |
workspace | ||
*.db | ||
.metadata | ||
.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCFeatureWriterOnlineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* GeoTools - The Open Source Java GIS Toolkit | ||
* http://geotools.org | ||
* | ||
* (C) 2019, Open Source Geospatial Foundation (OSGeo) | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 2.1 of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
*/ | ||
package org.geotools.jdbc; | ||
|
||
import org.geotools.data.FeatureWriter; | ||
import org.geotools.data.Transaction; | ||
import org.opengis.feature.simple.SimpleFeature; | ||
|
||
/** | ||
* JDBC {@link FeatureWriter}-implementation tampers with input-data. | ||
* | ||
* @author Burkhard Strauss | ||
* @see GEOT-6264 | ||
*/ | ||
public abstract class JDBCFeatureWriterOnlineTest extends JDBCTestSupport { | ||
|
||
public void testNext() throws Exception { | ||
|
||
try (FeatureWriter writer = | ||
dataStore.getFeatureWriter(tname("ft1"), Transaction.AUTO_COMMIT)) { | ||
assertTrue(writer.hasNext()); | ||
final SimpleFeature feature = (SimpleFeature) writer.next(); | ||
assertTrue(feature.getAttribute(0).toString().equals("POINT (0 0)")); | ||
assertTrue((Integer) feature.getAttribute(1) == 0); | ||
assertTrue((Double) feature.getAttribute(2) == 0.0); | ||
assertTrue(((String) feature.getAttribute(3)).equals("zero")); | ||
} | ||
try (FeatureWriter writer = | ||
dataStore.getFeatureWriter(tname("ft1"), Transaction.AUTO_COMMIT)) { | ||
assertTrue(writer.hasNext()); | ||
final SimpleFeature feature = (SimpleFeature) writer.next(); | ||
assertTrue(feature.getAttribute(0).toString().equals("POINT (0 0)")); | ||
assertTrue((Integer) feature.getAttribute(1) == 0); | ||
assertTrue((Double) feature.getAttribute(2) == 0.0); | ||
assertTrue(((String) feature.getAttribute(3)).equals("zero")); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...n/jdbc/jdbc-mysql/src/test/java/org/geotools/data/mysql/MySQLFeatureWriterOnlineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* GeoTools - The Open Source Java GIS Toolkit | ||
* http://geotools.org | ||
* | ||
* (C) 2019, Open Source Geospatial Foundation (OSGeo) | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 2.1 of the License. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
*/ | ||
package org.geotools.data.mysql; | ||
|
||
import org.geotools.jdbc.JDBCFeatureWriterOnlineTest; | ||
import org.geotools.jdbc.JDBCTestSetup; | ||
|
||
/** @author Burkhard Strauss */ | ||
public class MySQLFeatureWriterOnlineTest extends JDBCFeatureWriterOnlineTest { | ||
|
||
@Override | ||
protected JDBCTestSetup createTestSetup() { | ||
return new MySQLTestSetup(); | ||
} | ||
} |