diff --git a/src/test/java/com/squareup/javapoet/JavaFileTest.java b/src/test/java/com/squareup/javapoet/JavaFileTest.java index 0f8eeb672..16e063db8 100644 --- a/src/test/java/com/squareup/javapoet/JavaFileTest.java +++ b/src/test/java/com/squareup/javapoet/JavaFileTest.java @@ -17,6 +17,7 @@ import java.util.Date; import javax.lang.model.element.Modifier; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -116,6 +117,43 @@ public final class JavaFileTest { + "}\n"); } + @Ignore("https://github.com/square/javapoet/issues/298") + @Test public void conflictingSimpleNames() throws Exception { + String source = JavaFile.builder("com.squareup.tacos", + TypeSpec.classBuilder("A") + .addType(TypeSpec.classBuilder("B") + .addType(TypeSpec.classBuilder("Twin").build()) + .addType(TypeSpec.classBuilder("C") + .addField(ClassName.get("com.squareup.tacos", "A", "Twin", "D"), "d") + .build()) + .build()) + .addType(TypeSpec.classBuilder("Twin") + .addType(TypeSpec.classBuilder("D") + .build()) + .build()) + .build()) + .build() + .toString(); + assertThat(source).isEqualTo("" + + "package com.squareup.tacos;\n" + + "\n" + + "class A {\n" + + " class B {\n" + + " class Twin {\n" + + " }\n" + + "\n" + + " class C {\n" + + " A.Twin.D d;\n" + + " }\n" + + " }\n" + + "\n" + + " class Twin {\n" + + " class D {\n" + + " }\n" + + " }\n" + + "}\n"); + } + @Test public void defaultPackage() throws Exception { String source = JavaFile.builder("", TypeSpec.classBuilder("HelloWorld")