📄 testprivatedata.java
字号:
System.out.println( "ERROR(" + i + ", 3): rpd(" + dataWithPrivacy + ", 1): " + dataWithPrivacyRemoved + "\n" + " Expected: " + subTest.get(3)); numErrors++; } // 4 String dataWithPrivacyRemoved2 = STAFUtil.removePrivacyDelimiters( dataWithPrivacy, 2); System.out.println("rpd(" + dataWithPrivacy + ", 2): " + dataWithPrivacyRemoved2); if (dataWithPrivacyRemoved2 == null) { if (subTest.get(4) != null) { System.out.println( "ERROR(" + i + ", 4): rpd(" + dataWithPrivacy + ", 2): " + dataWithPrivacyRemoved2 + "\n" + " Expected: " + subTest.get(4)); numErrors++; } } else if (!dataWithPrivacyRemoved2.equals((String)subTest.get(4))) { System.out.println( "ERROR(" + i + ", 4): rpd(" + dataWithPrivacy + ", 2): " + dataWithPrivacyRemoved2 + "\n" + " Expected: " + subTest.get(4)); numErrors++; } // 5 String dataWithAllPrivacyRemoved = STAFUtil.removePrivacyDelimiters(dataWithPrivacy, 0); System.out.println("rpd(" + dataWithPrivacy + ", 0): " + dataWithAllPrivacyRemoved); if (dataWithAllPrivacyRemoved == null) { if (subTest.get(5) != null) { System.out.println( "ERROR(" + i + ", 5): rpd(" + dataWithPrivacy + ", 0): " + dataWithAllPrivacyRemoved + "\n" + " Expected: " + subTest.get(5)); numErrors++; } } else if (!dataWithAllPrivacyRemoved.equals((String)subTest.get(5))) { System.out.println( "ERROR(" + i + ", 5): rpd(" + dataWithPrivacy + ", 0): " + dataWithAllPrivacyRemoved + "\n" + " Expected: " + subTest.get(5)); numErrors++; } // 6 String escapedData = STAFUtil.escapePrivacyDelimiters(data); System.out.println("\nepd(" + data + "): " + escapedData ); if (escapedData == null) { if (subTest.get(6) != null) { System.out.println( "ERROR(" + i + ", 6): epd(" + data + "): " + escapedData + "\n" + " Expected: " + subTest.get(6)); numErrors++; } } else if (!escapedData.equals((String)subTest.get(6))) { System.out.println( "ERROR(" + i + ", 6): epd(" + data + "): " + escapedData + "\n" + " Expected: " + subTest.get(6)); numErrors++; } // 7 dataWithPrivacy = STAFUtil.addPrivacyDelimiters(escapedData); System.out.println("apd(" + escapedData + "): " + dataWithPrivacy); if (dataWithPrivacy == null) { if (subTest.get(7) != null) { System.out.println( "ERROR(" + i + ", 7): apd(" + escapedData + "): " + dataWithPrivacy + "\n" + " Expected: " + subTest.get(7)); numErrors++; } } else if (!dataWithPrivacy.equals((String)subTest.get(7))) { System.out.println( "ERROR(" + i + ", 7): apd(" + escapedData + "): " + dataWithPrivacy + "\n" + " Expected: " + subTest.get(7)); numErrors++; } // 8 dataWithPrivacyRemoved = STAFUtil.removePrivacyDelimiters(dataWithPrivacy, 1); System.out.println("rpd(" + dataWithPrivacy + ", 1): " + dataWithPrivacyRemoved); if (dataWithPrivacyRemoved == null) { if (data != null) { System.out.println( "ERROR(" + i + ", 8): rpd(" + dataWithPrivacy + ", 1): " + dataWithPrivacyRemoved + "\n" + " Expected: " + data); numErrors++; } } else if (!dataWithPrivacyRemoved.equals(data)) { System.out.println( "ERROR(:" + i + ", 8): rpd(" + dataWithPrivacy + ", 1): " + dataWithPrivacyRemoved + "\n" + " Expected: " + data); numErrors++; } // 9 dataWithAllPrivacyRemoved = STAFUtil.removePrivacyDelimiters(dataWithPrivacy); System.out.println( "rpd(" + dataWithPrivacy + "): " + dataWithAllPrivacyRemoved); if (dataWithAllPrivacyRemoved == null) { if (data != null) { System.out.println( "ERROR(" + i + ", 9): rpd(" + dataWithPrivacy + "): " + dataWithAllPrivacyRemoved + "\n" + " Expected: " + data); numErrors++; } } else if (!dataWithAllPrivacyRemoved.equals(data)) { System.out.println( "ERROR:(" + i + ", 9): rpd(" + dataWithPrivacy + "): " + dataWithAllPrivacyRemoved + "\n Expected: " + data); numErrors++; } } // Test compareSTAFVersion method // These versions should all be < actual version of STAF running String[] requiredVersionList = { "3", "3.0", "3.0.0", "3.1 Beta 1", "3.1 Alpha 1", "2.6.9", "2"}; for (int i = 0; i < requiredVersionList.length; ++i) { // Verify that the required version of STAF is running on the // local service machine. STAFResult res = STAFUtil.compareSTAFVersion( "local", handle, requiredVersionList[i]); if (res.rc != STAFResult.Ok) { if (res.rc == STAFResult.InvalidSTAFVersion) { System.out.println( "ERROR: Minimum required STAF version for this " + "service is not running. " + res.result); numErrors++; } else { System.out.println( "ERROR: Error verifying the STAF version. RC: " + res.rc + ", Additional info: " + res.result); numErrors++; } } } // Test STAFVersion class if ((new STAFVersion("3")).compareTo((new STAFVersion("3.0"))) != 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Versions 3 and 3.0 are not equal"); numErrors++; } if ((new STAFVersion("3")).compareTo((new STAFVersion("3.0.0"))) != 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Versions 3 and 3.0.0 are not equal"); numErrors++; } if ((new STAFVersion("3")).compareTo((new STAFVersion("3.0.0.0"))) != 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Versions 3 and 3.0.0.0 are not equal"); numErrors++; } if ((new STAFVersion("3")).compareTo((new STAFVersion("3.0.0 "))) != 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Versions 3 and 3.0.0 are not equal"); numErrors++; } if ((new STAFVersion("3.0.0")).compareTo((new STAFVersion("3.1.0"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.0.0 >= 3.1.0"); numErrors++; } if ((new STAFVersion("3.0.2")).compareTo((new STAFVersion("3.0.3"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.0.2 >= 3.0.3"); numErrors++; } if ((new STAFVersion("3.0.0")).compareTo((new STAFVersion("3.1"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.0.0 >= 3.1"); numErrors++; } if ((new STAFVersion("3.0.9")).compareTo((new STAFVersion("3.0.10"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.0.9 >= 3.0.10"); numErrors++; } if ((new STAFVersion("3.0.0.1")).compareTo((new STAFVersion("3.1"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.0.0.1 >= 3.1"); numErrors++; } if ((new STAFVersion("3.1.0 Alpha 1")).compareTo((new STAFVersion("3.1.0 Beta 1"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.1.0 Alpha1 >= 3.1.0 Beta 1"); numErrors++; } if ((new STAFVersion("3.1.0 Beta 1")).compareTo((new STAFVersion("3.1.0"))) >= 0) { System.out.println( "ERROR: STAFVersion.compareTo(): " + "Version 3.1.0 Beta1 >= 3.1.0"); numErrors++; } if (numErrors == 0) { System.out.println("\nTest completed successfully"); } else { System.out.println("\nTest failed with " + numErrors +" errors"); } } private static STAFHandle handle;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -