Re: [JGit Patch v2 4/7] Use test resources from classpath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



imyousuf@xxxxxxxxx wrote:
> From: Imran M Yousuf <imyousuf@xxxxxxxxxxxxxxxxxxxxxx>
> 
> Searched and fixed usage of resources, all tests are now passing and using
> classpath resources.
> 
> A utility class for test classes are created. One of its operation turns
> classpath resources to File and it is used by all test classes to locate
> test resources.

I would change the way you do this series a little bit.

Start the series with this patch, only have JGitTestUtil do:

	return new File("test", name);

like DirCacheCGitCompatabilityTest.pathOf does.  That way you
have the code replacement done in the first step, before you start
mucking around with the resource locations.

In the 2nd patch, change JGitTestUtil to get resources from
the classpath, move (not copy) the resources, and add the
tst-rsc directory to the Eclipse .classpath file.

In the 3rd patch, add your Maven POM file, including the .gitignore
for "target".

The tests will always work, and we don't get this weird copy-delete
pair on the resources.

> +/**
> + *
> + * @author imyousuf
> + */
> +public abstract class JGitTestUtil {

We don't comment classes like this.  Either document it for real,
or remove the Javadoc comment entirely.  In "real" documentation
we do not include @author tags.

> +    public static final String CLASSPATH_TO_RESOURCES =
> +        "/org/spearce/jgit/test/resources/";
> +    private JGitTestUtil() {
> +        throw new AssertionError();
> +    }
> +    
> +    public static File getTestResourceFile(String fileName) {
> +        if(fileName == null || fileName.length() <= 0) {

Formatting error.  We put space between "if(".

> +            return null;
> +        }
> +        URL url = JGitTestUtil.class.getResource(
> +            new StringBuilder(CLASSPATH_TO_RESOURCES)
> +                .append(fileName).toString());
> +        return new File(url.getPath());
> +    }
>  }

-- 
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux