001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bct.assertions; 018 019import static org.apache.juneau.commons.utils.Shorts.*; 020import static org.apache.juneau.commons.utils.StringUtils.*; 021 022import java.io.*; 023import java.util.*; 024import java.util.function.*; 025import java.util.regex.*; 026 027import org.apache.juneau.commons.function.*; 028import org.apache.juneau.commons.utils.*; 029 030/** 031 * Used for fluent assertion calls against strings. 032 * 033 * <h2 class='section'>Example:</h2> 034 * <p class='bjava'> 035 * <jc>// Validates the response body of an HTTP call is the text "OK".</jc> 036 * <jv>client</jv> 037 * .get(<jsf>URL</jsf>) 038 * .run() 039 * .assertContent().is(<js>"OK"</js>); 040 * </p> 041 * 042 * 043 * <h2 class='section'>Test Methods:</h2> 044 * <ul class='javatree'> 045 * <li class='jc'>{@link FluentStringAssertion} 046 * <ul class='javatreec'> 047 * <li class='jm'>{@link FluentStringAssertion#is(String) is(String)} 048 * <li class='jm'>{@link FluentStringAssertion#isNot(String) isNot(String)} 049 * <li class='jm'>{@link FluentStringAssertion#isLines(String...) isLines(String...)} 050 * <li class='jm'>{@link FluentStringAssertion#isSortedLines(String...) isSortedLines(String...)} 051 * <li class='jm'>{@link FluentStringAssertion#isIc(String) isIc(String)} 052 * <li class='jm'>{@link FluentStringAssertion#isNotIc(String) isNotIc(String)} 053 * <li class='jm'>{@link FluentStringAssertion#isContains(String...) isContains(String...)} 054 * <li class='jm'>{@link FluentStringAssertion#isNotContains(String...) isNotContains(String...)} 055 * <li class='jm'>{@link FluentStringAssertion#isEmpty() isEmpty()} 056 * <li class='jm'>{@link FluentStringAssertion#isNotEmpty() isNotEmpty()} 057 * <li class='jm'>{@link FluentStringAssertion#isString(Object) isString(Object)} 058 * <li class='jm'>{@link FluentStringAssertion#isMatches(String) isMatches(String)} 059 * <li class='jm'>{@link FluentStringAssertion#isPattern(String) isPattern(String)} 060 * <li class='jm'>{@link FluentStringAssertion#isPattern(String,int) isPattern(String,int)} 061 * <li class='jm'>{@link FluentStringAssertion#isPattern(Pattern) isPattern(Pattern)} 062 * <li class='jm'>{@link FluentStringAssertion#isStartsWith(String) isStartsWith(String)} 063 * <li class='jm'>{@link FluentStringAssertion#isEndsWith(String) isEndsWith(String)} 064 * </ul> 065 * <li class='jc'>{@link FluentObjectAssertion} 066 * <ul class='javatreec'> 067 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 068 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 069 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 070 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 071 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 072 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 073 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 074 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 075 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 076 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 077 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 078 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 079 * </ul> 080 * </ul> 081 * 082 * <h2 class='section'>Transform Methods:</h2> 083 * <ul class='javatree'> 084 * <li class='jc'>{@link FluentStringAssertion} 085 * <ul class='javatreec'> 086 * <li class='jm'>{@link FluentStringAssertion#asReplaceAll(String,String) asReplaceAll(String,String)} 087 * <li class='jm'>{@link FluentStringAssertion#asReplace(String,String) asReplace(String,String)} 088 * <li class='jm'>{@link FluentStringAssertion#asUrlDecode() asUrlDecode()} 089 * <li class='jm'>{@link FluentStringAssertion#asLc() asLc()} 090 * <li class='jm'>{@link FluentStringAssertion#asUc() asUc()} 091 * <li class='jm'>{@link FluentStringAssertion#asLines() asLines()} 092 * <li class='jm'>{@link FluentStringAssertion#asSplit(String) asSplit(String)} 093 * <li class='jm'>{@link FluentStringAssertion#asLength() asLength()} 094 * <li class='jm'>{@link FluentStringAssertion#asOneLine() asOneLine()} 095 * </ul> 096 * <li class='jc'>{@link FluentObjectAssertion} 097 * <ul class='javatreec'> 098 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 099 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 100 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 101 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 102 * </ul> 103 * </ul> 104 * 105 * <h2 class='section'>Configuration Methods:</h2> 106 * <ul class='javatree'> 107 * <li class='jc'>{@link Assertion} 108 * <ul class='javatreec'> 109 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 110 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 111 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 112 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 113 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 114 * </ul> 115 * </ul> 116 * 117 * <h2 class='section'>See Also:</h2><ul> 118 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 119 * </ul> 120 * 121 * @param <R> The return type. 122 */ 123@SuppressWarnings({ 124 "java:S115", // Constants use UPPER_snakeCase convention 125 "java:S1192" // Duplicated literals (argument/property names) read more clearly inline than as constants 126}) 127public class FluentStringAssertion<R> extends FluentObjectAssertion<String,R> { 128 129 private static final String LINE_SEPARATOR_REGEX = "[\\r\\n]+"; 130 131 private static final Messages MESSAGES = Messages.of(FluentStringAssertion.class, "Messages"); 132 private static final String MSG_stringDifferedAtPosition = MESSAGES.getString("stringDifferedAtPosition"); 133 private static final String MSG_expectedStringHadDifferentNumbersOfLines = MESSAGES.getString("expectedStringHadDifferentNumbersOfLines"); 134 private static final String MSG_expectedStringHadDifferentValuesAtLine = MESSAGES.getString("expectedStringHadDifferentValuesAtLine"); 135 private static final String MSG_stringEqualedUnexpected = MESSAGES.getString("stringEqualedUnexpected"); 136 private static final String MSG_stringDidNotContainExpectedSubstring = MESSAGES.getString("stringDidNotContainExpectedSubstring"); 137 private static final String MSG_stringContainedUnexpectedSubstring = MESSAGES.getString("stringContainedUnexpectedSubstring"); 138 private static final String MSG_stringWasNotEmpty = MESSAGES.getString("stringWasNotEmpty"); 139 private static final String MSG_stringWasNull = MESSAGES.getString("stringWasNull"); 140 private static final String MSG_stringWasEmpty = MESSAGES.getString("stringWasEmpty"); 141 private static final String MSG_stringDidNotMatchExpectedPattern = MESSAGES.getString("stringDidNotMatchExpectedPattern"); 142 private static final String MSG_stringDidNotStartWithExpected = MESSAGES.getString("stringDidNotStartWithExpected"); 143 private static final String MSG_stringDidNotEndWithExpected = MESSAGES.getString("stringDidNotEndWithExpected"); 144 145 private boolean javaStrings; 146 147 /** 148 * Chained constructor. 149 * 150 * <p> 151 * Used when transforming one assertion into another so that the assertion config can be used by the new assertion. 152 * 153 * @param creator 154 * The assertion that created this assertion. 155 * <br>Should be <jk>null</jk> if this is the top-level assertion. 156 * @param value 157 * The object being tested. 158 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 159 * @param returns 160 * The object to return after a test method is called. 161 * <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be 162 * used on the same assertion. 163 */ 164 public FluentStringAssertion(Assertion creator, String value, R returns) { 165 super(creator, value, returns); 166 } 167 168 /** 169 * Constructor. 170 * 171 * @param value 172 * The object being tested. 173 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 174 * @param returns 175 * The object to return after a test method is called. 176 * <br>If <jk>null</jk>, the test method returns this object allowing multiple test method calls to be 177 * used on the same assertion. 178 */ 179 public FluentStringAssertion(String value, R returns) { 180 this(null, value, returns); 181 } 182 183 /** 184 * When enabled, text in the message is converted to valid Java strings. 185 * 186 * <p class='bjava'> 187 * <jv>value</jv>.replaceAll(<js>"\\\\"</js>, <js>"\\\\\\\\"</js>).replaceAll(<js>"\n"</js>, <js>"\\\\n"</js>).replaceAll(<js>"\t"</js>, <js>"\\\\t"</js>); 188 * </p> 189 * 190 * @return This object. 191 */ 192 public FluentStringAssertion<R> asJavaStrings() { 193 this.javaStrings = true; 194 return this; 195 } 196 197 /** 198 * Converts the text to lowercase. 199 * 200 * @return This object. 201 */ 202 public FluentStringAssertion<R> asLc() { 203 return asTransformed(Shorts::lcr); 204 } 205 206 /** 207 * Returns the length of this string as an integer assertion. 208 * 209 * @return This object. 210 */ 211 public FluentIntegerAssertion<R> asLength() { 212 return new FluentIntegerAssertion<>(this, valueIsNull() ? null : value().length(), returns()); 213 } 214 215 /** 216 * Splits the string into lines. 217 * 218 * @return This object. 219 */ 220 public FluentListAssertion<String,R> asLines() { 221 return asSplit(LINE_SEPARATOR_REGEX); 222 } 223 224 /** 225 * Removes any newlines from the string. 226 * 227 * @return This object. 228 */ 229 public FluentStringAssertion<R> asOneLine() { 230 return asTransformed(x -> x == null ? null : x.replaceAll("[\\r\\n]+[ \\t]*", " ")); 231 } 232 233 /** 234 * Performs the specified substring replacement on the underlying string. 235 * 236 * @param target The sequence of char values to be replaced. 237 * @param replacement The replacement sequence of char values. 238 * @return This object. 239 */ 240 public FluentStringAssertion<R> asReplace(String target, String replacement) { 241 reqnn("target", target); 242 reqnn("replacement", replacement); 243 return asTransformed(x -> x == null ? null : x.replace(target, replacement)); 244 } 245 246 /** 247 * Performs the specified regular expression replacement on the underlying string. 248 * 249 * @param regex The regular expression to which this string is to be matched. 250 * @param replacement The string to be substituted for each match. 251 * @return This object. 252 */ 253 public FluentStringAssertion<R> asReplaceAll(String regex, String replacement) { 254 reqnn("regex", regex); 255 reqnn("replacement", replacement); 256 return asTransformed(x -> x == null ? null : x.replaceAll(regex, replacement)); 257 } 258 259 /** 260 * Splits the string into lines using the specified regular expression. 261 * 262 * @param regex The delimiting regular expression 263 * @return This object. 264 */ 265 public FluentListAssertion<String,R> asSplit(String regex) { 266 reqnn("regex", regex); 267 return new FluentListAssertion<>(this, valueIsNull() ? null : l(value().trim().split(regex)), returns()); 268 } 269 270 @Override /* Overridden from FluentObjectAssertion */ 271 public FluentStringAssertion<R> asTransformed(UnaryOperator<String> function) { 272 return new FluentStringAssertion<>(this, function.apply(orElse(null)), returns()); 273 } 274 275 /** 276 * Removes any leading/trailing whitespace from the string. 277 * 278 * @return This object. 279 */ 280 public FluentStringAssertion<R> asTrimmed() { 281 return new FluentStringAssertion<>(this, valueIsNull() ? null : value().trim(), returns()); 282 } 283 284 /** 285 * Converts the text to uppercase. 286 * 287 * @return This object. 288 */ 289 public FluentStringAssertion<R> asUc() { 290 return asTransformed(Shorts::ucr); 291 } 292 293 /** 294 * URL-decodes the text in this assertion. 295 * 296 * @return This object. 297 */ 298 public FluentStringAssertion<R> asUrlDecode() { 299 return asTransformed(StringUtils::urlDecode); 300 } 301 302 /** 303 * Asserts that the text equals the specified value. 304 * 305 * <p> 306 * Similar to {@link #is(String)} except error message states diff position. 307 * 308 * <h4 class='section'>Example:</h4> 309 * <p class='bjava'> 310 * <jc>// Validates the response body of an HTTP call is the text "OK".</jc> 311 * <jv>client</jv> 312 * .get(<jsf>URL</jsf>) 313 * .run() 314 * .assertContent().is(<js>"OK"</js>); 315 * </p> 316 * 317 * @param value 318 * The value to check against. 319 * <br>If multiple values are specified, they are concatenated with newlines. 320 * @return The fluent return object. 321 * @throws AssertionError If assertion failed. 322 */ 323 @Override 324 public R is(String value) throws AssertionError { 325 var s = orElse(null); 326 if (neq(value, s)) 327 throw error(MSG_stringDifferedAtPosition, diffPosition(value, s), fix(value), fix(s)); 328 return returns(); 329 } 330 331 /** 332 * Asserts that the text contains all of the specified substrings. 333 * 334 * @param values The values to check against. 335 * @return The fluent return object. 336 * @throws AssertionError If assertion failed. 337 */ 338 public R isContains(String...values) throws AssertionError { 339 reqnn("values", values); 340 var s = orElse(null); 341 for (var substring : values) 342 if (nn(substring) && ! contains(s, substring)) 343 throw error(MSG_stringDidNotContainExpectedSubstring, fix(substring), fix(s)); 344 return returns(); 345 } 346 347 /** 348 * Asserts that the text is empty. 349 * 350 * @return The fluent return object. 351 * @throws AssertionError If assertion failed. 352 */ 353 public R isEmpty() throws AssertionError { 354 var s = orElse(null); 355 if (nn(s) && ! s.isEmpty()) 356 throw error(MSG_stringWasNotEmpty, fix(s)); 357 return returns(); 358 } 359 360 /** 361 * Asserts that the text ends with the specified string. 362 * 363 * @param string The string to test for. 364 * @return The fluent return object. 365 * @throws AssertionError If assertion failed. 366 */ 367 public R isEndsWith(String string) { 368 reqnn("string", string); 369 var s = value(); 370 if (! s.endsWith(string)) 371 throw error(MSG_stringDidNotEndWithExpected, fix(string), fix(s)); 372 return returns(); 373 } 374 375 /** 376 * Asserts that the text equals the specified value ignoring case. 377 * 378 * @param value The value to check against. 379 * @return The fluent return object. 380 * @throws AssertionError If assertion failed. 381 */ 382 public R isIc(String value) throws AssertionError { 383 var s = orElse(null); 384 if (neqic(value, s)) 385 throw error(MSG_stringDifferedAtPosition, diffPositionIc(value, s), fix(value), fix(s)); 386 return returns(); 387 } 388 389 /** 390 * Asserts that the lines of text equals the specified value. 391 * 392 * <h4 class='section'>Example:</h4> 393 * <p class='bjava'> 394 * <jc>// Validates the response body of an HTTP call is the text "OK".</jc> 395 * <jv>client</jv> 396 * .get(<jsf>URL</jsf>) 397 * .run() 398 * .assertContent().isLines( 399 * <js>"Line 1"</js>, 400 * <js>"Line 2"</js>, 401 * <js>"Line 3"</js> 402 * ); 403 * </p> 404 * 405 * @param lines 406 * The value to check against. 407 * <br>If multiple values are specified, they are concatenated with newlines. 408 * @return The fluent return object. 409 * @throws AssertionError If assertion failed. 410 */ 411 public R isLines(String...lines) throws AssertionError { 412 reqnn("lines", lines); 413 var v = join(lines, '\n'); 414 var s = value(); 415 if (neq(v, s)) 416 throw error(MSG_stringDifferedAtPosition, diffPosition(v, s), fix(v), fix(s)); 417 return returns(); 418 } 419 420 /** 421 * Asserts that the text matches the specified pattern containing <js>"*"</js> meta characters. 422 * 423 * <p> 424 * The <js>"*"</js> meta character can be used to represent zero or more characters.. 425 * 426 * @param searchPattern The search pattern. 427 * @return The fluent return object. 428 * @throws AssertionError If assertion failed. 429 */ 430 public R isMatches(String searchPattern) throws AssertionError { 431 reqnn("searchPattern", searchPattern); 432 return isPattern(getMatchPattern(searchPattern)); 433 } 434 435 /** 436 * Asserts that the text equals the specified value. 437 * 438 * @param value The value to check against. 439 * @return The fluent return object. 440 * @throws AssertionError If assertion failed. 441 */ 442 @Override 443 public R isNot(String value) throws AssertionError { 444 var s = orElse(null); 445 if (eq(value, s)) 446 throw error(MSG_stringEqualedUnexpected, fix(s)); 447 return returns(); 448 } 449 450 /** 451 * Asserts that the text doesn't contain any of the specified substrings. 452 * 453 * @param values The values to check against. 454 * @return The fluent return object. 455 * @throws AssertionError If assertion failed. 456 */ 457 public R isNotContains(String...values) throws AssertionError { 458 reqnn("values", values); 459 var s = orElse(null); 460 for (var substring : values) 461 if (nn(substring) && contains(s, substring)) 462 throw error(MSG_stringContainedUnexpectedSubstring, fix(substring), fix(s)); 463 return returns(); 464 } 465 466 /** 467 * Asserts that the text is not null or empty. 468 * 469 * @return The fluent return object. 470 * @throws AssertionError If assertion failed. 471 */ 472 public R isNotEmpty() throws AssertionError { 473 var s = orElse(null); 474 if (s == null) 475 throw error(MSG_stringWasNull); 476 if (s.isEmpty()) 477 throw error(MSG_stringWasEmpty); 478 return returns(); 479 } 480 481 /** 482 * Asserts that the text does not equal the specified value ignoring case. 483 * 484 * @param value The value to check against. 485 * @return The fluent return object. 486 * @throws AssertionError If assertion failed. 487 */ 488 public R isNotIc(String value) throws AssertionError { 489 var s = orElse(null); 490 if (eqic(value, s)) 491 throw error(MSG_stringEqualedUnexpected, fix(s)); 492 return returns(); 493 } 494 495 /** 496 * Asserts that the text matches the specified regular expression pattern. 497 * 498 * @param pattern The pattern to test for. 499 * @return The fluent return object. 500 * @throws AssertionError If assertion failed. 501 */ 502 public R isPattern(Pattern pattern) throws AssertionError { 503 reqnn("pattern", pattern); 504 var s = value(); 505 if (! pattern.matcher(s).matches()) 506 throw error(MSG_stringDidNotMatchExpectedPattern, fix(pattern.pattern()), fix(s)); 507 return returns(); 508 } 509 510 /** 511 * Asserts that the text matches the specified regular expression. 512 * 513 * @param regex The pattern to test for. 514 * @return The fluent return object. 515 * @throws AssertionError If assertion failed. 516 */ 517 public R isPattern(String regex) throws AssertionError { 518 return isPattern(regex, 0); 519 } 520 521 /** 522 * Asserts that the text matches the specified regular expression. 523 * 524 * @param regex The pattern to test for. 525 * @param flags Pattern match flags. See {@link Pattern#compile(String, int)}. 526 * @return The fluent return object. 527 * @throws AssertionError If assertion failed. 528 */ 529 public R isPattern(String regex, int flags) throws AssertionError { 530 reqnn("regex", regex); 531 var p = Pattern.compile(regex, flags); 532 var s = value(); 533 if (! p.matcher(s).matches()) 534 throw error(MSG_stringDidNotMatchExpectedPattern, fix(regex), fix(s)); 535 return returns(); 536 } 537 538 /** 539 * Asserts that the text equals the specified value after splitting both by newlines and sorting the rows. 540 * 541 * <h4 class='section'>Example:</h4> 542 * <p class='bjava'> 543 * <jc>// Validates the response body of an HTTP call is the text "OK".</jc> 544 * <jv>client</jv> 545 * .get(<jsf>URL</jsf>) 546 * .run() 547 * .assertContent().isSortedLines( 548 * <js>"Line 1"</js>, 549 * <js>"Line 2"</js>, 550 * <js>"Line 3"</js> 551 * ); 552 * </p> 553 * 554 * @param lines 555 * The value to check against. 556 * <br>If multiple values are specified, they are concatenated with newlines. 557 * @return The fluent return object. 558 * @throws AssertionError If assertion failed. 559 */ 560 public R isSortedLines(String...lines) { 561 reqnn("lines", lines); 562 563 // Must work for windows too. 564 var e = join(lines, '\n').trim().split(LINE_SEPARATOR_REGEX); 565 var a = value().trim().split(LINE_SEPARATOR_REGEX); 566 567 if (e.length != a.length) 568 throw error(MSG_expectedStringHadDifferentNumbersOfLines, e.length, a.length); 569 570 Arrays.sort(e); 571 Arrays.sort(a); 572 573 for (var i = 0; i < e.length; i++) 574 if (! e[i].equals(a[i])) 575 throw error(MSG_expectedStringHadDifferentValuesAtLine, i + 1, e[i], a[i]); 576 577 return returns(); 578 } 579 580 /** 581 * Asserts that the text starts with the specified string. 582 * 583 * @param string The string to test for. 584 * @return The fluent return object. 585 * @throws AssertionError If assertion failed. 586 */ 587 public R isStartsWith(String string) { 588 reqnn("string", string); 589 var s = value(); 590 if (! s.startsWith(string)) 591 throw error(MSG_stringDidNotStartWithExpected, fix(string), fix(s)); 592 return returns(); 593 } 594 595 /** 596 * Asserts that the text equals the specified object after calling {@link #toString()} on the object. 597 * 598 * @param value The value to check against. 599 * @return The fluent return object. 600 */ 601 public R isString(Object value) { 602 return is(value == null ? null : toString()); 603 } 604 605 @Override /* Overridden from Assertion */ 606 public FluentStringAssertion<R> setMsg(String msg, Object...args) { 607 super.setMsg(msg, args); 608 return this; 609 } 610 611 @Override /* Overridden from Assertion */ 612 public FluentStringAssertion<R> setOut(PrintStream value) { 613 super.setOut(value); 614 return this; 615 } 616 617 @Override /* Overridden from Assertion */ 618 public FluentStringAssertion<R> setSilent() { 619 super.setSilent(); 620 return this; 621 } 622 623 @Override /* Overridden from Assertion */ 624 public FluentStringAssertion<R> setStdOut() { 625 super.setStdOut(); 626 return this; 627 } 628 629 @Override /* Overridden from Assertion */ 630 public FluentStringAssertion<R> setThrowable(Class<? extends RuntimeException> value) { 631 super.setThrowable(value); 632 return this; 633 } 634 635 private String fix(String text) { 636 if (javaStrings) 637 text = text.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t"); 638 return text; 639 } 640}