RFR: JDK-8224597: create automated tests for platform create-app-image options

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Jun 7 23:09:31 UTC 2019


On 6/7/19 9:52 AM, Alexey Semenyuk wrote:

> Not quite exactly what I meant by suggesting to use xml api. Sorry for 
> not being specific. With DOM and Xpath this can be as simple as the 
> following:

XPath is DOM based = slow. That point is not clear.

--Semyon


> ---
> package sample;
>
> import java.io.FileInputStream;
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.xpath.XPath;
> import javax.xml.xpath.XPathConstants;
> import javax.xml.xpath.XPathFactory;
>
> public class Sample {
>     public static void main(String[] args) throws Exception {
>         DocumentBuilder b = 
> DocumentBuilderFactory.newDefaultInstance().newDocumentBuilder();
>         org.w3c.dom.Document doc = b.parse(new FileInputStream(args[0]));
>
>         XPath xPath = XPathFactory.newInstance().newXPath();
>         // Query for the value of <string> element preceding <key> 
> element
>         // with value equal to CFBundleIdentifier
>         String v = 
> (String)xPath.evaluate("//string[preceding-sibling::key = 
> \"CFBundleIdentifier\"][1]", doc, XPathConstants.STRING);
>
>         if (!v.equals(args[1])) {
>             throw new AssertionError("Unexpected value of 
> CFBundleIdentifier key: [" + v + "]. Expected value: [" + args[1] + "]");
>         }
>     }
> }
> ---
>
> Running the sample:
> java sample.Sample 
> jp_sandbox\jdk\open\src\jdk.jpackage\macosx\classes\jdk\jpackage\internal\resources\Info-lite.plist.template 
> foo
> Exception in thread "main" java.lang.AssertionError: Unexpected value 
> of CFBundleIdentifier key: [DEPLOY_BUNDLE_IDENTIFIER]. Expected value: 
> [foo]
>     at sample.Sample.main(Sample.java:25)
>
> java sample.Sample 
> jp_sandbox\jdk\open\src\jdk.jpackage\macosx\classes\jdk\jpackage\internal\resources\Info-lite.plist.templateDEPLOY_BUNDLE_IDENTIFIER
>
> - Alexey
>
> On 6/6/2019 10:56 PM, Alexander Matveev wrote:
>> http://cr.openjdk.java.net/~almatvee/8224597/webrev.02/
>>
>> Updated OS X tests to use XML APIs to parse Info.plist.
>>
>> Thanks,
>> Alexander
>>
>> On 6/6/2019 2:43 PM, Alexey Semenyuk wrote:
>>> Any particular reason not to use xml api to read xml files?
>>> The way to extract app attributes from xml files produced by 
>>> jpackage looks fragile.
>>>
>>> - Alexey
>>>
>>> On 6/6/2019 5:37 PM, Alexander Matveev wrote:
>>>> Please review the jpackage fix for bug [1] at [2].
>>>>
>>>> This is a fix for the JDK-8200758-branch branch of the open sandbox 
>>>> repository (jpackage).
>>>>
>>>> - Added tests for --win-console, --mac-bundle-identifier and 
>>>> --mac-bundle-name.
>>>>
>>>> [1] https://bugs.openjdk.java.net/browse/JDK-8224597
>>>> [2] http://cr.openjdk.java.net/~almatvee/8224597/webrev.00/
>>>>
>>>> Thanks,
>>>> Alexander
>>>
>>
>


More information about the core-libs-dev mailing list