test/jdk/tools/jpackage/helpers/jdk/jpackage/test/FileAssociations.java
branchJDK-8200758-branch
changeset 58301 e0efb29609bd
child 58416 f09bf58c1f17
equal deleted inserted replaced
58172:bf06a1d3aef6 58301:e0efb29609bd
       
     1 /*
       
     2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     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 package jdk.jpackage.test;
       
    24 
       
    25 import java.nio.file.Path;
       
    26 import java.util.Map;
       
    27 
       
    28 
       
    29 public class FileAssociations {
       
    30     public FileAssociations(String faSuffixName) {
       
    31         suffixName = faSuffixName;
       
    32         setFilename("fa");
       
    33         setDescription("jpackage test extention");
       
    34     }
       
    35 
       
    36     public void createFile() {
       
    37         Test.createPropertiesFile(file,
       
    38                 Map.entry("extension", suffixName),
       
    39                 Map.entry("mime-type", getMime()),
       
    40                 Map.entry("description", description));
       
    41     }
       
    42 
       
    43     final public FileAssociations setFilename(String v) {
       
    44         file = Test.workDir().resolve(v + ".properties");
       
    45         return this;
       
    46     }
       
    47 
       
    48     final public FileAssociations setDescription(String v) {
       
    49         description = v;
       
    50         return this;
       
    51     }
       
    52 
       
    53     public Path getPropertiesFile() {
       
    54         return file;
       
    55     }
       
    56 
       
    57     public String getSuffix() {
       
    58         return "." + suffixName;
       
    59     }
       
    60 
       
    61     public String getMime() {
       
    62         return "application/x-jpackage-" + suffixName;
       
    63     }
       
    64 
       
    65     private Path file;
       
    66     final private String suffixName;
       
    67     private String description;
       
    68 }