Example usage for org.aspectj.util FileUtil getTempDir

List of usage examples for org.aspectj.util FileUtil getTempDir

Introduction

In this page you can find the example usage for org.aspectj.util FileUtil getTempDir.

Prototype

public static File getTempDir(String name) 

Source Link

Document

Make a new temporary directory in the same directory that the system uses for temporary files, or if that files, in the current directory.

Usage

From source file:org.collectionspace.chain.csp.persistence.TestBase.java

License:Educational Community License

public void testUIspec(ServletTester jetty, String url, String uijson) throws Exception {
    log.info("testUISpec(" + url + ", " + uijson + ")");

    String errMsg = String.format("Failed to create correct uispec for '%s' compared with file '%s'", url,
            uijson);//www.  j  av a2  s .  co m
    JSONObject generated = new JSONObject("{}");
    JSONObject baseline = new JSONObject("{}");
    boolean success = false;

    try {
        HttpTester response = GETData(url, jetty);

        generated = new JSONObject(response.getContent());
        baseline = new JSONObject(getResourceString(uijson));
        xxxfixOptions(generated);
        xxxfixOptions(baseline);

        // You can use these, Chris, to write stuff out if the spec has
        // changed to alter the test file -- dan
        // hendecasyllabic:tmp csm22$ cat gschema.out | pbcopy

        success = JSONUtils.checkJSONEquivOrEmptyStringKey(generated, baseline);
    } catch (Exception e) {
        log.error(errMsg, e);
        errMsg = String.format("%s. %s", errMsg, e.getMessage()); // Append the exception message to our default error message.
    }

    if (!success) {
        File tempDir = FileUtil.getTempDir(uijson);
        // Baseline spec
        File baselineFile = new File(tempDir, uijson + ".baseline.json");
        FileUtil.writeAsString(baselineFile, baseline.toString());

        // Generated spec
        File generatedFile = new File(tempDir, uijson + ".generated.json");
        FileUtil.writeAsString(generatedFile, generated.toString());

        log.error("The following baseline and generated UI specs did not match:");
        log.error("testUIspec(" + uijson + ") BASELINE from file" + baselineFile.getPath());
        log.error("testUIspec(" + url + ") GENERATED from url" + generatedFile.getPath());
    }

    assertTrue(errMsg, success);
}