< prev index next >

test/jdk/java/util/prefs/ExportSubtree.java

Print this page

        

*** 21,59 **** * questions. */ /* @test ! * @bug 6203576 4700020 7197662 * @summary checks if the output of exportSubtree() is identical to * the output from previous release. * @run main/othervm -Djava.util.prefs.userRoot=. ExportSubtree */ import java.io.*; import java.util.prefs.*; public class ExportSubtree { public static void main(String[] args) throws Exception { - try - { - //File f = new File(System.getProperty("test.src", "."), "TestPrefs.xml"); ByteArrayInputStream bais = new ByteArrayInputStream(importPrefs.getBytes("utf-8")); Preferences.importPreferences(bais); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Preferences.userRoot().node("testExportSubtree").exportSubtree(baos); Preferences.userRoot().node("testExportSubtree").removeNode(); if (!expectedResult.equals(baos.toString())) { ! //System.out.print(baos.toString()); ! //System.out.print(expectedResult); throw new IOException("exportSubtree does not output expected result"); } } - catch( Exception e ) { - e.printStackTrace(); - } - } static String ls = System.getProperty("line.separator"); static String importPrefs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">" --- 21,52 ---- * questions. */ /* @test ! * @bug 6203576 4700020 7197662 8217777 * @summary checks if the output of exportSubtree() is identical to * the output from previous release. * @run main/othervm -Djava.util.prefs.userRoot=. ExportSubtree */ import java.io.*; import java.util.prefs.*; public class ExportSubtree { public static void main(String[] args) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(importPrefs.getBytes("utf-8")); Preferences.importPreferences(bais); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Preferences.userRoot().node("testExportSubtree").exportSubtree(baos); Preferences.userRoot().node("testExportSubtree").removeNode(); if (!expectedResult.equals(baos.toString())) { ! System.out.print("Actual: \n"+baos.toString()); ! System.out.print("Expected: \n"+expectedResult); throw new IOException("exportSubtree does not output expected result"); } } static String ls = System.getProperty("line.separator"); static String importPrefs = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">"
*** 74,84 **** + " </node>" + " </root>" + "</preferences>"; static String expectedResult = ! "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + ls + "<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">" + ls + "<preferences EXTERNAL_XML_VERSION=\"1.0\">" + ls + " <root type=\"user\">" + ls + " <map/>" + ls + " <node name=\"testExportSubtree\">" --- 67,77 ---- + " </node>" + " </root>" + "</preferences>"; static String expectedResult = ! "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" + ls + "<!DOCTYPE preferences SYSTEM \"http://java.sun.com/dtd/preferences.dtd\">" + ls + "<preferences EXTERNAL_XML_VERSION=\"1.0\">" + ls + " <root type=\"user\">" + ls + " <map/>" + ls + " <node name=\"testExportSubtree\">"
< prev index next >