-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated ArchUnit-Example for version 0.9.0. There are now three subpr…
…ojects, each demonstrating how to use the respective 'flavor' of ArchUnit. Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
- Loading branch information
1 parent
9802e82
commit 249d837
Showing
378 changed files
with
4,551 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
apply plugin: 'java' | ||
subprojects { | ||
apply plugin: 'java' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// These are the 'production' dependencies of the Demo src/main/java files -> just for Demo purposes, otherwise irrelevant | ||
compile 'org.apache.geronimo.specs:geronimo-ejb_3.1_spec:1.0' | ||
compile 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0' | ||
dependencies { | ||
// These are the 'production' dependencies of the Demo src/main/java files -> just for Demo purposes, otherwise irrelevant | ||
compile 'org.apache.geronimo.specs:geronimo-ejb_3.1_spec:1.0' | ||
compile 'org.apache.geronimo.specs:geronimo-jpa_2.0_spec:1.0' | ||
} | ||
|
||
// This is the only dependency necessary, to run ArchUnit -> substitute 'archunit-junit' with 'archunit' if you don't use JUnit 4 | ||
testCompile 'com.tngtech.archunit:archunit-junit:0.8.3' | ||
tasks.withType(AbstractCompile) { | ||
options.compilerArgs += ["--add-modules", "java.xml.ws.annotation"] | ||
} | ||
} | ||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion = '4.7' | ||
} | ||
|
||
tasks.withType(AbstractCompile) { | ||
options.compilerArgs += ["--add-modules", "java.xml.ws.annotation"] | ||
} | ||
gradleVersion = '4.9' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
testCompile 'com.tngtech.archunit:archunit-junit4:0.9.0' | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
example-junit4/src/main/java/com/tngtech/archunit/example/EvilCoreAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tngtech.archunit.example; | ||
|
||
import com.tngtech.archunit.example.core.VeryCentralCore; | ||
|
||
@SuppressWarnings("unused") | ||
public class EvilCoreAccessor { | ||
void iShouldNotAccessCore() { | ||
new VeryCentralCore().doCoreStuff(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
example-junit4/src/main/java/com/tngtech/archunit/example/SomeOtherBusinessInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tngtech.archunit.example; | ||
|
||
public interface SomeOtherBusinessInterface { | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
...it/example/controller/SomeController.java → ...it/example/controller/SomeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package com.tngtech.archunit.example.controller; | ||
|
||
import com.tngtech.archunit.example.service.ServiceViolatingDaoRules; | ||
import com.tngtech.archunit.example.service.ServiceViolatingLayerRules; | ||
|
||
public class SomeController { | ||
private ServiceViolatingDaoRules service; | ||
private ServiceViolatingLayerRules otherService; | ||
|
||
void doSthController() { | ||
service.doSthService(); | ||
} | ||
|
||
void doSthWithSecuredService() { | ||
otherService.properlySecured(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
example-junit4/src/main/java/com/tngtech/archunit/example/controller/SomeGuiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tngtech.archunit.example.controller; | ||
|
||
import com.tngtech.archunit.example.service.ServiceHelper; | ||
|
||
public class SomeGuiController { | ||
void callServiceLayer() { | ||
ServiceHelper helper = new ServiceHelper(); | ||
new ServiceHelper("this is okay"); | ||
|
||
process(helper.insecure); | ||
process(helper.properlySecured); | ||
} | ||
|
||
private void process(Object object) { | ||
} | ||
} |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
.../example/controller/WronglyAnnotated.java → .../example/controller/WronglyAnnotated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package com.tngtech.archunit.example.controller; | ||
|
||
import com.tngtech.archunit.example.MyController; | ||
import com.tngtech.archunit.example.core.HighSecurity; | ||
|
||
@HighSecurity | ||
@MyController | ||
public class WronglyAnnotated { | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
example-junit4/src/main/java/com/tngtech/archunit/example/core/AnotherGoodCoreSatellite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tngtech.archunit.example.core; | ||
|
||
@SuppressWarnings("unused") | ||
public class AnotherGoodCoreSatellite implements CoreSatellite { | ||
VeryCentralCore centralCore; | ||
|
||
void iAlsoMayAccessCore() { | ||
centralCore.doCoreStuff(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
example-junit4/src/main/java/com/tngtech/archunit/example/core/CoreSatellite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tngtech.archunit.example.core; | ||
|
||
public interface CoreSatellite { | ||
} |
10 changes: 10 additions & 0 deletions
10
example-junit4/src/main/java/com/tngtech/archunit/example/core/GoodCoreSatellite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.tngtech.archunit.example.core; | ||
|
||
@SuppressWarnings("unused") | ||
public class GoodCoreSatellite implements CoreSatellite { | ||
VeryCentralCore centralCore; | ||
|
||
void iMayAccessCore() { | ||
centralCore.doCoreStuff(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
example-junit4/src/main/java/com/tngtech/archunit/example/core/HighSecurity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tngtech.archunit.example.core; | ||
|
||
import java.lang.annotation.Retention; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Retention(RUNTIME) | ||
public @interface HighSecurity { | ||
} |
17 changes: 17 additions & 0 deletions
17
example-junit4/src/main/java/com/tngtech/archunit/example/core/VeryCentralCore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.tngtech.archunit.example.core; | ||
|
||
import com.tngtech.archunit.example.SomeOtherBusinessInterface; | ||
import com.tngtech.archunit.example.web.AnnotatedController; | ||
|
||
@HighSecurity | ||
@SuppressWarnings("unused") | ||
public class VeryCentralCore implements SomeOtherBusinessInterface { | ||
public static final String DO_CORE_STUFF_METHOD_NAME = "doCoreStuff"; | ||
|
||
public void doCoreStuff() { | ||
} | ||
|
||
void coreDoingIllegalStuff() { | ||
new AnnotatedController(); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../ClassOfMinimalCircleCallingSliceTwo.java → ...1/ClassOfMinimalCycleCallingSliceTwo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../ClassOfMinimalCircleCallingSliceOne.java → ...2/ClassOfMinimalCycleCallingSliceOne.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
...om/tngtech/archunit/example/cycle/membercycle/slice1/SliceOneWithFieldTypeInSliceTwo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tngtech.archunit.example.cycle.membercycle.slice1; | ||
|
||
import com.tngtech.archunit.example.cycle.membercycle.slice2.SliceTwoWithMethodParameterTypeInSliceThree; | ||
|
||
public class SliceOneWithFieldTypeInSliceTwo { | ||
public SliceTwoWithMethodParameterTypeInSliceThree classInSliceTwo; | ||
} |
8 changes: 8 additions & 0 deletions
8
...rchunit/example/cycle/membercycle/slice2/SliceTwoWithMethodParameterTypeInSliceThree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.tngtech.archunit.example.cycle.membercycle.slice2; | ||
|
||
import com.tngtech.archunit.example.cycle.membercycle.slice3.SliceThreeWithMethodReturnTypeInSliceFour; | ||
|
||
public class SliceTwoWithMethodParameterTypeInSliceThree { | ||
public void methodWithParameterInSliceThree(SliceThreeWithMethodReturnTypeInSliceFour methodParameter) { | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
.../archunit/example/cycle/membercycle/slice3/SliceThreeWithMethodReturnTypeInSliceFour.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tngtech.archunit.example.cycle.membercycle.slice3; | ||
|
||
import com.tngtech.archunit.example.cycle.membercycle.slice4.SliceFourWithConstructorParameterInSliceOne; | ||
|
||
public class SliceThreeWithMethodReturnTypeInSliceFour { | ||
public SliceFourWithConstructorParameterInSliceOne methodWithReturnTypeInSliceFour() { | ||
return null; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...rchunit/example/cycle/membercycle/slice4/SliceFourWithConstructorParameterInSliceOne.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.tngtech.archunit.example.cycle.membercycle.slice4; | ||
|
||
import com.tngtech.archunit.example.cycle.membercycle.slice1.SliceOneWithFieldTypeInSliceTwo; | ||
|
||
public class SliceFourWithConstructorParameterInSliceOne { | ||
public SliceFourWithConstructorParameterInSliceOne(SliceOneWithFieldTypeInSliceTwo fieldInSliceTwo) { | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
example-junit4/src/main/java/com/tngtech/archunit/example/security/Secured.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.tngtech.archunit.example.security; | ||
|
||
import java.lang.annotation.Retention; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Retention(RUNTIME) | ||
public @interface Secured { | ||
} |
19 changes: 19 additions & 0 deletions
19
example-junit4/src/main/java/com/tngtech/archunit/example/service/ServiceHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.tngtech.archunit.example.service; | ||
|
||
import com.tngtech.archunit.example.security.Secured; | ||
|
||
/** | ||
* Well modelled code always has lots of 'helpers' ;-) | ||
*/ | ||
public class ServiceHelper { | ||
public Object insecure = new Object(); | ||
@Secured | ||
public Object properlySecured = new Object(); | ||
|
||
public ServiceHelper() { | ||
} | ||
|
||
@Secured | ||
public ServiceHelper(String properlySecured) { | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/address/Address.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tngtech.archunit.example.shopping.address; | ||
|
||
import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; | ||
|
||
public class Address { | ||
private ProductCatalog productCatalog; | ||
} |
15 changes: 15 additions & 0 deletions
15
...le-junit4/src/main/java/com/tngtech/archunit/example/shopping/catalog/ProductCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.tngtech.archunit.example.shopping.catalog; | ||
|
||
import java.util.Set; | ||
|
||
import com.tngtech.archunit.example.shopping.order.Order; | ||
import com.tngtech.archunit.example.shopping.product.Product; | ||
|
||
public class ProductCatalog { | ||
public Set<Product> allProducts; | ||
|
||
void gonnaDoSomethingIllegalWithOrder() { | ||
Order order = new Order(); | ||
order.addProducts(allProducts); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/customer/Customer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tngtech.archunit.example.shopping.customer; | ||
|
||
import com.tngtech.archunit.example.shopping.address.Address; | ||
|
||
public class Customer { | ||
public Address address; | ||
} |
16 changes: 16 additions & 0 deletions
16
...le-junit4/src/main/java/com/tngtech/archunit/example/shopping/importer/ProductImport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tngtech.archunit.example.shopping.importer; | ||
|
||
import com.tngtech.archunit.example.shopping.catalog.ProductCatalog; | ||
import com.tngtech.archunit.example.shopping.customer.Customer; | ||
import com.tngtech.archunit.example.shopping.xml.processor.XmlProcessor; | ||
import com.tngtech.archunit.example.shopping.xml.types.XmlTypes; | ||
|
||
public class ProductImport { | ||
public ProductCatalog productCatalog; | ||
public XmlTypes xmlType; | ||
public XmlProcessor xmlProcessor; | ||
|
||
public Customer getCustomer() { | ||
return new Customer(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/order/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.tngtech.archunit.example.shopping.order; | ||
|
||
import java.util.Set; | ||
|
||
import com.tngtech.archunit.example.shopping.customer.Customer; | ||
import com.tngtech.archunit.example.shopping.product.Product; | ||
|
||
public class Order { | ||
public Customer customer; | ||
public Set<Product> products; | ||
|
||
public void addProducts(Set<Product> products) { | ||
this.products.addAll(products); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/product/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.tngtech.archunit.example.shopping.product; | ||
|
||
import com.tngtech.archunit.example.shopping.customer.Customer; | ||
|
||
public class Product { | ||
public Customer customer; | ||
} |
4 changes: 4 additions & 0 deletions
4
...unit4/src/main/java/com/tngtech/archunit/example/shopping/xml/processor/XmlProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tngtech.archunit.example.shopping.xml.processor; | ||
|
||
public class XmlProcessor { | ||
} |
4 changes: 4 additions & 0 deletions
4
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/xml/types/XmlTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tngtech.archunit.example.shopping.xml.types; | ||
|
||
public class XmlTypes { | ||
} |
4 changes: 4 additions & 0 deletions
4
example-junit4/src/main/java/com/tngtech/archunit/example/shopping/xml/utils/XmlUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.tngtech.archunit.example.shopping.xml.utils; | ||
|
||
public class XmlUtils { | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.