Skip to content

Commit

Permalink
8264512: jdk/test/jdk/java/util/prefs/ExportNode.java relies on defau…
Browse files Browse the repository at this point in the history
…lt platform encoding

Reviewed-by: naoto
  • Loading branch information
Brian Burkhalter committed Apr 5, 2021
1 parent a0ec2cb commit 104e925
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions test/jdk/java/util/prefs/ExportNode.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2021, Oracle and/or its affiliates. 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
Expand Down Expand Up @@ -30,25 +30,46 @@
* @run main/othervm -Djava.util.prefs.userRoot=. ExportNode
* @author Konstantin Kladko
*/
import java.util.prefs.*;
import java.io.*;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

public class ExportNode {
private static final String NODE_NAME_1 = "ExportNodeTestName1";
private static final String NODE_NAME_2 = "ExportNodeTestName2";

public static void main(String[] args) throws
BackingStoreException, IOException {
Preferences N1 = Preferences.userRoot().node("ExportNodeTest1");
N1.put("ExportNodeTestName1","ExportNodeTestValue1");
Preferences N2 = N1.node("ExportNodeTest2");
N2.put("ExportNodeTestName2","ExportNodeTestValue2");
ByteArrayOutputStream exportStream = new ByteArrayOutputStream();
N2.exportNode(exportStream);

// Removal of preference node should always succeed on Solaris/Linux
// by successfully acquiring the appropriate file lock (4947349)
N1.removeNode();

if (((exportStream.toString()).lastIndexOf("ExportNodeTestName2")== -1) ||
((exportStream.toString()).lastIndexOf("ExportNodeTestName1")!= -1)) {
}
BackingStoreException, IOException {
Preferences N1 = Preferences.userRoot().node("ExportNodeTest1");
N1.put(NODE_NAME_1,"ExportNodeTestValue1");
Preferences N2 = N1.node("ExportNodeTest2");
N2.put(NODE_NAME_2,"ExportNodeTestValue2");
ByteArrayOutputStream exportStream = new ByteArrayOutputStream();
N2.exportNode(exportStream);

// Removal of preference node should always succeed on Solaris/Linux
// by successfully acquiring the appropriate file lock (4947349)
N1.removeNode();

String streamAsString = exportStream.toString("UTF-8");

StringBuilder sb = null;
if (streamAsString.lastIndexOf(NODE_NAME_2) == -1) {
if (sb == null)
sb = new StringBuilder();
sb.append(NODE_NAME_2 + " should have been found");
}
if (streamAsString.lastIndexOf(NODE_NAME_1) != -1) {
if (sb == null)
sb = new StringBuilder();
else
sb.append("; ");
sb.append(NODE_NAME_1 + " should *not* have been found");
}

if (sb != null)
throw new RuntimeException(sb.toString());
}
}

3 comments on commit 104e925

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 104e925 Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 104e925 Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch GoeLin-backport-104e925d in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 104e925d from the openjdk/jdk repository.

The commit being backported was authored by Brian Burkhalter on 5 Apr 2021 and was reviewed by Naoto Sato.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-104e925d:GoeLin-backport-104e925d
$ git checkout GoeLin-backport-104e925d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-104e925d

Please sign in to comment.