diff -r 000000000000 -r 24b6c30fbf71 test/java/util/prefs/Preferences/XMLPreferencesTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/prefs/Preferences/XMLPreferencesTest.java Wed Jun 24 17:29:29 2009 +0200 @@ -0,0 +1,97 @@ +/* + * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + + +import java.io.ByteArrayInputStream; +import sun.util.xml.PrefsXmlSupport; + +import java.io.ByteArrayOutputStream; +import java.util.prefs.Preferences; + +/** Checks whether reading and writing via standard DOM and simplified API + * results in same results. + * + * @author Jaroslav Tulach + */ +public class XMLPreferencesTest { + private static PrefsXmlSupport FULL = new com.sun.xml.internal.PrefsXmlSupportImpl(); + private static PrefsXmlSupport SIMPLE = new sun.util.xml.DefaultPrefsXmlSupport(); + + + public static void main(String[] args) throws Exception { + XMLPreferencesTest test = new XMLPreferencesTest(); + test.testCompareOutput(); + test.testCompareInput(); + } + + + public XMLPreferencesTest() { + } + + public void testCompareOutput() throws Exception { + Preferences p = Preferences.userRoot().node("a/b/c"); + p.put("ahoj", "simple"); + p.putInt("kuk", 1); + p.putBoolean("multi", true); + p.node("child").putBoolean("data", false); + p.node("empty"); + p.parent().putDouble("visible", 1.0); + + ByteArrayOutputStream full = new ByteArrayOutputStream(); + FULL.export(full, p, true); + + ByteArrayOutputStream simple = new ByteArrayOutputStream(); + SIMPLE.export(simple, p, true); + if (full.toString().equals(simple.toString())) { + // OK + System.err.println("OK: testCompareOutput"); + } else { + assert false : + "Full version differs from simplified. Full:\n" + full + "\nSimple:\n" + simple; + } + } + + public void testCompareInput() throws Exception { + /* + String text = ""; + + Properties p1 = new Properties(); + { + ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes("UTF-8")); + FULL.load(p1, is); + } + + Properties p2 = new Properties(); + { + ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes("UTF-8")); + SIMPLE.load(p2, is); + } + + assert p1.equals(p2) : "P1: " + p1 + "\nP2: " + p2; + System.err.println("OK: testCompareInput"); + */ + } + +} \ No newline at end of file