test/jdk/tools/jlink/ReleaseImplementorTest.java
author prr
Fri, 25 May 2018 12:12:24 -0700
changeset 50347 b2f046ae8eb6
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42699
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     1
/*
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     4
 *
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     8
 *
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    13
 * accompanied this code).
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    14
 *
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    18
 *
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    21
 * questions.
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    22
 */
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    23
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    24
import java.io.InputStream;
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    25
import java.nio.file.Files;
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    26
import java.nio.file.Path;
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    27
import java.nio.file.Paths;
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    28
import java.util.Properties;
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    29
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    30
/*
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    31
 * @test
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    32
 * @bug 8171316
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    33
 * @summary Add IMPLEMENTOR property to the release file
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    34
 * @run main ReleaseImplementorTest
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    35
 */
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    36
public class ReleaseImplementorTest {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    37
    public static void main(String[] args) throws Exception {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    38
        Properties props = new Properties();
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    39
        Path release = Paths.get(System.getProperty("test.jdk"), "release");
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    40
        try (InputStream in = Files.newInputStream(release)) {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    41
            props.load(in);
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    42
        }
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    43
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    44
        if (!props.containsKey("IMPLEMENTOR")) {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    45
            throw new RuntimeException("IMPLEMENTOR key is missing");
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    46
        }
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    47
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    48
        String implementor = props.getProperty("IMPLEMENTOR");
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    49
        if (implementor.length() < 3) {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    50
            throw new RuntimeException("IMPLEMENTOR value is not expected length");
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    51
        }
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    52
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    53
        if (implementor.charAt(0) != '"' ||
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    54
            implementor.charAt(implementor.length() - 1) != '"') {
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    55
            throw new RuntimeException("IMPLEMENTOR value not quoted property");
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    56
        }
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    57
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    58
        System.out.println("IMPLEMENTOR is " + implementor);
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    59
    }
786e60e05105 8171316: Add IMPLEMENTOR property to the release file
sundar
parents:
diff changeset
    60
}