/** Setup a log handler counting {@link LogRecord} having {@link Level#WARNING}. */ @Before public void setUp() { // when(mockLogHandler.publish(any(LogRecord.class))); doAnswer( new Answer<Object>() { public Object answer(InvocationOnMock invocation) { Object[] arguments = invocation.getArguments(); LogRecord logRecord = (LogRecord) arguments[0]; if (logRecord.getLevel() == Level.WARNING && !logRecord.getSourceMethodName().equals("finalize")) { warningsCount++; } return null; } }) .when(mockLogHandler) .publish(any(LogRecord.class)); dataStore = new JDBCDataStore(); dataStore.getLogger().addHandler(mockLogHandler); }
JDBCDataStore closer = new JDBCDataStore();
protected DataSource createDataSource(Map params, SQLDialect dialect) throws IOException { DataSource ds = super.createDataSource(params, dialect); JDBCDataStore closer = new JDBCDataStore();
final JDBCDataStore jdbcDataStore = new JDBCDataStore(); SQLDialect sqlDialect = new BasicSQLDialect(jdbcDataStore) {
/** Returns a properly initialized connection. It's up to the calling code to close it */ protected Connection getConnection() throws SQLException, IOException { Connection conn = getDataSource().getConnection(); JDBCDataStore store = null; try { store = new JDBCDataStore(); createDataStoreFactory().createSQLDialect(store).initializeConnection(conn); } finally { if (store != null) { store.dispose(); } } return conn; }
@Before public void setUp() throws SQLException { cx = new TracingMockConnection(); configureMetadata(); dataStore = new JDBCDataStore(); dataStore.setFilterFactory(CommonFactoryFinder.getFilterFactory2()); dataStore.setSQLDialect(createBasicSQLDialect()); MockDataSource dataSource = new MockDataSource(); dataSource.setupConnection(cx); dataStore.setDataSource(dataSource); featureType = Mockito.mock(SimpleFeatureType.class); Mockito.when(featureType.getTypeName()).thenReturn(SAMPLE_FEATURE_NAME); Mockito.when(featureType.getName()).thenReturn(new NameImpl(SAMPLE_FEATURE_NAME)); tx = new DefaultTransaction(); }
JDBCReaderCallback callback = mock(JDBCReaderCallback.class); JDBCDataStore store = new JDBCDataStore(); store.setNamespaceURI("http://geotools.org"); store.setPrimaryKeyFinder(
public final JDBCDataStore createDataStore(Map params) throws IOException { JDBCDataStore dataStore = new JDBCDataStore();
private boolean checkAndInstall(DataSource ds) throws DaoException { JDBCDataStore closer = new JDBCDataStore();
private boolean checkAndInstall(DataSource ds) throws DaoException { JDBCDataStore closer = new JDBCDataStore();
public void verifyVersion(Map params) throws DaoException { JDBCDataStore dataStore = new JDBCDataStore(); SQLDialect dialect = createSQLDialect(dataStore); dataStore.setSQLDialect(dialect); DataSource ds; try { ds = super.createDataSource(params, dialect); } catch (IOException e) { throw new DaoException(e); } LOG.info("checking for postgis extension"); // First pass through loop may install extension. Second pass should work! for (int i = 0; i < 2; i++) { if (checkAndInstall(ds)) { return; } } throw new DaoException("Failed to create PostGIS extension for database. Is PostGIS 2.x installed?"); }
public void verifyVersion(Map params) throws DaoException { JDBCDataStore dataStore = new JDBCDataStore(); SQLDialect dialect = createSQLDialect(dataStore); dataStore.setSQLDialect(dialect); DataSource ds; try { ds = super.createDataSource(params, dialect); } catch (IOException e) { throw new DaoException(e); } LOG.info("checking for postgis extension"); // First pass through loop may install extension. Second pass should work! for (int i = 0; i < 2; i++) { if (checkAndInstall(ds)) { return; } } throw new DaoException("Failed to create PostGIS extension for database. Is PostGIS 2.x installed?"); }
public final JDBCDataStore createDataStore(Map params) throws IOException { JDBCDataStore dataStore = new JDBCDataStore();
public final JDBCDataStore createDataStore(Map params) throws IOException { JDBCDataStore dataStore = new JDBCDataStore();