Package org.geotools.data.jdbc.datasource

Examples of org.geotools.data.jdbc.datasource.UnWrapper


    public void connect() throws Exception {
        super.connect();
        fixture = new GeometryFixture();
        this.connection = setup.getDataSource().getConnection();
       
        UnWrapper unwrapper = DataSourceFinder.getUnWrapper(this.connection);
        OracleConnection oraConn = (OracleConnection) unwrapper.unwrap(this.connection);
        converter = new GeometryConverter(oraConn);
    }
View Full Code Here


        try {
            // first lookup ever? (we have UNWRAPPER_NOT_FOUND as a sentinel for a lookup that
            // will not work (we assume the datasource will always return connections we can
            // unwrap, or never).
            if (uw == null) {
                UnWrapper unwrapper = DataSourceFinder.getUnWrapper(cx);
                if (unwrapper == null) {
                    uw = UNWRAPPER_NOT_FOUND;
                } else {
                    uw = unwrapper;
                }
View Full Code Here

       ds.setDriverClassName("org.h2.Driver");
       ds.setUrl("jdbc:h2:mem:test_mem");
       ds.setAccessToUnderlyingConnectionAllowed(true);
      
       Connection conn = ds.getConnection();
       UnWrapper uw = DataSourceFinder.getUnWrapper(conn);
       assertNotNull(uw);
       assertTrue(uw.canUnwrap(conn));
       Connection unwrapped = uw.unwrap(conn);
       assertNotNull(unwrapped);
       assertTrue(unwrapped instanceof org.h2.jdbc.JdbcConnection);
      
       Statement st = conn.createStatement();
       uw = DataSourceFinder.getUnWrapper(st);
       assertNotNull(uw);
       assertTrue(uw.canUnwrap(st));
       Statement uwst = uw.unwrap(st);
       assertNotNull(uwst);
       assertTrue(uwst instanceof org.h2.jdbc.JdbcStatement);
       st.close();
      
       PreparedStatement ps = conn.prepareStatement("select curtime()");
       uw = DataSourceFinder.getUnWrapper(ps);
       assertNotNull(uw);
       assertTrue(uw.canUnwrap(ps));
       PreparedStatement uwps = (PreparedStatement) uw.unwrap(ps);
       assertNotNull(uwps);
       assertTrue(uwps instanceof org.h2.jdbc.JdbcPreparedStatement);
       ps.close();
      
          
View Full Code Here

        assertTrue( wrapper.isWrapperFor( Connection.class ) );       
        Connection unwrap = wrapper.unwrap( Connection.class );
       
        assertSame( connection, unwrap );
       
        UnWrapper unwrapper = new GenericUnWrapper();
       
        assertFalse( unwrapper.canUnwrap( wrapper ) );
        try {
            assertNull( unwrapper.unwrap( wrapper ));
            fail("Cannot unwrap yet");
        }
        catch (Exception expected){
        }
        GenericUnWrapper.CONNECTION_METHODS.put(WrapperConnection.class,
                WrapperConnection.class.getMethod("getUnderlyingConnection", null));
       
        assertTrue( unwrapper.canUnwrap( wrapper ) );
        assertSame( connection, unwrapper.unwrap( wrapper ) );
    }
View Full Code Here

    @Test
    public void testSPIRegistration() throws Exception {
        Connection connection = new TestConnection();
        Connection wrapper = new WrapperConnection( connection );
       
         UnWrapper uw = DataSourceFinder.getUnWrapper( wrapper );
         if( uw != null ){
             assertTrue("picked up by jdbc4 extractor", uw instanceof SpringUnWrapper );
         }
        
         GenericUnWrapper.CONNECTION_METHODS.put(WrapperConnection.class,
                 WrapperConnection.class.getMethod("getUnderlyingConnection", null));
        
         uw = DataSourceFinder.getUnWrapper( wrapper );
         assertNotNull("registed and canUnwrap",uw);
         if( uw instanceof GenericUnWrapper ){
             assertSame( "Generic unwrapper is working", connection, uw.unwrap( wrapper ));
         }
    }
View Full Code Here

TOP

Related Classes of org.geotools.data.jdbc.datasource.UnWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.