77import java .util .*;
88import java .util .function .Supplier ;
99
10- import org .junit .experimental .theories .internal .ParameterizedAssertionError ;
1110import org .slf4j .*;
1211
13- import junit .framework .*;
14-
1512import de .tum .in .test .api .internal .sanitization .ThrowableInfo .PropertyKey ;
1613import de .tum .in .test .api .util .LruCache ;
1714
@@ -38,11 +35,7 @@ enum SafeTypeThrowableSanitizer implements SpecificThrowableSanitizer {
3835 entry ("java.net.HttpRetryException" , new HttpRetryExceptionCreator ()), //$NON-NLS-1$
3936 entry ("java.time.format.DateTimeParseException" , new DateTimeParseExceptionCreator ()), //$NON-NLS-1$
4037 entry ("java.util.IllformedLocaleException" , new IllformedLocaleExceptionCreator ()), //$NON-NLS-1$
41- entry ("java.util.MissingResourceException" , new MissingResourceExceptionCreator ()), //$NON-NLS-1$
42- entry ("junit.framework.ComparisonFailure" , new ThrowableCreatorWrapper (ComparisonFailureCreator ::new )), //$NON-NLS-1$
43- entry ("org.junit.ComparisonFailure" , new ThrowableCreatorWrapper (ComparisonFailureCreator ::new )), //$NON-NLS-1$
44- entry ("org.junit.experimental.theories.internal.ParameterizedAssertionError" , //$NON-NLS-1$
45- new ThrowableCreatorWrapper (ParameterizedAssertionErrorCreator ::new )) //
38+ entry ("java.util.MissingResourceException" , new MissingResourceExceptionCreator ()) //$NON-NLS-1$
4639 );
4740
4841 final Map <Class <? extends Throwable >, ThrowableCreator > cachedThrowableCreators = Collections
@@ -146,47 +139,4 @@ public Throwable create(ThrowableInfo info) {
146139 return new MissingResourceException (message , className , key );
147140 }
148141 }
149-
150- private static class ComparisonFailureCreator implements ThrowableCreator {
151-
152- private static final int MAX_CONTEXT_LENGTH = 20 ;
153-
154- private static final PropertyKey <String > EXPECTED = new PropertyKey <>(String .class , "expected" ); //$NON-NLS-1$
155- private static final PropertyKey <String > ACTUAL = new PropertyKey <>(String .class , "actual" ); //$NON-NLS-1$
156-
157- @ Override
158- public Throwable create (ThrowableInfo info ) {
159- var message = info .getMessage ();
160- var expected = info .getProperty (EXPECTED );
161- var actual = info .getProperty (ACTUAL );
162- String withoutMessage = new ComparisonCompactor (MAX_CONTEXT_LENGTH , expected , actual ).compact ("" ); //$NON-NLS-1$
163- var start = SanitizationUtils .removeSuffixMatching (message , withoutMessage );
164- if (start == null )
165- message = "" ; //$NON-NLS-1$
166- else
167- message = start .trim ();
168- if (ComparisonFailure .class .isAssignableFrom (info .getType ()))
169- return new ComparisonFailure (message , expected , actual );
170- return new org .junit .ComparisonFailure (message , expected , actual );
171- }
172- }
173-
174- private static class ParameterizedAssertionErrorCreator implements ThrowableCreator {
175-
176- @ Override
177- public Throwable create (ThrowableInfo info ) {
178- var targetException = info .getCause ();
179- var message = info .getMessage ();
180- var methodName = message ;
181- var params = new Object [0 ];
182- try {
183- var parts = message .substring (0 , message .length () - 1 ).split ("\\ (" , 2 ); //$NON-NLS-1$
184- methodName = parts [0 ];
185- params = parts [1 ].split ("," ); //$NON-NLS-1$
186- } catch (@ SuppressWarnings ("unused" ) RuntimeException e ) {
187- // ignore
188- }
189- return new ParameterizedAssertionError (targetException , methodName , params );
190- }
191- }
192142}
0 commit comments