1 23 24 29 package com.sun.enterprise.management.base; 30 31 import java.io.File ; 32 33 import com.sun.appserv.management.base.AMXDebug; 34 import com.sun.appserv.management.util.misc.Output; 35 36 37 38 import com.sun.enterprise.management.AMXTestBase; 39 import com.sun.enterprise.management.Capabilities; 40 41 import com.sun.enterprise.management.Capabilities; 42 43 45 public final class AMXDebugTest extends junit.framework.TestCase 46 { 47 public 48 AMXDebugTest() 49 { 50 getAMXDebug().setDefaultDebug( true ); 51 getAMXDebug().setAll( true ); 52 } 53 54 private String 55 getID( final String uniquifier ) 56 { 57 return this.getClass().getName() + "." + uniquifier; 58 } 59 60 private Output 61 getOutput( final String id ) 62 { 63 return getAMXDebug().getOutput( id ); 64 } 65 66 private AMXDebug 67 getAMXDebug() 68 { 69 return AMXDebug.getInstance(); 70 } 71 72 public synchronized void 73 testCreateFile() 74 { 75 final String id = getID( "testCreateFile" + System.currentTimeMillis() ); 77 final Output output = getOutput( id ); 78 79 final File outputFile = getAMXDebug().getOutputFile( id ); 80 outputFile.delete(); 81 assert( ! outputFile.exists() ); 82 83 output.printDebug( "test" ); 84 assert( outputFile.exists() ); 85 } 86 87 public synchronized void 88 testToggleDebug() 89 { 90 final String id = getID( "testToggleDebug" ); 91 final Output output = getOutput( id ); 92 93 getAMXDebug().setDebug( id, false ); 94 assert( ! getAMXDebug().getDebug( id ) ); 95 getAMXDebug().setDebug( id, true ); 96 assert( getAMXDebug().getDebug( id ) ); 97 } 98 99 public synchronized void 100 testReset() 101 { 102 final String id = getID( "testReset" ); 103 final Output output = getOutput( id ); 104 105 getAMXDebug().reset( id ); 106 final File outputFile = getAMXDebug().getOutputFile( id ); 107 outputFile.delete(); 108 assert( ! outputFile.exists() ); 109 output.printDebug( "test" ); 110 assert( outputFile.exists() ); 111 112 getAMXDebug().reset( id ); 114 getAMXDebug().reset( id ); 115 getAMXDebug().reset( id ); 116 } 117 118 119 public synchronized void 120 testPrint() 121 { 122 final String id = getID( "testPrint" ); 123 final Output output = getOutput( id ); 124 125 output.printDebug( "printDebug" ); 126 output.printError( "printError" ); 127 output.println( "println" ); 128 output.print( "print" );output.print( "..." );output.print( "END" ); 129 } 130 131 132 public synchronized void 133 testClose() 134 { 135 final String id = getID( "testClose" ); 136 final Output output = getOutput( id ); 137 final File outputFile = getAMXDebug().getOutputFile( id ); 138 139 output.println( "hello" ); 140 assert( outputFile.exists() ); 141 142 output.close(); 143 outputFile.delete(); 144 assert( !outputFile.exists() ); 145 146 output.println( "hello" ); 147 assert( outputFile.exists() ); 148 } 149 150 public synchronized void 151 testToggleDefaultDebug() 152 { 153 final String id = getID( "testToggleDefaultDebug" ); 154 final Output output = getOutput( id ); 155 156 getAMXDebug().setDefaultDebug( false ); 157 assert( ! getAMXDebug().getDefaultDebug() ); 158 159 getAMXDebug().setDefaultDebug( true ); 160 assert( getAMXDebug().getDefaultDebug() ); 161 } 162 163 164 public synchronized void 165 testSetAll() 166 { 167 final String id = getID( "testSetAll" ); 168 final Output output = getOutput( id ); 169 170 getAMXDebug().setAll( false ); 171 getAMXDebug().setAll( false ); 172 getAMXDebug().setAll( true ); 173 getAMXDebug().setAll( true ); 174 getAMXDebug().setAll( false ); 175 getAMXDebug().setAll( true ); 176 getAMXDebug().setAll( true ); 177 } 178 179 180 public synchronized void 181 testMark() 182 { 183 final String id = getID( "testMark" ); 184 final Output output = getOutput( id ); 185 186 getAMXDebug().mark( id ); 187 getAMXDebug().mark( id, null ); 188 getAMXDebug().mark( id, "marker 1" ); 189 getAMXDebug().mark( id, "marker 2" ); 190 getAMXDebug().mark( output, null ); 191 getAMXDebug().mark( output, "marker 3" ); 192 } 193 } 194 195 | Popular Tags |