595
596 private static void testCreateTempFile(String prefix, String suffix,
597 File directory) {
598 // createTempFile(String prefix, String suffix, File directory)
599 boolean exceptionThrown = false;
600 boolean shortPrefix = (prefix.length() < 3);
601 if (shortPrefix) {
602 try {
603 File.createTempFile(prefix, suffix, directory);
604 } catch (IllegalArgumentException ex) {
605 if ("Prefix string too short".equals(ex.getMessage()))
606 exceptionThrown = true;
607 } catch (IOException ioe) {
608 System.err.println("IOException happens in testCreateTempFile");
609 System.err.println(ioe.getMessage());
610 }
611 } else {
612 try {
613 File.createTempFile(prefix, suffix, directory);
614 } catch (IOException ex) {
615 if (ExceptionMsg.equals(ex.getMessage()))
616 exceptionThrown = true;
617 }
618 }
619 if (!exceptionThrown) {
620 throw new RuntimeException("createTempFile() should throw"
621 + (shortPrefix ? " IllegalArgumentException"
622 : " IOException"));
623 }
624 }
625 }
|
595
596 private static void testCreateTempFile(String prefix, String suffix,
597 File directory) {
598 // createTempFile(String prefix, String suffix, File directory)
599 boolean exceptionThrown = false;
600 boolean shortPrefix = (prefix.length() < 3);
601 if (shortPrefix) {
602 try {
603 File.createTempFile(prefix, suffix, directory);
604 } catch (IllegalArgumentException ex) {
605 if ("Prefix string too short".equals(ex.getMessage()))
606 exceptionThrown = true;
607 } catch (IOException ioe) {
608 System.err.println("IOException happens in testCreateTempFile");
609 System.err.println(ioe.getMessage());
610 }
611 } else {
612 try {
613 File.createTempFile(prefix, suffix, directory);
614 } catch (IOException ex) {
615 String err = "Unable to create temporary file";
616 if (err.equals(ex.getMessage()))
617 exceptionThrown = true;
618 else {
619 throw new RuntimeException("Get IOException with message, "
620 + ex.getMessage() + ", expect message, "+ err);
621 }
622 }
623 }
624 if (!exceptionThrown) {
625 throw new RuntimeException("createTempFile() should throw"
626 + (shortPrefix ? " IllegalArgumentException"
627 : " IOException"));
628 }
629 }
630 }
|