public void test() { try { test1ResultIsTrue = Helper.compareCharArrays(array1, array2); test2ResultIsTrue = Helper.compareCharArrays(array1, array3); } catch (Exception e) { this.e = e; throw new TestErrorException( "An exception should not have been thrown when comparing char array content."); } }
public void test() { try { test1ResultIsTrue = Helper.classIsSubclass(LargeProject.class, null); } catch (Exception e) { this.e = e; throw new TestErrorException( "An exception should not have been thrown when checking for status as a subclass when superclass is null."); } }
protected void verify() { if (results.size() != expectedResults.size()) { throw new TestErrorException("ReportQuery test failed: The result size are different"); } BigDecimal expected = (BigDecimal) ((ReportQueryResult) expectedResults.firstElement()).getByIndex(0); BigDecimal result = (BigDecimal) ConversionManager.getDefaultManager() .convertObject( ((ReportQueryResult) results.firstElement()).getByIndex(0), BigDecimal.class); if (!Helper.compareBigDecimals(expected, result)) { throw new TestErrorException( "ReportQuery test failed: The results did not match (" + expected + ", " + result + ")"); } }
// Bug#3854296. Test if byte[], Byte[], char[] and Character[] are converted to String correctly. public class ConvertByteCharArrayToStringTest extends AutoVerifyTestCase { String hexString = Helper.buildHexStringFromBytes(new byte[] {1, 56, -128, 127}); String testString = "A test string"; byte[] byteArray; Byte[] byteOArray; char[] charArray; Character[] charOArray; String byteString; String byteOString; String charString; String charOString; public ConvertByteCharArrayToStringTest() { setDescription( "Test if byte[], Byte[], char[] and Character[] are converted to String correctly."); } public void setup() { // Convert to an array first byteArray = (byte[]) ConversionManager.getDefaultManager().convertObject(hexString, ClassConstants.APBYTE); byteOArray = (Byte[]) ConversionManager.getDefaultManager().convertObject(hexString, ClassConstants.ABYTE); charArray = (char[]) ConversionManager.getDefaultManager().convertObject(testString, ClassConstants.APCHAR); charOArray = (Character[]) ConversionManager.getDefaultManager().convertObject(testString, ClassConstants.ACHAR); } public void test() { // Convert back to a string byteString = (String) ConversionManager.getDefaultManager().convertObject(byteArray, ClassConstants.STRING); byteOString = (String) ConversionManager.getDefaultManager().convertObject(byteOArray, ClassConstants.STRING); charString = (String) ConversionManager.getDefaultManager().convertObject(charArray, ClassConstants.STRING); charOString = (String) ConversionManager.getDefaultManager().convertObject(charOArray, ClassConstants.STRING); } public void verify() { if (!byteString.equals(hexString)) { throw (new TestErrorException( "Conversion of string to byte[] then to string failed. The original string is" + hexString + ", the returned string is " + byteString)); } if (!byteOString.equals(hexString)) { throw (new TestErrorException( "Conversion of string to Byte[] then to string failed. The original string is" + hexString + ", the returned string is " + byteOString)); } if (!charString.equals(testString)) { throw (new TestErrorException( "Conversion of string to char[] then to string failed. The original string is" + testString + ", the returned string is " + charString)); } if (!charOString.equals(testString)) { throw (new TestErrorException( "Conversion of string to Character[] then to string failed. The original string is" + testString + ", the returned string is " + charOString)); } } }