14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jfr.api.metadata.eventtype;
27
28 import java.util.List;
29
30 import jdk.jfr.EventType;
31 import jdk.jfr.SettingDescriptor;
32 import jdk.test.lib.Asserts;
33
34 /*
35 * @test
36 * @summary Test getSettings()
37 * @key jfr
38 * @library /test/lib /test/jdk
39 * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetSettings
40 */
41 public class TestGetSettings {
42
43 public static void main(String[] args) throws Throwable {
44 EventType eventType = EventType.getEventType(EventWithCustomSettings.class);
45 List<SettingDescriptor> settings = eventType.getSettingDescriptors();
46 Asserts.assertEquals(settings.size(), 5, "Wrong number of settings");
47
48 // test immutability
49 try {
50 settings.add(settings.get(0));
51 Asserts.fail("Should not be able to modify list returned by getSettings()");
52 } catch (UnsupportedOperationException uoe) {
53 // OK, as expected
54 }
55 }
56 }
|
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jfr.api.metadata.eventtype;
27
28 import java.util.List;
29
30 import jdk.jfr.EventType;
31 import jdk.jfr.SettingDescriptor;
32 import jdk.test.lib.Asserts;
33
34 /**
35 * @test
36 * @summary Test getSettings()
37 * @key jfr
38 * @requires vm.hasJFR
39 * @library /test/lib /test/jdk
40 * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetSettings
41 */
42 public class TestGetSettings {
43
44 public static void main(String[] args) throws Throwable {
45 EventType eventType = EventType.getEventType(EventWithCustomSettings.class);
46 List<SettingDescriptor> settings = eventType.getSettingDescriptors();
47 Asserts.assertEquals(settings.size(), 5, "Wrong number of settings");
48
49 // test immutability
50 try {
51 settings.add(settings.get(0));
52 Asserts.fail("Should not be able to modify list returned by getSettings()");
53 } catch (UnsupportedOperationException uoe) {
54 // OK, as expected
55 }
56 }
57 }
|