1 21 22 package org.apache.derbyTesting.unitTests.services; 23 24 import org.apache.derby.iapi.services.context.ContextService; 25 import org.apache.derby.iapi.services.diag.Diagnosticable; 26 import org.apache.derby.iapi.services.diag.DiagnosticUtil; 27 import org.apache.derby.iapi.services.monitor.Monitor; 28 import org.apache.derby.iapi.services.sanity.SanityManager; 29 import org.apache.derby.iapi.error.StandardException; 30 import org.apache.derby.iapi.store.access.AccessFactory; 31 import org.apache.derby.iapi.store.access.ConglomerateController; 32 import org.apache.derby.iapi.store.access.TransactionController; 33 import org.apache.derby.iapi.store.raw.ContainerHandle; 34 import org.apache.derby.iapi.store.raw.ContainerKey; 35 import org.apache.derby.iapi.store.raw.Page; 36 import org.apache.derby.iapi.store.raw.Transaction; 37 import org.apache.derby.iapi.store.raw.RawStoreFactory; 38 39 40 import org.apache.derbyTesting.unitTests.harness.T_MultiIterations; 41 import org.apache.derbyTesting.unitTests.harness.T_Fail; 42 import org.apache.derby.iapi.reference.Property; 43 44 import java.util.Properties ; 45 46 48 56 57 58 public class T_Diagnosticable extends T_MultiIterations 59 { 60 private static final String testService = "DiagnosticableTest"; 61 62 63 64 65 68 public T_Diagnosticable() 69 { 70 } 71 72 73 74 82 private void t_001() 83 throws T_Fail 84 { 85 Object diag_obj = new T_DiagTestClass1("object with diag interface"); 87 88 Object diagSubObj = new T_DiagTestClass1Sub("sub-class"); 91 92 Object obj = new Long (5); 94 95 String str = null; 97 String expected_str = null; 98 Diagnosticable helper_class = null; 99 100 str = DiagnosticUtil.toDiagString(diag_obj); 102 expected_str = "D_T_DiagTestClass1: object with diag interface"; 103 104 if (str.compareTo(expected_str) != 0) 105 { 106 throw T_Fail.testFailMsg( 107 "DiagnosticUtil.toDiagString() failed, got: (" + str + 108 "), expected: (" + expected_str + ")."); 109 } 110 111 112 114 helper_class = DiagnosticUtil.findDiagnostic(diag_obj); 115 116 if (!(helper_class instanceof D_T_DiagTestClass1)) 117 throw T_Fail.testFailMsg("Bad helper class lookup."); 118 119 121 try 122 { 123 str = helper_class.diag(); 124 } 125 catch (Throwable t) 126 { 127 throw T_Fail.testFailMsg( 128 "Unexpected exception from helper_class.diag() call"); 129 } 130 131 if (!str.equals(expected_str)) 132 { 133 throw T_Fail.testFailMsg( 134 "DiagnosticUtil.toDiagString() failed, got: (" + str + 135 "), expected: (" + expected_str + ")."); 136 } 137 138 str = DiagnosticUtil.toDiagString(diagSubObj); 140 expected_str = "D_T_DiagTestClass1: sub-class"; 141 if (!str.equals(expected_str)) 142 { 143 throw T_Fail.testFailMsg( 144 "DiagnosticUtil.toDiagString() failed, got: (" + str + 145 "), expected: (" + expected_str + ")."); 146 } 147 148 str = DiagnosticUtil.toDiagString(obj); 150 expected_str = "5"; 151 152 if (str.compareTo(expected_str) != 0) 153 { 154 throw T_Fail.testFailMsg( 155 "DiagnosticUtil.toDiagString() failed, got: (" + str + 156 "), expected: (" + expected_str + ")."); 157 } 158 159 helper_class = DiagnosticUtil.findDiagnostic(obj); 162 163 if (helper_class != null) 164 throw T_Fail.testFailMsg("Bad helper class - should be null."); 165 } 166 167 168 169 170 178 protected void setupTest() 179 throws T_Fail 180 { 181 if (startParams == null) { 183 startParams = new Properties (); 184 } 185 startParams.put(Property.NO_AUTO_BOOT, Boolean.TRUE.toString()); 186 startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString()); 188 } 189 190 193 194 public String getModuleToTestProtocolName() { 195 return("org.apache.derby.iapi.services.diag.DiagnosticUtil"); 196 } 197 198 204 protected void runTestSet() throws T_Fail 205 { 206 out.println("Executing " + testService + " test."); 207 208 t_001(); 209 210 out.println("Finished Executing " + testService + " test."); 211 } 212 } 213 | Popular Tags |