1 23 package com.sun.enterprise.management.ext.logging; 24 25 import java.util.Map ; 26 import java.util.Date ; 27 import java.util.logging.Level ; 28 29 import javax.management.openmbean.CompositeData ; 30 import javax.management.openmbean.OpenDataException ; 31 32 import com.sun.appserv.management.ext.logging.LogQueryEntry; 33 import com.sun.appserv.management.ext.logging.LogQueryEntryImpl; 34 35 36 import com.sun.enterprise.management.Capabilities; 37 38 40 public final class LogQueryEntryImplTest extends junit.framework.TestCase 41 { 42 public 43 LogQueryEntryImplTest( ) 44 { 45 } 46 47 48 private static final String N1 = "foo"; 49 private static final String V1 = "foo-value"; 50 private static final String N2 = LogQueryEntry.THREAD_ID_KEY; 51 private static final String V2 = "13347"; 52 53 private static String 54 nvp( final String name, final String value ) 55 { 56 return( name + "=" + value ); 57 } 58 59 public static LogQueryEntryImpl 60 createDummy() 61 { 62 return new LogQueryEntryImpl( 63 0, 64 new Date (), 65 Level.OFF.toString(), 66 "Sun Appserver whatever", 67 "hello world", 68 "MSG01", 69 "module", 70 nvp(N1,V1) + ";" + nvp(N2,V2) ); 71 } 72 73 public void 74 testCreate() 75 { 76 createDummy(); 77 } 78 79 public void 80 testEquals() 81 { 82 final LogQueryEntryImpl d = createDummy(); 83 84 assertEquals( d, d ); 85 86 final LogQueryEntryImpl dCopy = new LogQueryEntryImpl( 87 d.getRecordNumber(), 88 d.getDate(), 89 d.getLevel(), 90 d.getProductName(), 91 d.getMessage(), 92 d.getMessageID(), 93 d.getModule(), 94 d.getNameValuePairs() ); 95 96 assertEquals( d, dCopy ); 97 assertEquals( dCopy, d ); 98 } 99 100 101 public void 102 testGetNameValuePairsMap() 103 { 104 final LogQueryEntryImpl d = createDummy(); 105 106 final Map <String ,String > m = d.getNameValuePairsMap(); 107 assertEquals( V1, m.get( N1 ) ); 108 assertEquals( V2, m.get( N2 ) ); 109 } 110 111 public void 112 testGetters() 113 throws OpenDataException 114 { 115 final LogQueryEntryImpl d = createDummy(); 116 117 d.getRecordNumber(); 118 d.getDate(); 119 d.getLevel(); 120 d.getMessage(); 121 d.getMessageID(); 122 d.getModule(); 123 d.getMessage(); 124 d.getNameValuePairs(); 125 d.getNameValuePairsMap(); 126 } 127 128 154 } 155 156 157 158 159 160 161 162 163 164 | Popular Tags |