FAULT: Added number support and improved test case usage pattern
This commit is contained in:
parent
32fdf0e261
commit
1f958a1adc
2 changed files with 31 additions and 16 deletions
|
|
@ -64,6 +64,10 @@ abstract public class BassFaultAnchor extends BassFaultAnchorSignalStore {
|
|||
super(error, signal, tracer);
|
||||
}
|
||||
|
||||
public final BassFaultAnchor withSignalTrace(Class<?> signal, String key, Number value) {
|
||||
return withSignalTrace(signal, key, value.toString());
|
||||
}
|
||||
|
||||
public final BassFaultAnchor withSignalTrace(Class<?> signal, String key, String value) {
|
||||
fetchTraceSignalMap(signal).put(key, value);
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -43,51 +43,60 @@ public class FaultSignalTraceTest {
|
|||
}
|
||||
}
|
||||
static class SpaceB {
|
||||
static void traceRootAccess() {
|
||||
static void traceRootAccess(int productColor) {
|
||||
try {
|
||||
SpaceA.traceRoot();
|
||||
} catch (FaultBeanInstantiation e) {
|
||||
throw e.withSignalTrace(SpaceB.class, "Name", "FoodSection").withSignalTrace(SpaceB.class, "From", "FoodEmail");
|
||||
// test auto-esc of email header protection from java manifest v1 output
|
||||
// and add stuff on the general whiteboard to play games
|
||||
// and normal fault context signal tracing
|
||||
throw e.withSignalTrace(SpaceB.class, "Name", "FoodSection")
|
||||
.withSignalTrace(SpaceB.class, "From", "FoodEmail")
|
||||
.withSignalTrace(SpaceB.class, "product-color", productColor)
|
||||
.appendOnWhitePaper("Paper-SpaceB", "sissors");
|
||||
}
|
||||
}
|
||||
}
|
||||
static class SpaceC {
|
||||
static void traceRootCatchBass() {
|
||||
static void traceRootCatchBass(String bearbar) {
|
||||
try {
|
||||
SpaceB.traceRootAccess();
|
||||
SpaceB.traceRootAccess((int) bearbar.charAt(0));
|
||||
} catch (BassFaultAnchor e) {
|
||||
throw e.withSignalTrace(SpaceC.class, v -> {
|
||||
v.put("bearbar", bearbar);
|
||||
v.put("Junit-Foo", "Bar");
|
||||
v.put("Junit-仙上主天", "仙上主天");
|
||||
v.put("Junit-仙上主天", "仙上主天"); // only works with manifest v2++
|
||||
}).appendOnWhitePaper("Paper-SpaceC", "rock");
|
||||
}
|
||||
}
|
||||
}
|
||||
static class SpaceD {
|
||||
static void traceWrapClassic() {
|
||||
static void traceWrapClassic(String foobar) {
|
||||
try {
|
||||
SpaceC.traceRootCatchBass();
|
||||
SpaceC.traceRootCatchBass(foobar);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Classic argument missing wrapper", e);
|
||||
// classic java error wrapping to add meta info like call arguments for context in stack trace
|
||||
throw new IllegalArgumentException("Classic argument missing wrapper with foobar " + foobar, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
static class SpaceE {
|
||||
static void traceWrap() {
|
||||
static void traceWrap(int eSpaceMine) {
|
||||
try {
|
||||
SpaceD.traceWrapClassic();
|
||||
SpaceD.traceWrapClassic("" + eSpaceMine * 1234);
|
||||
} catch (Exception e) {
|
||||
throw new FaultBeanState(e, SpaceD.class).appendOnWhitePaper("Paper-SpaceE", "sissors");
|
||||
throw new FaultStreamDelegate(e, SpaceD.class)
|
||||
.withSignalTrace(SpaceE.class, "eSpaceMine", eSpaceMine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaultString() {
|
||||
FaultBeanState error = null;
|
||||
BassFaultAnchor error = null;
|
||||
try {
|
||||
SpaceE.traceWrap();
|
||||
} catch (FaultBeanState e) {
|
||||
SpaceE.traceWrap(123);
|
||||
} catch (BassFaultAnchor e) {
|
||||
error = e;
|
||||
}
|
||||
Assertions.assertNotNull(error);
|
||||
|
|
@ -97,14 +106,14 @@ public class FaultSignalTraceTest {
|
|||
//System.out.println(errorText.length()); // 3185, 3433
|
||||
Assertions.assertNotNull(errorText);
|
||||
Assertions.assertTrue(errorText.contains(error.getMessage()));
|
||||
Assertions.assertTrue(errorText.contains("FaultBeanState"));
|
||||
Assertions.assertTrue(errorText.contains("FaultStreamDelegate"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFaultStringSitra() {
|
||||
BassFaultAnchor error = null;
|
||||
try {
|
||||
SpaceE.traceWrap();
|
||||
SpaceE.traceWrap(123);
|
||||
} catch (BassFaultAnchor e) {
|
||||
error = e;
|
||||
}
|
||||
|
|
@ -119,5 +128,7 @@ public class FaultSignalTraceTest {
|
|||
Assertions.assertTrue(sitraText.contains("FoodSection"));
|
||||
Assertions.assertTrue(sitraText.contains("SpaceC"));
|
||||
Assertions.assertTrue(sitraText.contains("Junit-Foo: Bar"));
|
||||
Assertions.assertTrue(sitraText.contains("eSpaceMine: 123"));
|
||||
Assertions.assertTrue(sitraText.contains("product-color: 49"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue