@BeforeClass public static void before() { modelExplorer = new ModelExplorer(); modelExplorer.importProject(PROJECT_NAME); modelExplorer.changeConnectionProfile( ConnectionProfileConstants.SQL_SERVER_2008_PARTS_SUPPLIER, PROJECT_NAME, NAME_ORACLE_MODEL); }
/** deploy vdb and create connection profile (modelExplorer.deployVDB() doesn't create CP) */ private void executeVDB(String project, String vdb) { modelExplorer.activate(); vdb = (vdb.contains(".vdb")) ? vdb : vdb + ".vdb"; new DefaultTreeItem(project, vdb).select(); new ContextMenu("Modeling", "Execute VDB").select(); new WaitWhile(new IsInProgress(), TimePeriod.VERY_LONG); new WaitWhile(new JobIsRunning(), TimePeriod.LONG); new WorkbenchShell(); TeiidPerspective.activate(); }
@Test public void reuseVDBtest() { VdbWizard.openVdbWizard() .setLocation(PROJECT_NAME) .setName(SOURCE_VDB) .addModel(PROJECT_NAME, VIEW_SOURCE_MODEL + ".xmi") .finish(); executeVDB(PROJECT_NAME, SOURCE_VDB); modelExplorer.createProject(PROJECT_NAME_REUSE); ImportJDBCDatabaseWizard.openWizard() .setConnectionProfile(SOURCE_VDB + " - localhost - Teiid Connection") .nextPage() .setTableTypes(false, true, false) .nextPage() .setTables(VIEW_SOURCE_MODEL) .nextPage() .setFolder(PROJECT_NAME_REUSE) .finish(); MetadataModelWizard wizard = MetadataModelWizard.openWizard() .setLocation(PROJECT_NAME_REUSE) .setModelName(VIEW_REUSE_MODEL) .selectModelClass(MetadataModelWizard.ModelClass.RELATIONAL) .selectModelType(MetadataModelWizard.ModelType.VIEW) .selectModelBuilder(MetadataModelWizard.ModelBuilder.TRANSFORM_EXISTING) .nextPage(); try { new PushButton("OK").click(); } catch (Exception ex) { } wizard.activate().finish(); new RelationalModelEditor(VIEW_REUSE_MODEL + ".xmi").save(); VdbWizard.openVdbWizard() .setLocation(PROJECT_NAME_REUSE) .setName(REUSE_VDB) .addModel(PROJECT_NAME_REUSE, VIEW_REUSE_MODEL + ".xmi") .finish(); modelExplorer.deployVdb(PROJECT_NAME_REUSE, REUSE_VDB); /* test version 1 */ TeiidJDBCHelper jdbchelper = new TeiidJDBCHelper(teiidServer, REUSE_VDB); try { ResultSet rs = jdbchelper.executeQueryWithResultSet("SELECT * FROM " + VIEW_REUSE_MODEL + ".version"); rs.next(); assertEquals("version1", rs.getString(1)); assertEquals( 16, jdbchelper.getNumberOfResults("SELECT * FROM " + VIEW_REUSE_MODEL + ".PARTS")); } catch (SQLException e) { e.printStackTrace(); } finally { jdbchelper.closeConnection(); } /*change sourceVDB version to 2*/ new RelationalModelEditor(VIEW_SOURCE_MODEL + ".xmi").close(); modelExplorer.openModelEditor(PROJECT_NAME, VIEW_SOURCE_MODEL + ".xmi"); TransformationEditor transformation = new RelationalModelEditor(VIEW_SOURCE_MODEL + ".xmi") .openTransformationDiagram(ModelEditor.ItemType.TABLE, "version"); transformation.setTransformation("SELECT 'version2'"); transformation.saveAndValidateSql(); AbstractWait.sleep(TimePeriod.NORMAL); new ShellMenu("File", "Save All").select(); VdbEditor vdb = new VdbEditor(SOURCE_VDB + ".vdb"); vdb.activate(); vdb.synchronizeAll(); vdb.setVersion(2); new RelationalModelEditor(SOURCE_VDB + ".vdb").save(); modelExplorer.deployVdb(PROJECT_NAME, SOURCE_VDB); /* test version 1 */ if (new JiraClient().isIssueClosed("TEIIDDES-2848")) { jdbchelper = new TeiidJDBCHelper(teiidServer, REUSE_VDB); try { ResultSet rs = jdbchelper.executeQueryWithResultSet("SELECT * FROM " + VIEW_REUSE_MODEL + ".version"); rs.next(); assertEquals("version1", rs.getString(1)); assertEquals( 17, jdbchelper.getNumberOfResults("SELECT * FROM " + VIEW_REUSE_MODEL + ".PARTS")); } catch (SQLException e) { e.printStackTrace(); } } /* change and test reuseVDB with version 2 */ vdb = new VdbEditor(REUSE_VDB + ".vdb"); vdb.activate(); vdb.setImportVDB(SOURCE_VDB, 2, false); new RelationalModelEditor(REUSE_VDB + ".vdb").save(); modelExplorer.deployVdb(PROJECT_NAME_REUSE, REUSE_VDB); jdbchelper = new TeiidJDBCHelper(teiidServer, REUSE_VDB); try { ResultSet rs = jdbchelper.executeQueryWithResultSet("SELECT * FROM " + VIEW_REUSE_MODEL + ".version"); rs.next(); assertEquals("version2", rs.getString(1)); assertEquals( 16, jdbchelper.getNumberOfResults("SELECT * FROM " + VIEW_REUSE_MODEL + ".PARTS")); } catch (SQLException e) { e.printStackTrace(); } }