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