public boolean insertInsertedClass = false;
@Override
public void setUp() {
// Create a source class that passes fine (just to test infrastructure.)
sourceOracle.addOrReplace(new MockJavaResource("test.A") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package test;\n");
code.append("class A {\n");
code.append(" void myFunc() {\n");
code.append(" }\n");
code.append("}\n");
return code;
}
});
// Create a source file containing a reference to a class in another
// package that we don't yet know about. That code will be inserted
// by the AdditionalTypeProviderDelegate.
sourceOracle.addOrReplace(new MockJavaResource("test.B") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package test;\n");
code.append("import myPackage.InsertedClass;");
code.append("class B {\n");
code.append(" int func() {\n");
// Reference an unknown class that will be substituted on the fly.
code.append(" return myPackage.InsertedClass.getSmallNumber();\n");
code.append(" }\n");
code.append("}\n");
return code;
}
});
// Create a source file containing a reference to a class in another
// package, but that lacks an import directive. Are we creating the
// class anyway?
sourceOracle.addOrReplace(new MockJavaResource("test.B1") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package test;\n");
code.append("class B1 {\n");