KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > logging > KeysTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.logging;
5
6 import junit.framework.TestCase;
7
8 public class KeysTest extends TestCase {
9
10   public void test() {
11     String JavaDoc[] keys = Keys.getKeys(Class1.class);
12
13     assertEquals(5, keys.length);
14
15     for (int i = 0; i < keys.length; i++) {
16       assertEquals("index " + i, "good", keys[i]);
17     }
18
19   }
20
21   private static class Class1 {
22     static final String JavaDoc GOOD_1 = "good";
23     public static final String JavaDoc GOOD_2 = "good";
24     protected static final String JavaDoc GOOD_3 = "good";
25     private static final String JavaDoc GOOD_4 = "good";
26     transient static final String JavaDoc GOOD_5 = "good";
27
28     private static final Object JavaDoc NO_GOOD_1 = new Object JavaDoc(); // not type String
29
private static String JavaDoc NO_GOOD_2 = "bad"; // not final
30
final String JavaDoc NO_GOOD_3 = "bad"; // not static
31
static final String JavaDoc No_GOOD_4 = "bad"; // not all caps
32

33     public void silenceWarnings() {
34       // this method here to make eclipse shutup about unused variables
35
if (true) { throw new Error JavaDoc("oh no you didn't!"); }
36
37       System.out.println(GOOD_4);
38       System.out.println(NO_GOOD_1);
39       System.out.println(NO_GOOD_2);
40     }
41
42   }
43
44 }
45
Popular Tags