1 23 24 package com.sun.enterprise.management.ext.logging; 25 26 import java.util.List ; 27 import java.util.Set ; 28 29 import com.sun.appserv.management.base.Util; 30 import com.sun.appserv.management.base.XTypes; 31 32 import com.sun.appserv.management.helper.LoggingHelper; 33 34 import com.sun.appserv.management.ext.logging.Logging; 35 import static com.sun.appserv.management.ext.logging.Logging.*; 36 import com.sun.appserv.management.ext.logging.LogModuleNames; 37 import com.sun.appserv.management.ext.logging.LogRecordFields; 38 import com.sun.appserv.management.ext.logging.LogQueryResult; 39 import com.sun.appserv.management.ext.logging.LogQueryResultImpl; 40 41 42 import com.sun.enterprise.management.AMXTestBase; 43 import com.sun.enterprise.management.Capabilities; 44 45 46 49 public final class LoggingHelperTest extends AMXTestBase 50 { 51 public 52 LoggingHelperTest( ) 53 { 54 } 55 56 final Set <Logging> 57 getAllLogging() 58 { 59 return getQueryMgr().queryJ2EETypeSet( XTypes.LOGGING ); 60 } 61 62 public LoggingHelper 63 createHelper( final Logging logging ) 64 { 65 return new LoggingHelper( logging ); 66 } 67 68 69 private void 70 validateResult( final LogQueryResult result ) 71 { 72 assert( result != null ); 73 assert( result.getFieldNames() != null ); 74 assert( result.getEntries() != null ); 75 } 76 77 public void 78 testQueryServerLogSingle() 79 { 80 final Set <Logging> loggings = getAllLogging(); 81 82 for( final Logging logging : loggings ) 83 { 84 final LoggingHelper helper = createHelper( logging ); 85 final LogQueryResult result = 86 helper.queryServerLog( LOWEST_SUPPORTED_QUERY_LEVEL, "EJB" ); 87 validateResult( result ); 88 } 89 } 90 91 92 93 public void 94 testQueryServerLogLevelAndModules() 95 { 96 final Set <Logging> loggings = getAllLogging(); 97 98 for( final Logging logging : loggings ) 99 { 100 final LoggingHelper helper = createHelper( logging ); 101 102 final LogQueryResult result = 103 helper.queryServerLog( LOWEST_SUPPORTED_QUERY_LEVEL, 104 LogModuleNames.ALL_NAMES ); 105 validateResult( result ); 106 } 107 } 108 109 110 public void 111 testQueryServerLogLevel() 112 { 113 final Set <Logging> loggings = getAllLogging(); 114 115 for( final Logging logging : loggings ) 116 { 117 final LoggingHelper helper = createHelper( logging ); 118 119 final LogQueryResult result = 120 helper.queryServerLog( LOWEST_SUPPORTED_QUERY_LEVEL ); 121 validateResult( result ); 122 } 123 } 124 125 126 public void 127 testQueryAllCurrent() 128 { 129 final Set <Logging> loggings = getAllLogging(); 130 131 for( final Logging logging : loggings ) 132 { 133 final LoggingHelper helper = createHelper( logging ); 134 135 final LogQueryResult result = helper.queryAllCurrent(); 136 validateResult( result ); 137 } 138 } 139 140 141 private static final int HOUR_MILLIS = 60 * 60 * 1000; 142 public void 143 testQueryServerLogRecent() 144 { 145 final Set <Logging> loggings = getAllLogging(); 146 147 for( final Logging logging : loggings ) 148 { 149 final LoggingHelper helper = createHelper( logging ); 150 151 final LogQueryResult result = 152 helper.queryServerLogRecent( HOUR_MILLIS ); 153 validateResult( result ); 154 } 155 } 156 157 158 public void 159 testQueryServerLogRecentWithModules( ) 160 { 161 final Set <Logging> loggings = getAllLogging(); 162 163 for( final Logging logging : loggings ) 164 { 165 final LoggingHelper helper = createHelper( logging ); 166 167 final LogQueryResult result = 168 helper.queryServerLogRecent( 169 HOUR_MILLIS, LogModuleNames.ALL_NAMES ); 170 validateResult( result ); 171 } 172 } 173 174 175 public void 176 testQueryAllInFile( ) 177 { 178 final Set <Logging> loggings = getAllLogging(); 179 180 for( final Logging logging : loggings ) 181 { 182 final LoggingHelper helper = createHelper( logging ); 183 184 final String [] names = logging.getLogFileNames( SERVER_KEY ); 185 for( final String name : names ) 186 { 187 final LogQueryResult result = helper.queryAllInFile( name ); 188 validateResult( result ); 189 } 190 } 191 } 192 193 public void 194 testQueryAll( ) 195 { 196 final Set <Logging> loggings = getAllLogging(); 197 198 for( final Logging logging : loggings ) 199 { 200 final LoggingHelper helper = createHelper( logging ); 201 202 final LogQueryResult[] results = helper.queryAll(); 203 for( final LogQueryResult result : results ) 204 { 205 validateResult( result ); 206 } 207 } 208 } 209 210 211 } 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | Popular Tags |