|
18 | 18 |
|
19 | 19 | import java.io.Externalizable;
|
20 | 20 | import java.io.Serializable;
|
| 21 | +import java.lang.annotation.ElementType; |
| 22 | +import java.lang.annotation.Retention; |
| 23 | +import java.lang.annotation.RetentionPolicy; |
| 24 | +import java.lang.annotation.Target; |
21 | 25 | import java.lang.reflect.InvocationTargetException;
|
22 | 26 | import java.lang.reflect.Method;
|
23 | 27 | import java.lang.reflect.Proxy;
|
|
31 | 35 |
|
32 | 36 | import org.junit.jupiter.api.BeforeEach;
|
33 | 37 | import org.junit.jupiter.api.Test;
|
| 38 | +import org.junit.jupiter.params.ParameterizedTest; |
| 39 | +import org.junit.jupiter.params.provider.ValueSource; |
34 | 40 |
|
35 | 41 | import org.springframework.tests.sample.objects.DerivedTestObject;
|
36 | 42 | import org.springframework.tests.sample.objects.ITestInterface;
|
@@ -383,43 +389,39 @@ void determineCommonAncestor() {
|
383 | 389 | assertThat(ClassUtils.determineCommonAncestor(String.class, List.class)).isNull();
|
384 | 390 | }
|
385 | 391 |
|
386 |
| - @Test |
387 |
| - public void isPrimitiveWrapper() { |
388 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Boolean.class)).isTrue(); |
389 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Character.class)).isTrue(); |
390 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Byte.class)).isTrue(); |
391 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Short.class)).isTrue(); |
392 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Integer.class)).isTrue(); |
393 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Long.class)).isTrue(); |
394 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Float.class)).isTrue(); |
395 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Double.class)).isTrue(); |
396 |
| - assertThat(ClassUtils.isPrimitiveWrapper(Void.class)).isTrue(); |
| 392 | + @ParameterizedTest |
| 393 | + @WrapperTypes |
| 394 | + void isPrimitiveWrapper(Class<?> type) { |
| 395 | + assertThat(ClassUtils.isPrimitiveWrapper(type)).isTrue(); |
397 | 396 | }
|
398 | 397 |
|
399 |
| - @Test |
400 |
| - public void isPrimitiveOrWrapper() { |
401 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(boolean.class)).isTrue(); |
402 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(char.class)).isTrue(); |
403 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(byte.class)).isTrue(); |
404 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(short.class)).isTrue(); |
405 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(int.class)).isTrue(); |
406 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(long.class)).isTrue(); |
407 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(float.class)).isTrue(); |
408 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(double.class)).isTrue(); |
409 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(void.class)).isTrue(); |
| 398 | + @ParameterizedTest |
| 399 | + @PrimitiveTypes |
| 400 | + void isPrimitiveOrWrapperWithPrimitive(Class<?> type) { |
| 401 | + assertThat(ClassUtils.isPrimitiveOrWrapper(type)).isTrue(); |
| 402 | + } |
410 | 403 |
|
411 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Boolean.class)).isTrue(); |
412 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Character.class)).isTrue(); |
413 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Byte.class)).isTrue(); |
414 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Short.class)).isTrue(); |
415 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Integer.class)).isTrue(); |
416 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Long.class)).isTrue(); |
417 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Float.class)).isTrue(); |
418 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Double.class)).isTrue(); |
419 |
| - assertThat(ClassUtils.isPrimitiveOrWrapper(Void.class)).isTrue(); |
| 404 | + @ParameterizedTest |
| 405 | + @WrapperTypes |
| 406 | + void isPrimitiveOrWrapperWithWrapper(Class<?> type) { |
| 407 | + assertThat(ClassUtils.isPrimitiveOrWrapper(type)).isTrue(); |
420 | 408 | }
|
421 | 409 |
|
422 | 410 |
|
| 411 | + @Target(ElementType.METHOD) |
| 412 | + @Retention(RetentionPolicy.RUNTIME) |
| 413 | + @ValueSource(classes = { Boolean.class, Character.class, Byte.class, Short.class, |
| 414 | + Integer.class, Long.class, Float.class, Double.class, Void.class }) |
| 415 | + @interface WrapperTypes { |
| 416 | + } |
| 417 | + |
| 418 | + @Target(ElementType.METHOD) |
| 419 | + @Retention(RetentionPolicy.RUNTIME) |
| 420 | + @ValueSource(classes = { boolean.class, char.class, byte.class, short.class, |
| 421 | + int.class, long.class, float.class, double.class, void.class }) |
| 422 | + @interface PrimitiveTypes { |
| 423 | + } |
| 424 | + |
423 | 425 | public static class InnerClass {
|
424 | 426 |
|
425 | 427 | static boolean noArgCalled;
|
|
0 commit comments