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.Arrays;
29
30 import jdk.jfr.Category;
31 import jdk.jfr.Description;
32 import jdk.jfr.Enabled;
33 import jdk.jfr.Event;
34 import jdk.jfr.EventType;
35 import jdk.jfr.Label;
36 import jdk.test.lib.Asserts;
37
38 /*
39 * @test
40 * @summary Test getAnnotations()
41 * @key jfr
42 * @library /test/lib
43 * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotation
44 */
45 public class TestGetAnnotation {
46
47 public static void main(String[] args) throws Throwable {
48 EventType type = EventType.getEventType(MyEvent.class);
49
50 Label label = type.getAnnotation(Label.class);
51 if (label == null) {
52 Asserts.fail("Annotation label was null");
53 }
54 Asserts.assertEquals(label.value(), "myLabel", "Wrong value for annotation label");
55
56 Category category = type.getAnnotation(Category.class);
57 if (category == null) {
58 Asserts.fail("Annotation @Description was null");
59 }
60
61 Asserts.assertTrue(Arrays.equals(category.value(), new String[] {"Stuff"}), "Wrong value for annotation enabled");
|
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.Arrays;
29
30 import jdk.jfr.Category;
31 import jdk.jfr.Description;
32 import jdk.jfr.Enabled;
33 import jdk.jfr.Event;
34 import jdk.jfr.EventType;
35 import jdk.jfr.Label;
36 import jdk.test.lib.Asserts;
37
38 /**
39 * @test
40 * @summary Test getAnnotations()
41 * @key jfr
42 * @requires vm.hasJFR
43 * @library /test/lib
44 * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotation
45 */
46 public class TestGetAnnotation {
47
48 public static void main(String[] args) throws Throwable {
49 EventType type = EventType.getEventType(MyEvent.class);
50
51 Label label = type.getAnnotation(Label.class);
52 if (label == null) {
53 Asserts.fail("Annotation label was null");
54 }
55 Asserts.assertEquals(label.value(), "myLabel", "Wrong value for annotation label");
56
57 Category category = type.getAnnotation(Category.class);
58 if (category == null) {
59 Asserts.fail("Annotation @Description was null");
60 }
61
62 Asserts.assertTrue(Arrays.equals(category.value(), new String[] {"Stuff"}), "Wrong value for annotation enabled");
|