jdk/test/javax/management/ObjectName/ApplyWildcardTest.java
author uvangapally
Fri, 19 May 2017 15:27:25 +0530
changeset 45232 1e2ad0809162
parent 30376 2ccf2cf7ea48
child 44423 306c020eb154
permissions -rw-r--r--
8175845: Provide javadoc descriptions for jdk.hotspot.agent module Summary: Added description for jdk.hotspot.agent module Reviewed-by: mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 5506
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4716807
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Test the ObjectName.apply(ObjectName) method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *          with wildcards in the key properties value part.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @author Luis-Miguel Alventosa
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 5506
diff changeset
    30
 * @modules java.management
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @run clean ApplyWildcardTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @run build ApplyWildcardTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @run main ApplyWildcardTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class ApplyWildcardTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private static final String positiveTests[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        { "d:k=*", "d:k=\"\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        { "d:k=*", "d:k=" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        { "d:k=*", "d:k=v" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        { "d:k=a*b", "d:k=axyzb" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        { "d:k=a*b,*", "d:k=axyzb,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        { "d:*,k=a*b", "d:k=axyzb,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        { "d:k=?", "d:k=v" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        { "d:k=a?b", "d:k=axb" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        { "d:k=a?b,*", "d:k=axb,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        { "d:*,k=a?b", "d:k=axb,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        { "d:k=?*", "d:k=axyzb" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        { "d:k=a?bc*d", "d:k=axbcyzd" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        { "d:k=a?bc*d,*", "d:k=axbcyzd,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        { "d:*,k=a?bc*d", "d:k=axbcyzd,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        { "d:k1=?,k2=*", "d:k1=a,k2=ab" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        { "d:k1=a?b,k2=c*d", "d:k1=axb,k2=cyzd" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        { "d:k1=a?b,k2=c*d,*", "d:k1=axb,k2=cyzd,k3=v3" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        { "d:*,k1=a?b,k2=c*d", "d:k1=axb,k2=cyzd,k3=v3" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        { "d:k=\"*\"", "d:k=\"\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        { "d:k=\"*\"", "d:k=\"v\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        { "d:k=\"a*b\"", "d:k=\"axyzb\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        { "d:k=\"a*b\",*", "d:k=\"axyzb\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        { "d:*,k=\"a*b\"", "d:k=\"axyzb\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        { "d:k=\"?\"", "d:k=\"v\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        { "d:k=\"a?b\"", "d:k=\"axb\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        { "d:k=\"a?b\",*", "d:k=\"axb\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        { "d:*,k=\"a?b\"", "d:k=\"axb\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        { "d:k=\"?*\"", "d:k=\"axyzb\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        { "d:k=\"a?bc*d\"", "d:k=\"axbcyzd\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        { "d:k=\"a?bc*d\",*", "d:k=\"axbcyzd\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        { "d:*,k=\"a?bc*d\"", "d:k=\"axbcyzd\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        { "d:k1=\"?\",k2=\"*\"", "d:k1=\"a\",k2=\"ab\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        { "d:k1=\"a?b\",k2=\"c*d\"", "d:k1=\"axb\",k2=\"cyzd\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        { "d:k1=\"a?b\",k2=\"c*d\",*", "d:k1=\"axb\",k2=\"cyzd\",k3=\"v3\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        { "d:*,k1=\"a?b\",k2=\"c*d\"", "d:k1=\"axb\",k2=\"cyzd\",k3=\"v3\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static final String negativeTests[][] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        { "d:k=\"*\"", "d:k=" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        { "d:k=*", "d:k=,k2=" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        { "d:k=*", "d:k=v,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        { "d:k=a*b", "d:k=axyzbc" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        { "d:k=a*b,*", "d:k=axyzbc,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        { "d:*,k=a*b", "d:k=axyzbc,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        { "d:k=?", "d:k=xyz" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        { "d:k=a?b", "d:k=ab" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        { "d:k=a?b,*", "d:k=ab,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        { "d:*,k=a?b", "d:k=ab,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        { "d:k=?*", "d:k=axyzb,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        { "d:k=a?bc*d", "d:k=abcd" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        { "d:k=a?bc*d,*", "d:k=abcd,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        { "d:*,k=a?bc*d", "d:k=abcd,k2=v2" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        { "d:k1=?,k2=*", "d:k1=ab,k2=ab" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        { "d:k1=a?b,k2=c*d", "d:k1=ab,k2=cd" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        { "d:k1=a?b,k2=c*d,*", "d:k1=ab,k2=cd,k3=v3" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        { "d:*,k1=a?b,k2=c*d", "d:k1=ab,k2=cd,k3=v3" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        { "d:k=\"*\"", "d:k=\"\",k2=\"\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        { "d:k=\"*\"", "d:k=\"v\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        { "d:k=\"a*b\"", "d:k=\"axyzbc\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        { "d:k=\"a*b\",*", "d:k=\"axyzbc\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        { "d:*,k=\"a*b\"", "d:k=\"axyzbc\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        { "d:k=\"?\"", "d:k=\"xyz\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        { "d:k=\"a?b\"", "d:k=\"ab\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        { "d:k=\"a?b\",*", "d:k=\"ab\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        { "d:*,k=\"a?b\"", "d:k=\"ab\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        { "d:k=\"?*\"", "d:k=\"axyzb\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        { "d:k=\"a?bc*d\"", "d:k=\"abcd\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        { "d:k=\"a?bc*d\",*", "d:k=\"abcd\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        { "d:*,k=\"a?bc*d\"", "d:k=\"abcd\",k2=\"v2\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        { "d:k1=\"?\",k2=\"*\"", "d:k1=\"ab\",k2=\"ab\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        { "d:k1=\"a?b\",k2=\"c*d\"", "d:k1=\"ab\",k2=\"cd\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        { "d:k1=\"a?b\",k2=\"c*d\",*", "d:k1=\"ab\",k2=\"cd\",k3=\"v3\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        { "d:*,k1=\"a?b\",k2=\"c*d\"", "d:k1=\"ab\",k2=\"cd\",k3=\"v3\"" },
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    private static int runPositiveTests() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        int error = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        for (int i = 0; i < positiveTests.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                ObjectName on1 = ObjectName.getInstance(positiveTests[i][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                ObjectName on2 = ObjectName.getInstance(positiveTests[i][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                System.out.println("\"" + on1 + "\".apply(\"" + on2 + "\")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                boolean result = on1.apply(on2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                System.out.println("Result = " + result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                if (result == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                System.out.println("Got Unexpected Exception = " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    private static int runNegativeTests() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        int error = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        for (int i = 0; i < negativeTests.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                ObjectName on1 = ObjectName.getInstance(negativeTests[i][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                ObjectName on2 = ObjectName.getInstance(negativeTests[i][1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                System.out.println("\"" + on1 + "\".apply(\"" + on2 + "\")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                boolean result = on1.apply(on2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                System.out.println("Result = " + result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                if (result == true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                    System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                System.out.println("Got Unexpected Exception = " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        int error = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        // Check null values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        System.out.println("Test ObjectName.apply(null)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            new ObjectName("d:k=v").apply(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            System.out.println("Didn't get expected NullPointerException!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        } catch (NullPointerException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            System.out.println("Got expected exception '" + e.toString() + "'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            System.out.println("Got unexpected exception '" + e.toString() + "'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // Check domain pattern values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        System.out.println("Test ObjectName.apply(domain_pattern)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            if (new ObjectName("d:k=v").apply(new ObjectName("*:k=v"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                System.out.println("Got 'true' expecting 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                System.out.println("Got expected return value 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            System.out.println("Got unexpected exception = " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        // Check key property list pattern values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        System.out.println("Test ObjectName.apply(key_property_list_pattern)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            if (new ObjectName("d:k=v").apply(new ObjectName("d:k=v,*"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                System.out.println("Got 'true' expecting 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                System.out.println("Got expected return value 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            System.out.println("Got unexpected exception = " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        // Check key property value pattern values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        System.out.println("Test ObjectName.apply(key_property_value_pattern)");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            if (new ObjectName("d:k=v").apply(new ObjectName("d:k=*"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                System.out.println("Got 'true' expecting 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                System.out.println("Got expected return value 'false'");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                System.out.println("Test passed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            System.out.println("Got unexpected exception = " + e.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            System.out.println("Test failed!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        System.out.println("----------------------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        error += runPositiveTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        error += runNegativeTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (error > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            final String msg = "Test FAILED! Got " + error + " error(s)";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            System.out.println(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            throw new IllegalArgumentException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            System.out.println("Test PASSED!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}