Path: blob/master/test/jdk/tools/jpackage/windows/WinUrlTest.java
41149 views
/*1* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.util.ArrayList;24import jdk.jpackage.test.PackageTest;25import jdk.jpackage.test.JPackageCommand;26import jdk.jpackage.test.Annotations.Test;27import jdk.jpackage.test.Annotations.Parameters;28import java.util.List;29import java.util.Objects;30import java.util.stream.Stream;31import jdk.jpackage.test.PackageType;3233/**34* Test all possible combinations of --about-url, --win-update-url and35* --win-help-url parameters.36*/3738/*39* @test40* @summary jpackage with --about-url, --win-update-url and --win-help-url41* parameters42* @library ../helpers43* @key jpackagePlatformPackage44* @build jdk.jpackage.test.*45* @build WinUrlTest46* @requires (os.family == "windows")47* @modules jdk.jpackage/jdk.jpackage.internal48* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main49* --jpt-run=WinUrlTest50*/51public class WinUrlTest {5253static enum URL {54About("--about-url"),55Update("--win-update-url"),56Help("--win-help-url");5758URL(String cliOption) {59this.cliOption = cliOption;60}6162final String cliOption;63}6465public WinUrlTest(Boolean withAboutURL, Boolean withUpdateURL,66Boolean withHelpURL) {67urls = Stream.of(68withAboutURL ? URL.About : null,69withUpdateURL ? URL.Update : null,70withHelpURL ? URL.Help : null71).filter(Objects::nonNull).toList();72}7374@Parameters75public static List<Object[]> data() {76List<Object[]> data = new ArrayList<>();77for (var withAboutURL : List.of(Boolean.TRUE, Boolean.FALSE)) {78for (var withUpdateURL : List.of(Boolean.TRUE, Boolean.FALSE)) {79for (var withHelpURL : List.of(Boolean.TRUE, Boolean.FALSE)) {80var args = new Object[]{withAboutURL, withUpdateURL, withHelpURL};81if (Stream.of(args).anyMatch(Boolean.TRUE::equals)) {82data.add(args);83}84}85}86}8788return data;89}9091@Test92public void test() {93PackageTest test = new PackageTest()94.forTypes(PackageType.WINDOWS)95.configureHelloApp();9697test.addInitializer(JPackageCommand::setFakeRuntime);98test.addInitializer(this::setPackageName);99100urls.forEach(url -> {101test.addInitializer(cmd -> cmd.addArguments(url.cliOption,102"http://localhost/" + url.name().toLowerCase()));103});104105test.run();106}107108private void setPackageName(JPackageCommand cmd) {109StringBuilder sb = new StringBuilder(cmd.name());110sb.append("With");111urls.forEach(url -> sb.append(url.name()));112cmd.setArgumentValue("--name", sb.toString());113}114115private final List<URL> urls;116}117118119