-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #15. Almost done. Need more testing and check if package is tak…
…en into account
- Loading branch information
1 parent
36fa9b1
commit 32fdfef
Showing
11 changed files
with
282 additions
and
76 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...rary-integration-tests/src/main/java/org/boundbox/sample/MultipleInnerClassTestClass.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 org.boundbox.sample; | ||
|
||
@edu.umd.cs.findbugs.annotations.SuppressWarnings( | ||
value={"URF_UNREAD_FIELD"}, | ||
justification="Only used for tests") | ||
public class MultipleInnerClassTestClass { | ||
public class InnerClass { | ||
public int a = 0; | ||
}; | ||
public static class StaticInnerClass2 { | ||
public int a = 3; | ||
}; | ||
public static class StaticInnerClass { | ||
public int a = 2; | ||
}; | ||
public class InnerClass2 { | ||
public int a = 1; | ||
}; | ||
} |
14 changes: 14 additions & 0 deletions
14
...dbox-library-integration-tests/src/main/java/org/boundbox/sample/VisibilityTestClass.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,14 @@ | ||
package org.boundbox.sample; | ||
|
||
@SuppressWarnings("unused") | ||
@edu.umd.cs.findbugs.annotations.SuppressWarnings( | ||
value={"URF_UNREAD_FIELD"}, | ||
justification="Only used for tests") | ||
public class VisibilityTestClass { | ||
private class Inner { | ||
public class InnerInner{ | ||
private C foo = new C(); | ||
} | ||
} | ||
private static class C {} | ||
} |
46 changes: 46 additions & 0 deletions
46
...x-library-integration-tests/src/test/java/org/boundbox/sample/MultipleInnerClassTest.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,46 @@ | ||
package org.boundbox.sample; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.boundbox.BoundBox; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class MultipleInnerClassTest { | ||
|
||
private MultipleInnerClassTestClass multipleInnerClassTestClassInstance; | ||
@BoundBox(boundClass = MultipleInnerClassTestClass.class) | ||
private BoundBoxOfMultipleInnerClassTestClass boundBoxOfA; | ||
|
||
@Before | ||
public void setup() { | ||
multipleInnerClassTestClassInstance = new MultipleInnerClassTestClass(); | ||
boundBoxOfA = new BoundBoxOfMultipleInnerClassTestClass(multipleInnerClassTestClassInstance); | ||
} | ||
|
||
@Test | ||
public void test_read_access_to_field() { | ||
//given | ||
Object innerInstance = boundBoxOfA.boundBox_new_InnerClass(); | ||
Object innerInstance2 = boundBoxOfA.boundBox_new_InnerClass2(); | ||
Object staticInnerInstance = BoundBoxOfMultipleInnerClassTestClass.boundBox_new_StaticInnerClass(); | ||
Object staticInnerInstance2 = BoundBoxOfMultipleInnerClassTestClass.boundBox_new_StaticInnerClass2(); | ||
|
||
//when | ||
BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfInnerClass boundBoxOfInner = boundBoxOfA.new BoundBoxOfInnerClass(innerInstance); | ||
BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfInnerClass2 boundBoxOfInner2 = boundBoxOfA.new BoundBoxOfInnerClass2(innerInstance2); | ||
BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfStaticInnerClass boundBoxOfStaticInner = new BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfStaticInnerClass(staticInnerInstance); | ||
BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfStaticInnerClass2 boundBoxOfStaticInner2 = new BoundBoxOfMultipleInnerClassTestClass.BoundBoxOfStaticInnerClass2(staticInnerInstance2); | ||
|
||
//then | ||
assertEquals("org.boundbox.sample.MultipleInnerClassTestClass$InnerClass", innerInstance.getClass().getName()); | ||
assertEquals("org.boundbox.sample.MultipleInnerClassTestClass$InnerClass2", innerInstance2.getClass().getName()); | ||
assertEquals("org.boundbox.sample.MultipleInnerClassTestClass$StaticInnerClass", staticInnerInstance.getClass().getName()); | ||
assertEquals("org.boundbox.sample.MultipleInnerClassTestClass$StaticInnerClass2", staticInnerInstance2.getClass().getName()); | ||
|
||
assertEquals(0,boundBoxOfInner.boundBox_getA()); | ||
assertEquals(1,boundBoxOfInner2.boundBox_getA()); | ||
assertEquals(2,boundBoxOfStaticInner.boundBox_getA()); | ||
assertEquals(3,boundBoxOfStaticInner2.boundBox_getA()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
boundbox-library-integration-tests/src/test/java/org/boundbox/sample/VisibilityTest.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,42 @@ | ||
package org.boundbox.sample; | ||
|
||
import static org.junit.Assert.assertNotEquals; | ||
import static org.junit.Assert.assertNotSame; | ||
|
||
import org.boundbox.BoundBox; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class VisibilityTest { | ||
|
||
private VisibilityTestClass visibilityTestClassA; | ||
@BoundBox(boundClass = VisibilityTestClass.class) | ||
private BoundBoxOfVisibilityTestClass boundBoxOfA; | ||
|
||
@Before | ||
public void setup() { | ||
visibilityTestClassA = new VisibilityTestClass(); | ||
boundBoxOfA = new BoundBoxOfVisibilityTestClass(visibilityTestClassA); | ||
} | ||
|
||
@Test | ||
public void test_read_access_to_field() { | ||
System.out.println("Inner classes of VisibilityTestClass"); | ||
for(Class<?> c : VisibilityTestClass.class.getDeclaredClasses()) { | ||
System.out.println(c.getName()); | ||
} | ||
//given | ||
Object innerInstance = boundBoxOfA.boundBox_new_Inner(); | ||
Object cInstance = BoundBoxOfVisibilityTestClass.boundBox_new_C(); | ||
|
||
//when | ||
BoundBoxOfVisibilityTestClass.BoundBoxOfInner boundBoxOfInner = boundBoxOfA.new BoundBoxOfInner(innerInstance); | ||
Object innerInnerInstance = boundBoxOfInner.boundBox_new_InnerInner(); | ||
BoundBoxOfVisibilityTestClass.BoundBoxOfInner.BoundBoxOfInnerInner boundBoxOfInnerInner = boundBoxOfInner.new BoundBoxOfInnerInner(innerInnerInstance); | ||
|
||
//then | ||
assertNotEquals(innerInstance, cInstance); | ||
assertNotEquals(innerInstance.getClass(), cInstance.getClass()); | ||
assertNotSame(null, boundBoxOfInnerInner.boundBox_getFoo()); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.