test/jdk/tools/jpackage/junit/jdk/jpackage/internal/AppImageFileTest.java
author herrick
Wed, 16 Oct 2019 10:32:08 -0400
branchJDK-8200758-branch
changeset 58648 3bf53ffa9ae7
parent 58606 6e02ff008c16
child 58696 61c44899b4eb
permissions -rw-r--r--
8232279 : Improve test helpers #2 Submitted-by: asemenyuk Reviewed-by: aherrick, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58606
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     1
/*
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     4
 *
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    10
 *
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    15
 * accompanied this code).
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    16
 *
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    20
 *
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    23
 * questions.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    24
 */
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    25
package jdk.jpackage.internal;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    26
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    27
import java.io.IOException;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    28
import java.nio.file.Files;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    29
import java.nio.file.Path;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    30
import java.nio.file.StandardOpenOption;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    31
import java.util.ArrayList;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    32
import java.util.List;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    33
import java.util.Map;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    34
import java.util.LinkedHashMap;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    35
import org.junit.Assert;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    36
import org.junit.Test;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    37
import org.junit.Rule;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    38
import org.junit.rules.TemporaryFolder;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    39
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    40
public class AppImageFileTest {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    41
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    42
    @Rule
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    43
    public final TemporaryFolder tempFolder = new TemporaryFolder();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    44
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    45
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    46
    public void testIdentity() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    47
        Map<String, ? super Object> params = new LinkedHashMap<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    48
        params.put("name", "Foo");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    49
        params.put("app-version", "2.3");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    50
        params.put("description", "Duck is the King");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    51
        AppImageFile aif = create(params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    52
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    53
        Assert.assertEquals("Foo", aif.getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    54
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    55
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    56
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    57
    public void testInvalidCommandLine() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    58
        // Just make sure AppImageFile will tolerate jpackage params that would
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    59
        // never create app image at both load/save phases.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    60
        // People would edit this file just because they can.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    61
        // We should be ready to handle curious minds.
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    62
        Map<String, ? super Object> params = new LinkedHashMap<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    63
        params.put("invalidParamName", "randomStringValue");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    64
        create(params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    65
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    66
        params = new LinkedHashMap<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    67
        params.put("name", "foo");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    68
        params.put("app-version", "");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    69
        create(params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    70
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    71
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    72
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    73
    public void testInavlidXml() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    74
        assertInvalid(createFromXml("<foo/>"));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    75
        assertInvalid(createFromXml("<jpackage-state/>"));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    76
        assertInvalid(createFromXml(
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    77
                "<jpackage-state>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    78
                    "<main-launcher></main-launcher>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    79
                "</jpackage-state>"));
58648
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    80
        assertInvalid(createFromXml(
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    81
                "<jpackage-state>",
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    82
                    "<launcher>A</launcher>",
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    83
                    "<launcher>B</launcher>",
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    84
                "</jpackage-state>"));
58606
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    85
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    86
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    87
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    88
    public void testValidXml() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    89
        Assert.assertEquals("Foo", (createFromXml(
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    90
                "<jpackage-state>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    91
                    "<main-launcher>Foo</main-launcher>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    92
                "</jpackage-state>")).getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    93
58648
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    94
        Assert.assertEquals("Boo", (createFromXml(
58606
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    95
                "<jpackage-state>",
58648
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
    96
                    "<main-launcher>Boo</main-launcher>",
58606
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    97
                    "<main-launcher>Bar</main-launcher>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    98
                "</jpackage-state>")).getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
    99
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   100
        var file = createFromXml(
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   101
                "<jpackage-state>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   102
                    "<main-launcher>Foo</main-launcher>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   103
                    "<launcher></launcher>",
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   104
                "</jpackage-state>");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   105
        Assert.assertEquals("Foo", file.getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   106
        Assert.assertArrayEquals(new String[0],
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   107
                file.getAddLauncherNames().toArray(String[]::new));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   108
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   109
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   110
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   111
    public void testMainLauncherName() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   112
        Map<String, ? super Object> params = new LinkedHashMap<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   113
        params.put("name", "Foo");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   114
        params.put("description", "Duck App Description");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   115
        AppImageFile aif = create(params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   116
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   117
        Assert.assertEquals("Foo", aif.getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   118
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   119
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   120
    @Test
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   121
    public void testAddLauncherNames() throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   122
        Map<String, ? super Object> params = new LinkedHashMap<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   123
        List<Map<String, ? super Object>> launchersAsMap = new ArrayList<>();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   124
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   125
        Map<String, ? super Object> addLauncher2Params = new LinkedHashMap();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   126
        addLauncher2Params.put("name", "Launcher2Name");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   127
        launchersAsMap.add(addLauncher2Params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   128
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   129
        Map<String, ? super Object> addLauncher3Params = new LinkedHashMap();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   130
        addLauncher3Params.put("name", "Launcher3Name");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   131
        launchersAsMap.add(addLauncher3Params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   132
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   133
        params.put("name", "Duke App");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   134
        params.put("description", "Duke App Description");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   135
        params.put("add-launcher", launchersAsMap);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   136
        AppImageFile aif = create(params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   137
58648
3bf53ffa9ae7 8232279 : Improve test helpers #2
herrick
parents: 58606
diff changeset
   138
        List<String> addLauncherNames = aif.getAddLauncherNames();
58606
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   139
        Assert.assertEquals(2, addLauncherNames.size());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   140
        Assert.assertTrue(addLauncherNames.contains("Launcher2Name"));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   141
        Assert.assertTrue(addLauncherNames.contains("Launcher3Name"));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   142
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   143
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   144
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   145
    private AppImageFile create(Map<String, Object> params) throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   146
        AppImageFile.save(tempFolder.getRoot().toPath(), params);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   147
        return AppImageFile.load(tempFolder.getRoot().toPath());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   148
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   149
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   150
    private void assertInvalid(AppImageFile file) {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   151
        Assert.assertNull(file.getLauncherName());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   152
        Assert.assertNull(file.getAddLauncherNames());
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   153
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   154
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   155
    private AppImageFile createFromXml(String... xmlData) throws IOException {
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   156
        Path directory = tempFolder.getRoot().toPath();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   157
        Path path = directory.resolve(AppImageFile.XML_FILENAME);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   158
        path.toFile().mkdirs();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   159
        Files.delete(path);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   160
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   161
        ArrayList<String> data = new ArrayList();
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   162
        data.add("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>");
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   163
        data.addAll(List.of(xmlData));
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   164
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   165
        Files.write(path, data, StandardOpenOption.CREATE,
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   166
                    StandardOpenOption.TRUNCATE_EXISTING);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   167
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   168
        AppImageFile image = AppImageFile.load(directory);
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   169
        return image;
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   170
    }
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   171
6e02ff008c16 8231604: Expand junit test added with JDK-8230920
herrick
parents: 58414
diff changeset
   172
}