All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.ac.auckland.integration.testing.resource.JsonTestResource Maven / Gradle / Ivy

The newest version!
package nz.ac.auckland.integration.testing.resource;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.net.URL;

/**
 * Provides a mechanism for retrieving JSON values from a file/URL/String and also
 * validating the response from a target service.
 *
 * @author David MacDonald 
 */
public class JsonTestResource extends StaticTestResource {

    public JsonTestResource(String value) {
        super(value);
    }

    public JsonTestResource(File file) {
        super(file);
    }

    public JsonTestResource(URL url) {
        super(url);
    }

    /**
     * @param file a reference to the JSON test resource
     * @return A JSON string
     * @throws Exception
     */
    protected String getResource(File file) throws Exception {
        return FileUtils.readFileToString(file);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy