public String getContentOfTestFile( final String testFilePath ) throws IOException { final File file = UnitTestUtil.getTestDataFile(testFilePath); return ObjectConverterUtil.convertFileToString(file); }
/** * 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); }
public static File getTestScratchFile(String fileName) { // Create the input stream ... String path = UnitTestUtil.getTestScratchPath(); File file = new File(path, fileName); return file; }
helpTestEquals(obj1); helpTestEqualsTransitivity(obj1, obj2); helpTestHashCode(equal, obj1, obj2); helpTestEquals(obj2); Comparable comp1 = (Comparable)obj1; Comparable comp2 = (Comparable)obj2; helpTestCompareTo(correctCompareToResult, comp1, comp2); helpTestReflexiveCompareTo(comp1); // doesn't do anything if obj1 == null helpTestReflexiveCompareTo(comp2); // doesn't do anything if obj2 == null
public void testSerialize() throws Exception { ServiceInvocationStruct struct = new ServiceInvocationStruct(new Object[] {new Integer(1), "hello"}, "doSomething", TestServiceInvocationStruct.class); Object serialized = UnitTestUtil.helpSerialize(struct); assertNotNull(serialized); assertTrue(serialized instanceof ServiceInvocationStruct); ServiceInvocationStruct copy = (ServiceInvocationStruct)serialized; assertTrue(Arrays.equals(struct.args, copy.args)); assertEquals(struct.methodName, copy.methodName); assertEquals(struct.targetClass, copy.targetClass); } }
public static void enableTraceLogging(String loggerName) { enableLogging(Level.FINEST, loggerName); }
public void testSerialization() throws Exception { String testString = "This is test string for testing ByteLobChunk"; //$NON-NLS-1$ LobChunk chunk = new LobChunk(testString.getBytes(), true); LobChunk result = UnitTestUtil.helpSerialize(chunk); assertTrue(Arrays.equals(chunk.getBytes(), result.getBytes())); assertTrue(result.isLast()); }
public void testNoPassword() throws Exception { SocketUtil.loadKeyStore(UnitTestUtil.getTestDataFile("metamatrix.keystore").getAbsolutePath(), null, "JKS"); //$NON-NLS-1$ //$NON-NLS-2$ }
@Test public void testSerialize() throws Exception { ArrayImpl a1 = new ArrayImpl((Object[])new Integer[] {1, 2, 3}); a1 = UnitTestUtil.helpSerialize(a1); assertEquals(1, a1.getValues()[0]); } }
@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); }
@BeforeClass public static void beforeClass() throws IOException { FileWriter f = new FileWriter(UnitTestUtil.getTestScratchPath()+"/foo"); f.write("ResourceContents"); f.close(); root = VFS.getChild("location"); fileMount = VFS.mountReal(new File(UnitTestUtil.getTestScratchPath()), root); }
@Test public void testUTF8() throws Exception { FileInputStream fis = new FileInputStream(UnitTestUtil.getTestDataFile("legal_notice.xml")); //$NON-NLS-1$ ReaderInputStream ris = new ReaderInputStream(new FileReader(UnitTestUtil.getTestDataFile("legal_notice.xml")), Charset.forName("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$ int value; while (true) { value = fis.read(); assertEquals(value, ris.read()); if (value == -1) { break; } } }
@Test public void testReferencePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialClob clob = new SerialClob(testString.toCharArray()); ClobType cv = new ClobType(clob); cv.setReferenceStreamId(null); // now force to serialize ClobType read = UnitTestUtil.helpSerialize(cv); assertTrue(read.length() > 0); assertEquals(testString, read.getSubString(1, testString.length())); }
@Test(expected=SAXException.class) public void testModelNameUniqueness() throws Exception { FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/model-not-unique-vdb.xml"); VDBMetadataParser.validate(in); }
public static FileStorageManager getStorageManager(Integer openFiles, String dir) throws TeiidComponentException { FileStorageManager sm = new FileStorageManager(); sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$ if (openFiles != null) { sm.setMaxOpenFiles(openFiles); } sm.initialize(); return sm; }
@Test public void testCompatibility() throws Exception { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(UnitTestUtil.getTestDataFile("handshake.ser"))); Handshake hs = (Handshake)ois.readObject(); assertEquals(AuthenticationType.USERPASSWORD, hs.getAuthType()); }
@Test public void testReferencePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialBlob blob = new SerialBlob(testString.getBytes()); BlobType bv = new BlobType(blob); bv.setReferenceStreamId(null); // now force to serialize BlobType read = UnitTestUtil.helpSerialize(bv); assertNull(read.getReferenceStreamId()); assertEquals(testString, new String(read.getBytes(1, (int)blob.length()))); }
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! } }
@Test public void test81Schema() throws Exception { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(UnitTestUtil.getTestDataFile("schema.ser"))); Schema schema = (Schema) ois.readObject(); assertNotNull(schema.getFunctions()); }
public void testBlobValuePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialBlob blob = new SerialBlob(testString.getBytes()); BlobType bv = new BlobType(blob); String key = bv.getReferenceStreamId(); // now force to serialize BlobType read = UnitTestUtil.helpSerialize(bv); // make sure we have kept the reference stream id assertEquals(key, read.getReferenceStreamId()); // and lost the original object assertNull(read.getReference()); }