Skip to content

Commit 387c3ec

Browse files
committed
DATAJDBC-220 - Added a Degraph test for inter module dependencies.
The existing test only analysed Spring Data JDBC itself. The new test also considers packages from commons and treats org.springframework.data.x.X and org.springframework.data.jdbc.x.Y as belonging to the same "sub-module" "x".
1 parent e4de570 commit 387c3ec

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

src/test/java/org/springframework/data/jdbc/degraph/DependencyTests.java

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,52 @@
1414
* limitations under the License.
1515
*/
1616
package org.springframework.data.jdbc.degraph;
17-
import static de.schauderhaft.degraph.check.JCheck.classpath;
18-
import static org.junit.Assert.assertThat;
1917

20-
import org.junit.Test;
18+
import static de.schauderhaft.degraph.check.JCheck.*;
19+
import static org.junit.Assert.*;
2120

2221
import de.schauderhaft.degraph.check.JCheck;
22+
import scala.runtime.AbstractFunction1;
23+
24+
import org.junit.Test;
2325

2426
/**
27+
* Test package dependencies for violations.
28+
*
2529
* @author Jens Schauder
2630
*/
2731
public class DependencyTests {
2832

29-
@Test public void test() {
30-
assertThat( classpath()
31-
.noJars()
32-
.including("org.springframework.data.jdbc.**")
33-
.filterClasspath("*target/classes")
34-
.printOnFailure("degraph.graphml"), JCheck.violationFree());
33+
@Test // DATAJDBC-114
34+
public void cycleFree() {
3535

36+
assertThat( //
37+
classpath() //
38+
.noJars() //
39+
.including("org.springframework.data.jdbc.**") //
40+
.filterClasspath("*target/classes") // exclude test code
41+
.printOnFailure("degraph.graphml"),
42+
JCheck.violationFree());
3643
}
3744

45+
@Test // DATAJDBC-220
46+
public void acrossModules() {
47+
48+
assertThat( //
49+
classpath() //
50+
// include only Spring Data related classes (for example no JDK code)
51+
.including("org.springframework.data.**") //
52+
.filterClasspath(new AbstractFunction1<String, Object>() {
53+
@Override
54+
public Object apply(String s) { //
55+
// only the current module + commons
56+
return s.endsWith("target/classes") || s.contains("spring-data-commons");
57+
}
58+
}) // exclude test code
59+
.withSlicing("sub-modules", // sub-modules are defined by any of the following pattern.
60+
"org.springframework.data.jdbc.(**).*", //
61+
"org.springframework.data.(**).*") //
62+
.printTo("degraph-across-modules.graphml"), // writes a graphml to this location
63+
JCheck.violationFree());
64+
}
3865
}

0 commit comments

Comments
 (0)