1 19 20 package org.netbeans.modules.db.api.explorer; 21 22 import java.net.URL ; 23 import org.netbeans.api.db.explorer.DatabaseConnection; 24 import org.netbeans.api.db.explorer.JDBCDriver; 25 import org.netbeans.junit.NbTestCase; 26 import org.netbeans.modules.db.explorer.DbMetaDataTransferProvider; 27 import org.openide.filesystems.XMLFileSystem; 28 import org.openide.loaders.DataFolder; 29 import org.openide.loaders.DataObject; 30 import org.openide.loaders.FolderLookup; 31 import org.openide.util.Lookup; 32 33 37 public class DbMetaDataTransferProviderImplTest extends NbTestCase { 38 39 public DbMetaDataTransferProviderImplTest(String testName) { 40 super(testName); 41 } 42 43 47 public void testBasic() throws Exception { 48 JDBCDriver driver = JDBCDriver.create("foo", "Foo", "org.example.Foo", new URL [0]); 49 DatabaseConnection dbconn = DatabaseConnection.create(driver, "url", "user", "schema", "pwd", false); 50 51 XMLFileSystem layerFs = new XMLFileSystem(DbMetaDataTransferProviderImplTest.class.getClassLoader().getResource("org/netbeans/modules/dbapi/resources/layer.xml")); 52 DataFolder services = DataFolder.findFolder(layerFs.getRoot().getFileObject("Services")); 53 FolderLookup lookup = new FolderLookup(services); 54 55 DbMetaDataTransferProvider dbTransferProvider = (DbMetaDataTransferProvider)lookup.getLookup().lookup(DbMetaDataTransferProvider.class); 56 assertNotNull(dbTransferProvider); 57 58 assertSame(DatabaseMetaDataTransfer.TABLE_FLAVOR, dbTransferProvider.getTableDataFlavor()); 59 60 DatabaseMetaDataTransfer.Table table = (DatabaseMetaDataTransfer.Table)dbTransferProvider.createTableData(dbconn, driver, "SOME_TABLE"); 61 assertSame(dbconn, table.getDatabaseConnection()); 62 assertSame(driver, table.getJDBCDriver()); 63 assertSame("SOME_TABLE", table.getTableName()); 64 } 65 } 66 | Popular Tags |