Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanenicolas committed Oct 17, 2013
1 parent 3388943 commit c248334
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class NonStaticInnerClassInheritsStaticInnerClassTestClass {
//this test is order dependent, that's a fail.
//there is absolutely nothing that we can do to prevent this.
private static class StaticInnerClass {
public static int foo = 2;
private static int foo = 2;
}

public class InnerClass extends StaticInnerClass {
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public Void visitTypeAsClass(TypeElement e, ScanningContext scanningContext) {
return null;
}

if (visitiedTypes.contains(e.toString())) {
log.info("dropping visitied class ->" + e.getSimpleName());
return null;
}
visitiedTypes.add(e.toString());

doCheckVisibilityOfType(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,30 @@ public void testProcess_class_with_non_static_inner_class_inheriting_fields_from
FieldInfoFoo.setEffectiveInheritanceLevel(0);
assertContains(listFieldInfos, FieldInfoFoo);
}

@Test
public void testProcess_class_with_non_static_inner_class_inheriting_fields_from_a_static_inner_class_in_same_outer_class() throws URISyntaxException {
// given
String[] testSourceFileNames = new String[] { "TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.java" };
CompilationTask task = processAnnotations(testSourceFileNames, boundBoxProcessor);

// when
// Perform the compilation task.
task.call();

// then
assertFalse(boundBoxProcessor.getListClassInfo().isEmpty());
ClassInfo classInfo = boundBoxProcessor.getListClassInfo().get(0);

List<FieldInfo> listFieldInfos = classInfo.getListInnerClassInfo().get(1).getListFieldInfos();

FieldInfo FieldInfoFoo = new FieldInfo("foo", int.class.getName());
FieldInfoFoo.setStaticField(false);
FieldInfoFoo.setInheritanceLevel(1);
FieldInfoFoo.setEffectiveInheritanceLevel(0);
assertContains(listFieldInfos, FieldInfoFoo);
}


@Test
public void testProcess_class_with_composition_of_static_inner_class() throws URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import org.boundbox.BoundBox;

//Thanks to Philippe Prados for this nasty example
@BoundBox(boundClass = TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.StaticInner.class)
@SuppressWarnings("unused")
//TDD for issue #18
@BoundBox(boundClass = TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.InnerClass.class)
public class TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass {
public class InnerClass {
private int foo = 2;
public class InnerClass extends StaticInner {
}

public static class StaticInner extends InnerClass {
public StaticInner(TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass obj) {
obj.super();
}
public static class StaticInner {
public static int foo = 2;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import org.boundbox.BoundBox;

//TDD for issue #18
@BoundBox(boundClass = TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.InnerClass.class)
//Thanks to Philippe Prados for this nasty example
@BoundBox(boundClass = TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.StaticInner.class)
@SuppressWarnings("unused")
public class TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass {
public class InnerClass extends StaticInner {
public class InnerClass {
private int foo = 2;
}

public static class StaticInner {
public static int foo = 2;
public static class StaticInner extends InnerClass {
public StaticInner(TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass obj) {
obj.super();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import org.boundbox.BoundBox;

//TDD for issue #18
@SuppressWarnings("unused")
@BoundBox(boundClass = TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.class)
public class TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass {

public static class StaticInner {
private static int foo = 2;
}
public class SubInnerClass extends StaticInner {
}
}

0 comments on commit c248334

Please sign in to comment.