-
Bug
-
Resolution: Done
-
Critical
-
2.0.0.Alpha4
-
None
When ResourceFactory.create(Object) is called and the argument is a File pointing to a *.java file, I expect a JavaResource object to be returned, however, a FileResource is returned instead.
It appears that the algorithm is not deterministic, since I've seen it return JavaResource sometimes.
The following failling test illustrates it:
@Test public void testJavaResourceCreationSpecialized() throws Exception { JavaClass javaClass = JavaParser.create(JavaClass.class).setPackage("org.jboss.forge.test").setName("Example"); JavaResource resource = factory.create(JavaResource.class, File.createTempFile("forge", ".java")); resource.createNewFile(); resource.setContents(javaClass); Resource<File> newResource = factory.create(resource.getUnderlyingResourceObject()); Assert.assertThat(newResource, is(instanceOf(JavaResource.class))); }