Escape all names that turn into Java identifiers

This commit is contained in:
Andrey Breslav
2012-07-09 20:53:05 +04:00
parent 69996243b9
commit ed1ca4b77e
2 changed files with 4 additions and 3 deletions
@@ -41,7 +41,7 @@ public class SimpleTestClassModel implements TestClassModel {
this.recursive = recursive; this.recursive = recursive;
this.extension = extension; this.extension = extension;
this.doTestMethodName = doTestMethodName; this.doTestMethodName = doTestMethodName;
this.testClassName = StringUtil.capitalize(rootFile.getName()); this.testClassName = StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(rootFile.getName()));
} }
@Override @Override
@@ -71,7 +71,7 @@ public class SimpleTestClassModel implements TestClassModel {
result.add(new TestMethodModel() { result.add(new TestMethodModel() {
@Override @Override
public String getName() { public String getName() {
return "testAllFilesPresentIn" + StringUtil.capitalize(rootFile.getName()); return "testAllFilesPresentIn" + testClassName;
} }
@Override @Override
@@ -84,6 +84,7 @@ public class SimpleTestClassModel implements TestClassModel {
"\", ", recursive, "\", ", recursive,
");"); ");");
} }
}); });
File[] listFiles = rootFile.listFiles(); File[] listFiles = rootFile.listFiles();
@@ -53,6 +53,6 @@ public class SimpleTestMethodModel implements TestMethodModel {
String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile()); String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile());
unescapedName = relativePath + "-" + StringUtil.capitalize(fileName); unescapedName = relativePath + "-" + StringUtil.capitalize(fileName);
} }
return "test" + TestGeneratorUtil.escapeForJavaIdentifier(StringUtil.capitalize(unescapedName)); return "test" + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
} }
} }