test/java/util/prefs/ExportSubtree.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26    @bug 6203576 4700020
  27    @summary checks if the output of exportSubtree() is identical to
  28             the output from previous release.

  29  */
  30 
  31 import java.io.*;
  32 import java.util.prefs.*;
  33 
  34 public class ExportSubtree {
  35    public static void main(String[] args) throws Exception {
  36       try
  37       {
  38           //File f = new File(System.getProperty("test.src", "."), "TestPrefs.xml");
  39           ByteArrayInputStream bais = new ByteArrayInputStream(importPrefs.getBytes("utf-8"));
  40           Preferences.importPreferences(bais);
  41           ByteArrayOutputStream baos = new ByteArrayOutputStream();
  42           Preferences.userRoot().node("testExportSubtree").exportSubtree(baos);
  43           Preferences.userRoot().node("testExportSubtree").removeNode();
  44           if (!expectedResult.equals(baos.toString())) {
  45               //System.out.print(baos.toString());
  46               //System.out.print(expectedResult);
  47               throw new IOException("exportSubtree does not output expected result");
  48           }




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 /* @test
  26  * @bug 6203576 4700020 7197662
  27  * @summary checks if the output of exportSubtree() is identical to
  28  *          the output from previous release.
  29  * @run main/othervm -Djava.util.prefs.userRoot=. ExportSubtree
  30  */
  31 
  32 import java.io.*;
  33 import java.util.prefs.*;
  34 
  35 public class ExportSubtree {
  36    public static void main(String[] args) throws Exception {
  37       try
  38       {
  39           //File f = new File(System.getProperty("test.src", "."), "TestPrefs.xml");
  40           ByteArrayInputStream bais = new ByteArrayInputStream(importPrefs.getBytes("utf-8"));
  41           Preferences.importPreferences(bais);
  42           ByteArrayOutputStream baos = new ByteArrayOutputStream();
  43           Preferences.userRoot().node("testExportSubtree").exportSubtree(baos);
  44           Preferences.userRoot().node("testExportSubtree").removeNode();
  45           if (!expectedResult.equals(baos.toString())) {
  46               //System.out.print(baos.toString());
  47               //System.out.print(expectedResult);
  48               throw new IOException("exportSubtree does not output expected result");
  49           }