/
AccessModeClassTests.java
75 lines (68 loc) · 2.98 KB
/
AccessModeClassTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package org.j8unit.repository.java.nio.file;
import static org.junit.Assert.assertTrue;
import java.nio.file.AccessMode;
import org.j8unit.repository.categories.J8UnitRepository;
import org.j8unit.repository.java.lang.EnumClassTests;
import org.junit.Test;
import org.junit.experimental.categories.Category;
/**
* <p>
* Reusable j8unit test interface containing the type relevant aspects – i. e., runtime constraints
* and further type specific requirements – of the hereby targeted type-under-test {@link AccessMode public
* final enum java.nio.file.AccessMode}.
*
* (In addition, the runtime type of this j8unit test interface's generic type is verified by
* {@link #verifyGenericType()}).
* </p>
*
* <p>
* The complementary j8unit test interface containing the instance relevant aspects is
* {@link org.j8unit.repository.java.nio.file.AccessModeTests}.
* </p>
*
* <p>
* <strong>What? Testing the class/the type itself? What is it good for?</strong>
* </p>
*
* <p>
* Classes/Types may have its own requirements and/or constraints; and all of these needs to be tested too!
*
* For example, all sub-types of {@link Throwable} should provide a zero-argument and a {@link String}-argument
* constructor. Obviously, this is a class-specific behaviour. In general, all constraints referring to the provision of
* specific constructors (and its individual requirements) should be covered by according test methods. (Note, this is
* not limited to constructors only; Just think of factory methods and further.)
*
* For another example, <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.6.1">
* <q>by virtue of the <em>AnnotationTypeElementDeclaration</em> production, a method declaration in an annotation type
* declaration cannot have formal parameters, type parameters, or a {@code throws} clause</q> (JLS,
* Sec. 9.6.1</a>). Obviously, this is a type-specific behaviour too; And it must be tested!
* </p>
*
* @param SUT
* the class' type of the subject-under-test
* @since 0.9.0
*/
@FunctionalInterface
@Category(J8UnitRepository.class)
public abstract interface AccessModeClassTests<SUT extends AccessMode>
extends EnumClassTests<SUT> {
// J8UNIT-MARKER-[BEGIN]-[CLASS]-[java.nio.file.AccessMode]
/**
* @see Class#isAssignableFrom(Class) public native boolean java.lang.Class.isAssignableFrom(java.lang.Class<?>)
* (the hereby targeted method-under-test)
*
* @since 0.9.2
*/
@Override
@Test
public default void verifyGenericType()
throws Exception {
// create new instance
final Class<SUT> sut = createNewSUT();
// assert assignability
assertTrue("This j8unit test interface is used with a generic type that is illegaly not assignable to AccessMode.class!",
AccessMode.class.isAssignableFrom(sut));
}
// J8UNIT-MARKER-[MANUAL]-[CLASS]-[java.nio.file.AccessMode]
// J8UNIT-MARKER-[END]-[CLASS]-[java.nio.file.AccessMode]
}