@@ -0,0 +1,2717 @@
+package net.sf.jabref;%0A%0Aimport com.google.common.base.Charsets;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors;%0A%0A@RunWith(Parameterized.class)%0Apublic class ArchitectureTests %7B%0A%0A    public static final String PACKAGE_JAVAX_SWING = %22javax.swing%22;%0A    public static final String PACKAGE_JAVA_AWT = %22java.awt%22;%0A    public static final String PACKAGE_NET_SF_JABREF_GUI = %22net.sf.jabref.gui%22;%0A%0A    private final String firstPackage;%0A    private final String secondPackage;%0A%0A    public ArchitectureTests(String firstPackage, String secondPackage) %7B%0A        this.firstPackage = firstPackage;%0A        this.secondPackage = secondPackage;%0A    %7D%0A%0A    @Parameterized.Parameters(name = %22%7Bindex%7D -- is %7B0%7D independent of %7B1%7D?%22)%0A    public static Iterable%3CObject%5B%5D%3E data() %7B%0A        return Arrays.asList(%0A                new Object%5B%5D%5B%5D %7B%0A                        %7B%22net.sf.jabref.logic%22, PACKAGE_JAVA_AWT%7D,%0A                        %7B%22net.sf.jabref.logic%22, PACKAGE_JAVAX_SWING%7D,%0A                        %7B%22net.sf.jabref.logic%22, PACKAGE_NET_SF_JABREF_GUI%7D,%0A                        %7B%22net.sf.jabref.model%22, PACKAGE_JAVA_AWT%7D,%0A                        %7B%22net.sf.jabref.model%22, PACKAGE_JAVAX_SWING%7D,%0A                        %7B%22net.sf.jabref.model%22, PACKAGE_NET_SF_JABREF_GUI%7D%0A                %7D%0A        );%0A    %7D%0A%0A%0A%0A    @Test%0A    public void testLogicIndependentOfSwingAndGui() throws IOException %7B%0A        assertIndependenceOfPackages(firstPackage, secondPackage);%0A    %7D%0A%0A    private void assertIndependenceOfPackages(String firstPackage, String secondPackage) throws IOException %7B%0A        List%3CPath%3E files = Files.walk(Paths.get(%22src%22))%0A                .filter(p -%3E p.toString().endsWith(%22.java%22))%0A                .filter(p -%3E %7B%0A                    try %7B%0A                        return Files.readAllLines(p, Charsets.UTF_8).stream().filter(s -%3E s.startsWith(%22package %22 + firstPackage)).findAny().isPresent();%0A                    %7D catch (IOException e) %7B%0A                        return false;%0A                    %7D%0A                %7D).filter(p -%3E %7B%0A                    try %7B%0A                        return Files.readAllLines(p, Charsets.UTF_8).stream().filter(s -%3E s.startsWith(%22import %22 + secondPackage)).findAny().isPresent();%0A                    %7D catch (IOException e) %7B%0A                        return false;%0A                    %7D%0A                %7D).collect(Collectors.toList());%0A%0A        if(!files.isEmpty()) %7B%0A            Assert.fail(files.toString());%0A        %7D%0A    %7D%0A%0A%7D%0A

Enforce architecture by failing on wrong package dependencies