Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-935

ResourceFactory incorrectly handles specific resources

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 2.0.0.Alpha5
    • 2.0.0.Alpha4
    • Resources
    • None

    Description

      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)));
         }
      

      Attachments

        Activity

          People

            rhn-support-ggastald George Gastaldi
            rhn-support-ggastald George Gastaldi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: