test/jdk/javax/management/mxbean/StandardMBeanOverrideTest.java
author jwilhelm
Thu, 24 Jan 2019 21:24:29 +0100
changeset 53479 31e5c82f59e9
parent 47216 71c04702a3d5
permissions -rw-r--r--
8217580: Remove tests from problemList as bugs has been closed Reviewed-by: iignatyev, mseledtsov
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: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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 6283045
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Test the correctness of immutableInfo field in MBeanInfo descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *          when overriding the methods cacheMBeanInfo, getCachedMBeanInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *          getMBeanInfo and getNotificationInfo in StandardMBean and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *          StandardEmitterMBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * @author Luis-Miguel Alventosa
44423
306c020eb154 8176176: fix @modules in jdk_svc tests
iignatyev
parents: 30376
diff changeset
    32
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @run clean StandardMBeanOverrideTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @run build StandardMBeanOverrideTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @run main StandardMBeanOverrideTest
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.lang.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.management.openmbean.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class StandardMBeanOverrideTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static Object testInstances[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        new TestClass0(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        new TestClass1(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        new TestClass2(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        new TestClass3(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        new TestClass4(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        new TestClass5(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        new TestClass6(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        new TestClass7(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        new TestClass8(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        new TestClass9(false),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        new TestClass0(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        new TestClass1(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        new TestClass2(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        new TestClass3(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        new TestClass4(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        new TestClass5(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        new TestClass6(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        new TestClass7(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        new TestClass8(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        new TestClass9(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    public interface ImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public interface NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public interface TestInterface {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public static class TestClass0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        extends StandardMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        implements TestInterface, ImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        public TestClass0(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            super(TestInterface.class, mxbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public static class TestClass1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        extends StandardMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        public TestClass1(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            super(TestInterface.class, mxbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        protected void cacheMBeanInfo(MBeanInfo info) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            super.cacheMBeanInfo(info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public static class TestClass2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        extends StandardMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        public TestClass2(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            super(TestInterface.class, mxbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        protected MBeanInfo getCachedMBeanInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            return super.getCachedMBeanInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public static class TestClass3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        extends StandardMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        public TestClass3(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            super(TestInterface.class, mxbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        public MBeanInfo getMBeanInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return super.getMBeanInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public static class TestClass4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        extends StandardMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        implements TestInterface, ImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        public TestClass4(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            super(TestInterface.class, mxbean);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        public MBeanNotificationInfo[] getNotificationInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            return new MBeanNotificationInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public static class TestClass5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        extends StandardEmitterMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        implements TestInterface, ImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        public TestClass5(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            super(TestInterface.class, mxbean,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                  new NotificationBroadcasterSupport());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public static class TestClass6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        extends StandardEmitterMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        public TestClass6(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            super(TestInterface.class, mxbean,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                  new NotificationBroadcasterSupport());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        protected void cacheMBeanInfo(MBeanInfo info) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            super.cacheMBeanInfo(info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static class TestClass7
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        extends StandardEmitterMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        public TestClass7(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            super(TestInterface.class, mxbean,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                  new NotificationBroadcasterSupport());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        protected MBeanInfo getCachedMBeanInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            return super.getCachedMBeanInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public static class TestClass8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        extends StandardEmitterMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        public TestClass8(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            super(TestInterface.class, mxbean,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                  new NotificationBroadcasterSupport());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        public MBeanInfo getMBeanInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            return super.getMBeanInfo();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    public static class TestClass9
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        extends StandardEmitterMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        implements TestInterface, NonImmutableInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        public TestClass9(boolean mxbean) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            super(TestInterface.class, mxbean,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                  new NotificationBroadcasterSupport());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        public MBeanNotificationInfo[] getNotificationInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            return new MBeanNotificationInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        int error = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // Instantiate the MBean server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        echo("\n>>> Create the MBean server");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // Get default domain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        echo("\n>>> Get the MBean server's default domain");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        String domain = mbs.getDefaultDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        echo("\tDefault Domain = " + domain);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        for (int i = 0; i < testInstances.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            // Create and register the TestClass MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            String cn = testInstances[i].getClass().getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            String ons = domain + ":type=" + cn + ",name=" + i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            echo("\n>>> Create the " + cn +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                 " MBean within the MBeanServer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            echo("\tObjectName = " + ons);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            ObjectName on = ObjectName.getInstance(ons);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            mbs.registerMBean(testInstances[i], on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            // Check immutableInfo field in descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            MBeanInfo mbi = mbs.getMBeanInfo(on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            Descriptor d = mbi.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            echo("MBeanInfo descriptor = " + d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            if (d == null || d.getFieldNames().length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                echo("Descriptor is null or empty");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            if (testInstances[i] instanceof ImmutableInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                if ("true".equals(d.getFieldValue("immutableInfo"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                    echo("OK: immutableInfo field is true");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    echo("KO: immutableInfo field should be true");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            if (testInstances[i] instanceof NonImmutableInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                if ("false".equals(d.getFieldValue("immutableInfo"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                    echo("OK: immutableInfo field is false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    echo("KO: immutableInfo field should be false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    error++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if (error > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            echo("\nTest failed! " + error + " errors.\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            throw new IllegalArgumentException("Test failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            echo("\nTest passed!\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    private static void echo(String msg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        System.out.println(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
}