/** * Tests the creation of new feature types, with CRS and all. * * <p>This test also ensures that the arcsde datastore is able of creating schemas where the * geometry attribute is not the last one. This is important since to do so, the ArcSDE datastore * must break the usual way of creating schemas with the ArcSDE Java API, in which one first * creates the (non spatially enabled) "table" with all the non spatial attributes and finally * creates the "layer", adding the spatial attribute to the previously created table. So, this * test ensures the datastore correctly works arround this limitation. * * @throws IOException * @throws SchemaException * @throws SeException * @throws UnavailableConnectionException */ @Test public void testCreateSchema() throws IOException, SchemaException, SeException, UnavailableConnectionException { final String typeName; { ISessionPool connectionPool = testData.getConnectionPool(); ISession session = connectionPool.getSession(); final String user; user = session.getUser(); session.dispose(); typeName = user + ".GT_TEST_CREATE"; } SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.add("FST_COL", String.class); b.add("SECOND_COL", String.class); b.add("GEOM", Point.class); b.add("FOURTH_COL", Integer.class); final SimpleFeatureType type = b.buildFeatureType(); DataStore ds = testData.getDataStore(); testData.deleteTable(typeName); Map hints = new HashMap(); hints.put("configuration.keyword", testData.getConfigKeyword()); ((ArcSDEDataStore) ds).createSchema(type, hints); testData.deleteTable(typeName); }
/** * This test is currently broken. It's a placeholder for some logic that sfarber wrote which tries * to guess the SRS of a featureclass, based on connecting to it via an SeLayer. * * @throws Throwable */ @Test @Ignore public void testAutoFillSRS() throws Throwable { ArcSDEDataStore ds = testData.getDataStore(); CoordinateReferenceSystem sdeCRS = ds.getSchema("GISDATA.TOWNS_POLY").getGeometryDescriptor().getCoordinateReferenceSystem(); LOGGER.info(sdeCRS.toWKT().replaceAll(" ", "").replaceAll("\n", "").replaceAll("\"", "\\\"")); // CoordinateReferenceSystem epsgCRS = CRS.decode("EPSG:26986"); // LOGGER.info("are these two CRS's equal? " + // CRS.equalsIgnoreMetadata(sdeCRS, epsgCRS)); if (1 == 1) return; int epsgCode = -1; int[] projcs = PeFactory.projcsCodelist(); LOGGER.info(projcs.length + " projections available."); for (int i = 0; i < projcs.length; i++) { try { PeProjectedCS candidate = PeFactory.projcs(projcs[i]); // in ArcSDE 9.2, if the PeFactory doesn't support a projection // it claimed // to support, it returns 'null'. So check for it. if (candidate != null && candidate.getName().indexOf("Massachusetts") != -1) { // LOGGER.info("\n\n" + projcs[i] + " has name " + // candidate.getName() + "\ntried to match " + wktName + // "\n\n"); epsgCode = projcs[i]; } else if (candidate == null) { // LOGGER.info(projcs[i] + " was null"); } else if (candidate != null) { // LOGGER.info(projcs[i] + " wasn't null"); } } catch (PeProjectionException pe) { // Strangely SDE includes codes in the projcsCodeList() that // it doesn't actually support. // Catch the exception and skip them here. } } }
@SuppressWarnings("unchecked") @Test public void testCreateNillableShapeSchema() throws IOException, SchemaException, SeException, UnavailableConnectionException { SimpleFeatureType type; final String typeName = "GT_TEST_CREATE"; SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(typeName); b.add("OBJECTID", Integer.class); b.nillable(true); b.add("SHAPE", MultiLineString.class); type = b.buildFeatureType(); ArcSDEDataStore ds = testData.getDataStore(); testData.deleteTable(typeName); Map hints = new HashMap(); hints.put("configuration.keyword", testData.getConfigKeyword()); ds.createSchema(type, hints); testData.deleteTable(typeName); }
@Test public void testDispose() throws IOException { store.dispose(); try { ((ArcSDEDataStore) store).getSession(Transaction.AUTO_COMMIT); fail("Expected IllegalStateException when the datastore has been disposed"); } catch (IllegalStateException e) { assertTrue(true); } finally { // dispose test data so next test does not fail due to pool being // closed testData.tearDown(false, true); testData = null; } }