public Resource locateSpecification(Fixture fixture) {
    Check.notNull(fixture, "Fixture is null");
    String fixturePath = fixture.getFixturePathWithoutSuffix();
    String resourcePath = "/" + fixturePath + "." + specificationSuffix;

    return new Resource(resourcePath);
  }
예제 #2
0
 public void write(Resource resource, String s) throws IOException {
   Check.notNull(resource, "resource is null");
   mkdirs(resource);
   FileOutputStream os = new FileOutputStream(getFile(resource));
   Writer writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
   try {
     writer.write(s);
   } finally {
     writer.close();
     os.close();
   }
 }
예제 #3
0
  public void beforeParsing(Document document) {
    nu.xom.Element html = document.getRootElement();
    nu.xom.Element head = html.getFirstChildElement("head");
    Check.notNull(head, "<head> section is missing from document");
    script = new nu.xom.Element("script");
    script.addAttribute(new Attribute("type", "text/javascript"));

    // Fix for Issue #26: Strict XHTML DTD requires an explicit end tag for <script> element
    // Thanks to Matthias Schwegler for reporting and supplying a fix for this.
    script.appendChild("");

    head.appendChild(script);
  }
예제 #4
0
 public void copyTo(Resource resource, InputStream inputStream) throws IOException {
   Check.notNull(resource, "resource is null");
   mkdirs(resource);
   File outputFile = getFile(resource);
   // Do not overwrite if a recent copy already exists
   if (outputFile.exists() && isFreshEnough(outputFile)) {
     return;
   }
   OutputStream outputStream = createOutputStream(resource);
   try {
     IOUtil.copy(inputStream, outputStream);
   } finally {
     outputStream.close();
   }
 }
예제 #5
0
 public OutputStream getOutputStream(Resource resource) throws IOException {
   Check.notNull(resource, "resource is null");
   mkdirs(resource);
   return createOutputStream(resource);
 }
예제 #6
0
 public void delete(Resource resource) throws IOException {
   Check.notNull(resource, "resource is null");
   getFile(resource).delete();
 }