/** * Obtain a {@link File}for the file name in the test data directory (given by {@link #getTestDataPath()}). * * @param fileName * A path and name relative to the test data directory; for example, "MyFile.txt" if the file is in the test * data directory, or "subfolder/MyFile.txt" if the file is in "subfolder". * @return The File referencing the file with the specified fileName within the test data directory */ public static File getTestDataFile(String fileName) { return new File(UnitTestUtil.getTestDataPath(), fileName); }
@Test(expected=SAXException.class) public void testModelNameUniqueness() throws Exception { FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/model-not-unique-vdb.xml"); VDBMetadataParser.validate(in); }
@Test public void testParseVDB() throws Exception { FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml"); VDBMetadataParser.validate(in); in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml"); VDBMetaData vdb = VDBMetadataParser.unmarshell(in); TestVDBUtility.validateVDB(vdb); }
public void testInvalidDataSource() { final String serverName = "hostName"; //$NON-NLS-1$ final String vdbName = "vdbName"; //$NON-NLS-1$ final String vdbVersion = ""; //$NON-NLS-1$ final int portNumber = -1; // this is what is invalid final String dataSourceName = null; final String transactionAutoWrap = null; final String configFile = UnitTestUtil.getTestDataPath() + "/config.txt"; //$NON-NLS-1$ try { helpTestConnection(vdbName,vdbVersion,serverName,portNumber, null, null, null, dataSourceName,transactionAutoWrap, "false", configFile); // TRUE TO OVERRIDE USERNAME & PASSWORD //$NON-NLS-1$ fail("Unexpectedly able to connect"); //$NON-NLS-1$ } catch ( SQLException e) { // this is expected! } }
public void testInvalidDataSource2() { final String serverName = "hostName"; //$NON-NLS-1$ final String vdbName = "vdbName"; //$NON-NLS-1$ final String vdbVersion = ""; //$NON-NLS-1$ final int portNumber = 31000; final String alternateServers = "hostName:-1"; // this is what is invalid //$NON-NLS-1$ final String dataSourceName = null; final String transactionAutoWrap = null; final String configFile = UnitTestUtil.getTestDataPath() + "/config.txt"; //$NON-NLS-1$ try { helpTestConnection(vdbName, vdbVersion, serverName, portNumber, alternateServers, null, null, dataSourceName, transactionAutoWrap, "false", configFile); //$NON-NLS-1$ // TRUE TO OVERRIDE USERNAME & PASSWORD fail("Unexpectedly able to connect"); //$NON-NLS-1$ } catch ( SQLException e) { // this is expected! } }
@Test public void testUniqueReferencedKey() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/keys.vdb"); Collection fks = tm.getForeignKeysInGroup(tm.getGroupID("x.a")); assertEquals(1, fks.size()); Object pk = tm.getPrimaryKeyIDForForeignKeyID(fks.iterator().next()); assertNotNull(pk); }
@Test public void testMultiple() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ZZZ.vdb"); Collection<String> names = tm.getGroupsForPartialName("PRODUCTDATA"); assertEquals(1, names.size()); names = tm.getGroupsForPartialName("PARTS"); assertEquals(1, names.size()); //ensure that datatypes are set Table t = tm.getGroupID(names.iterator().next()); assertNotNull(t.getColumns().get(0).getDatatype()); }
@Test public void testIndex() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/ora.vdb"); Collection indexes = tm.getIndexesInGroup(tm.getGroupID("ORACLE_BQT.SMALLA")); assertEquals(1, indexes.size()); }
@Test public void testSchemaLoad() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/Test.vdb"); //ensure that datatypes are set Table t = tm.getGroupID("Northwind.Northwind.dbo.Employees"); assertFalse(t.isVirtual()); }
@Test public void testFunctionMetadata() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/TEIIDDES992_VDB.vdb"); Map<String, FunctionMethod> functions = tm.getMetadataStore().getSchema("TEIIDDES992").getFunctions(); assertEquals(1, functions.size()); FunctionMethod fm = functions.values().iterator().next(); assertEquals("mmuuid:5c2cede9-0e18-4e4c-a531-34507abf0ff8", fm.getUUID()); assertEquals("sampleFunction", fm.getName()); assertEquals(1, fm.getInputParameters().size()); assertEquals("mmuuid:f9ded2ae-9652-414e-b5a9-74185f8703c0", fm.getOutputParameter().getUUID()); assertNotNull(fm.getInputParameters().get(0).getParent()); }