view test/org/openjdk/jigsaw/hello-json-custom.sh @ 5630:8ddc73840820

Expanded the JSON-based module descriptor support. It should now support all of the features that module-info.java supports. Also added encoding detection to the JSON parser code. According to http://www.ietf.org/rfc/rfc4627.txt section 3 a JSON file should always be in unicode. The JSON parser can now deal with UTF-8, UTF-16 and UTF-32 (there are test files included to test this functionality too). Added, more tests, including a test that shows how a module-info.json file can be expanded with custom metadata, very much like what it could look for OSGi.
author davidb
date Tue, 15 May 2012 10:57:06 +0100
parents
children 1d2576346081
line wrap: on
line source
#! /bin/sh

# Copyright (c) 2012, Red Hat and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.

# @test
# @summary HelloJSON with Custom Metadata in the module definition. 

exec sh ${TESTSRC:-.}/tester.sh $0

: hellojsoncustom pass

modulejson com.greetings.json.custom
{ 
    "module" : 
    {
    	"name" : "com.greetings.json.custom",
    	"version" : "0.1",
    	"requires" : [{"name" : "org.astro.json.custom", "version" : "1.2"}],
    	"org.example.import.package" :
    	[
    	    { "name" : "org.astro.json.custom", "version" : "1.2.3" },
    	    { "name" : "org.astro.json.custom.sub", "version" : "[1.1, 2.0)" }
    	],
    	"org.example.license" : "http://www.opensource.org/licenses/gpl-3.0",
    	"org.example.require.capability" : 
    	[
    	    { 
    	        "name" : "org.example.somecapability",
    	        "directives" : 
    	        [
    	           "filter" : "(org.example.somecapability=sometype)"
    	        ]
    	    }
    	],
    	"org.example.provide.capability" : 
    	[
    	    {
    	        "name" : "org.example.someothercapability", 
    	        "attributes" : 
    	        [
    	            "org.example.someothercapability" : "somevalue"
    	        ]
    	    }
    	],
    	"class" : "com.greetings.json.custom.HelloJSONCustom"
    }
}

package com.greetings.json.custom;
import org.astro.json.custom.World;
public class HelloJSONCustom {
    public static void main(String[] args) {
        System.out.println("Hello, " + World.name() + " via JSON module descriptor with Custom Metadata!");
    }
}

modulejson org.astro.json.custom
{
    "module" :
    {
    	"name" : "org.astro.json.custom",
    	"version" : "1.2",
    	"exports" : 
    	[
    	    {
    	        "name" : "org.astro.json.custom", 
    	        "org.example.version" : "1.2.3.qualifier"
    	    },
            {
                "name" : "org.astro.json.custom.sub", 
                "org.example.version" : "9",
                "uses" : [ "org.astro.json.custom" ]
            }
    	]
	}
}

package org.astro.json.custom;
public class World {
    public static String name() {
	    return "JSON (custom) world";
    }
}