return Collections.<Resource> singleton(new EmptyMockJavaResource(
com.google.web.bindery.requestfactory.shared.Violation.class));
}
private Set<Resource> getJavaResources() {
MockJavaResource[] javaFiles = {new MockJavaResource("t.AddressProxy") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("interface AddressProxy extends EntityProxy {\n");
code.append("String getCity();\n");
code.append("void setCity(String city);\n");
code.append("String getStreet();\n");
code.append("void setStreet(String street);\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.AddressEditor") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("class AddressEditor implements Editor<AddressProxy> {\n");
code.append("public SimpleEditor<String> city;\n");
code.append("public SimpleEditor<String> street;\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.CompositeProxy") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("interface CompositeProxy extends EntityProxy {\n");
code.append("AddressProxy getAddress();\n");
code.append("PersonProxy getPerson();\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.CompositeEditor") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("class CompositeEditor implements Editor<CompositeProxy> {\n");
code.append("AddressEditor address;\n");
code.append("PersonEditor person(){return null;}\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.CompositeEditorDriver") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface CompositeEditorDriver extends RequestFactoryEditorDriver<CompositeProxy, CompositeEditor> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.CyclicEditorDriver") {
// Tests error-detection when the editor graph isn't a DAG
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface CyclicEditorDriver extends"
+ " RequestFactoryEditorDriver<CyclicEditorDriver.AProxy,"
+ " CyclicEditorDriver.AEditor> {\n");
code.append(" interface AProxy extends EntityProxy { BProxy getB(); }");
code.append(" interface BProxy extends EntityProxy { AProxy getA(); }");
code.append(" interface AEditor extends Editor<AProxy> {");
code.append(" BEditor bEditor();");
code.append(" }");
code.append(" interface BEditor extends Editor<BProxy> {");
code.append(" AEditor aEditor();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.DottedPathEditorDriver") {
// Tests error-detection when the editor graph isn't a DAG
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("interface DottedPathEditorDriver extends"
+ " RequestFactoryEditorDriver<PersonProxy,"
+ " DottedPathEditorDriver.PersonEditor> {\n");
code.append(" interface PersonEditor extends Editor<PersonProxy> {");
code.append(" SimpleEditor<String> nameEditor();");
code.append(" @Editor.Path(\"address.street\")");
code.append(" SimpleEditor<String> streetEditor();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.ListEditor") {
// Tests error-detection when the editor graph isn't a DAG
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + CompositeEditor.class.getName() + ";\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("interface ListEditor extends CompositeEditor<PersonProxy, AddressProxy, AddressEditor>, Editor<PersonProxy> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.ListEditorDriver") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface ListEditorDriver extends RequestFactoryEditorDriver<PersonProxy, ListEditor> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.MissingGetterEditorDriver") {
// Tests error-detection when the editor structure doesn't match the
// proxy
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("interface MissingGetterEditorDriver extends"
+ " RequestFactoryEditorDriver<MissingGetterEditorDriver.AProxy,"
+ " MissingGetterEditorDriver.AEditor> {\n");
code.append(" interface AProxy extends EntityProxy {}");
code.append(" interface AEditor extends Editor<AProxy> {");
code.append(" SimpleEditor<String> missingEditor();");
code.append(" SimpleEditor<String> yetAgain();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonProxy") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("interface PersonProxy extends EntityProxy {\n");
code.append("AddressProxy getAddress();\n");
code.append("String getName();\n");
code.append("long getLastModified();\n");
code.append("String getReadonly();\n");
code.append("boolean hasHas();\n");
code.append("boolean isIs();\n");
code.append("void setHas(boolean has);\n");
code.append("void setIs(boolean is);\n");
code.append("void setName(String name);\n");
code.append("void setLastModified(long value);\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditor") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("class PersonEditor implements Editor<PersonProxy> {\n");
code.append("SimpleEditor<Boolean> has;\n");
code.append("SimpleEditor<Boolean> is;\n");
code.append("SimpleEditor<Long> lastModified;\n");
code.append("public SimpleEditor<String> name;\n");
code.append("SimpleEditor<String> readonly;\n");
code.append("public static SimpleEditor ignoredStatic;\n");
code.append("private SimpleEditor<String> ignoredPrivate;\n");
code.append("@Editor.Ignore public SimpleEditor<String> ignoredPublic;\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorWithAliasedSubEditors") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("class PersonEditorWithAliasedSubEditors implements Editor<PersonProxy> {\n");
code.append("@Path(\"\") PersonEditor e1;\n");
code.append("@Path(\"\") PersonEditor e2;\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorWithAliasedSubEditorsDriver") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface PersonEditorWithAliasedSubEditorsDriver extends"
+ " RequestFactoryEditorDriver<PersonProxy, t.PersonEditorWithAliasedSubEditors> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorWithBadPrimitiveAccess") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("class PersonEditorWithBadPrimitiveAccess implements Editor<PersonProxy> {\n");
code.append("@Path(\"lastModified.foo\") SimpleEditor<String> bad;\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorWithBadPrimitiveAccessDriver") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface PersonEditorWithBadPrimitiveAccessDriver extends"
+ " RequestFactoryEditorDriver<PersonProxy, t.PersonEditorWithBadPrimitiveAccess> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorUsingMethods") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("abstract class PersonEditorUsingMethods implements Editor<PersonProxy> {\n");
code.append("public abstract SimpleEditor<String> nameEditor();\n");
code.append("protected abstract SimpleEditor<String> readonlyEditor();\n");
code.append("public static SimpleEditor<String> ignoredStatic() {return null;}\n");
code.append("private SimpleEditor<String> ignoredPrivate() {return null;}\n");
code.append("@Editor.Ignore public abstract SimpleEditor<String> ignoredPublic();\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorDriver") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface PersonEditorDriver extends"
+ " RequestFactoryEditorDriver<PersonProxy, PersonEditor> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonEditorDriverUsingMethods") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface PersonEditorDriverUsingMethods extends"
+ " RequestFactoryEditorDriver<PersonProxy, PersonEditorUsingMethods> {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.PersonRequestFactory") {
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactory.class.getName() + ";\n");
code.append("interface PersonRequestFactory extends RequestFactory {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.TooManyInterfacesEditorDriver") {
// Tests a Driver interface that extends more than RFED
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("interface TooManyInterfacesEditorDriver extends"
+ " RequestFactoryEditorDriver<CompositeProxy, CompositeEditor>,"
+ " java.io.Serializable {\n");
code.append("}");
return code;
}
}, new MockJavaResource("t.UnparameterizedEditorEditorDriver") {
// Tests error-detection when the editor structure doesn't match the
// proxy
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("interface UnparameterizedEditorEditorDriver extends"
+ " RequestFactoryEditorDriver<UnparameterizedEditorEditorDriver.AProxy,"
+ " UnparameterizedEditorEditorDriver.AEditor> {\n");
code.append(" interface AProxy extends EntityProxy {}");
code.append(" interface AEditor extends Editor<AProxy> {");
code.append(" SimpleEditor needsParameterization();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.UsesIsEditorDriver") {
// Tests error-detection when the editor structure doesn't match the
// proxy
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + IsEditor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("interface UsesIsEditorDriver extends"
+ " RequestFactoryEditorDriver<UsesIsEditorDriver.AProxy,"
+ " UsesIsEditorDriver.AEditor> {\n");
code.append(" interface AProxy extends EntityProxy { BProxy getB();}");
code.append(" interface BProxy extends EntityProxy { String getString();}");
code.append(" interface AEditor extends Editor<AProxy> {");
code.append(" BView bEditor();");
code.append(" }");
code.append(" interface BView extends IsEditor<BEditor> {");
code.append(" @Editor.Path(\"string\") BEditor unseen();");
code.append(" }");
code.append(" interface BEditor extends Editor<BProxy> {");
code.append(" SimpleEditor<String> stringEditor();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.UsesIsEditorAndEditorDriver") {
// Tests error-detection when the editor structure doesn't match the
// proxy
@Override
public CharSequence getContent() {
StringBuilder code = new StringBuilder();
code.append("package t;\n");
code.append("import " + Editor.class.getName() + ";\n");
code.append("import " + HasEditorErrors.class.getName() + ";\n");
code.append("import " + IsEditor.class.getName() + ";\n");
code.append("import " + EntityProxy.class.getName() + ";\n");
code.append("import " + RequestFactoryEditorDriver.class.getName()
+ ";\n");
code.append("import " + SimpleEditor.class.getName() + ";\n");
code.append("interface UsesIsEditorAndEditorDriver extends"
+ " RequestFactoryEditorDriver<UsesIsEditorAndEditorDriver.AProxy,"
+ " UsesIsEditorAndEditorDriver.AEditor> {\n");
code.append(" interface AProxy extends EntityProxy { BProxy getB();}");
code.append(" interface BProxy extends EntityProxy { String getString();}");
code.append(" interface AEditor extends Editor<AProxy> {");
code.append(" BView bEditor();");
code.append(" }");
code.append(" interface BView extends IsEditor<BEditor>, Editor<BProxy>, HasEditorErrors {");
code.append(" @Editor.Path(\"string\") SimpleEditor<String> viewEditor();");
code.append(" }");
code.append(" interface BEditor extends Editor<BProxy> {");
code.append(" @Editor.Path(\"string\") SimpleEditor<String> coEditor();");
code.append(" }");
code.append("}");
return code;
}
}, new MockJavaResource("t.CompositeAndLeafEditorDriver") {
/*
* Tests that we descend into sub-editor of a CompositeEditor that also is
* a LeafValueEditor (this is the case for the
* c.g.g.editor.client.adapters.OptionalFieldEditor). Also test that any
* editor-like fields within the LeafValueEditor are ignored.