public InputStream createInputStream(Resource resource) throws IOException { InputStream inputStream = getResourceAsStream(resource.getPath()); if (inputStream == null) { throw new IOException(SimpleFormatter.format("Resource '[%s: %s]' not found", this, resource.getPath())); } return inputStream; }
private String[] getPathPieces() { String packagePath = getPackage().getPath(); if ("/".equals(packagePath)) { return new String[]{""}; } return packagePath.split("/"); }
private String[] getPathPieces() { String packagePath = getPackage().getPath(); if ("/".equals(packagePath)) { return new String[]{""}; } return packagePath.split("/"); }
public boolean canFind(Resource resource) { InputStream stream = getResourceAsStream(resource.getPath()); if (stream == null) { return false; } try { stream.close(); } catch (IOException e) { // Ignore } return true; }
public Resource getParent() { if (getPath().equals("/")) { return null; } StringBuilder parentPath = new StringBuilder(); parentPath.append("/"); for (int i = 1; i < parts.length - 1; i++) { parentPath .append(parts[i]).append("/"); } return new Resource(parentPath.toString()); }
public boolean canFind(Resource resource) { InputStream stream = getResourceAsStream(resource.getPath()); if (stream == null) { return false; } try { stream.close(); } catch (IOException e) { // Ignore } return true; }
public InputStream createInputStream(Resource resource) throws IOException { InputStream inputStream = getResourceAsStream(resource.getPath()); if (inputStream == null) { throw new IOException(SimpleFormatter.format("Resource '[%s: %s]' not found", this, resource.getPath())); } return inputStream; }
public Resource getParent() { if (getPath().equals("/")) { return null; } StringBuilder parentPath = new StringBuilder(); parentPath.append("/"); for (int i = 1; i < parts.length - 1; i++) { parentPath .append(parts[i]).append("/"); } return new Resource(parentPath.toString()); }
public static Class<?> findFixtureClass(Resource hrefResource) throws ClassNotFoundException { String dottedHrefResource = hrefResource.getPath().replaceFirst("/", "").replace("/", "."); String name = dottedHrefResource.substring(0, dottedHrefResource.lastIndexOf(".")); String[] fixtureNames = {name, name + "Test", name + "Fixture"}; for (String fixtureName : fixtureNames) { Class<?> concordionClass = getFixtureClass(fixtureName); if (concordionClass != null) { return concordionClass; } } throw new ClassNotFoundException("Unable to find fixture class for '" + hrefResource + "'. " + "Fixture class must be named one of " + Arrays.toString(fixtureNames) + "."); }
private InputStream copySourceHtml(Resource resource, InputStream inputStream) throws IOException { Resource sourceHtmlResource = new Resource(resource.getPath() + ".html"); System.out.println(SimpleFormatter.format("[Source: %s]", copySourceHtmlTarget.resolvedPathFor(sourceHtmlResource))); String html = asString(inputStream); copySourceHtmlTarget.write(sourceHtmlResource, html); inputStream = new ByteArrayInputStream(html.getBytes("UTF-8")); return inputStream; } }
private InputStream copySourceHtml(Resource resource, InputStream inputStream) throws IOException { Resource sourceHtmlResource = new Resource(resource.getPath() + ".html"); System.out.println(SimpleFormatter.format("[Source: %s]", copySourceHtmlTarget.resolvedPathFor(sourceHtmlResource))); String html = asString(inputStream); copySourceHtmlTarget.write(sourceHtmlResource, html); inputStream = new ByteArrayInputStream(html.getBytes("UTF-8")); return inputStream; } }
public InputStream createInputStream(Resource resource) throws IOException { if (resource.getPath().startsWith(prefix)) { return new ByteArrayInputStream("x".getBytes("UTF-8")); } return source.createInputStream(resource); }
private OutputStream createOutputStream(Resource resource) throws FileNotFoundException { File file = getFile(resource); resourcesOutput.add(resource.getPath()); return new FileOutputStream(file); }
public void afterProcessingSpecification(SpecificationProcessingEvent event) { try { target.write(event.getResource(), XML_DECLARATION + event.getRootElement().toXML()); } catch (IOException e) { throw new RuntimeException("Failed to write results to '" + event.getResource().getPath() + "'.", e); } }
public void afterProcessingSpecification(SpecificationProcessingEvent event) { try { target.write(event.getResource(), XML_DECLARATION + event.getRootElement().toXML()); } catch (IOException e) { throw new RuntimeException("Failed to write results to '" + event.getResource().getPath() + "'.", e); } }
private Element createBreadcrumbElement(Resource documentResource, Resource indexPageResource, SpecificationConverter specificationConverter) throws IOException { String breadcrumbWording = getBreadcrumbWordingForResource(indexPageResource, specificationConverter); Element a = new Element("a"); Resource indexPageAsHtmlResource = new Resource(indexPageResource.getPath().replaceFirst("\\..*$", "\\.html")); a.addAttribute("href", documentResource.getRelativePath(indexPageAsHtmlResource)); a.appendText(breadcrumbWording); return a; }
private Element createBreadcrumbElement(Resource documentResource, Resource indexPageResource, SpecificationConverter specificationConverter) throws IOException { String breadcrumbWording = getBreadcrumbWordingForResource(indexPageResource, specificationConverter); Element a = new Element("a"); Resource indexPageAsHtmlResource = new Resource(indexPageResource.getPath().replaceFirst("\\..*$", "\\.html")); a.addAttribute("href", documentResource.getRelativePath(indexPageAsHtmlResource)); a.appendText(breadcrumbWording); return a; }
public void testCanAppendDotXHTMLWhenConstructedWithXHTMLArgument() throws Exception { SpecificationLocator locator = new ClassNameBasedSpecificationLocator(); assertEquals("/org/concordion/internal/ClassNameBasedSpecificationLocator.xhtml", locator.locateSpecification(new FixtureType(this.getClass()), "xhtml").getPath()); } }
public void testRemovesWordTestFromEndOfClassNameAndAppendsDotHTML() throws Exception { SpecificationLocator locator = new ClassNameBasedSpecificationLocator(); assertEquals("/org/concordion/internal/ClassNameBasedSpecificationLocator.html", locator.locateSpecification(new FixtureType(this.getClass()), "html").getPath()); }
public void testRemovesWordFixtureFromEndOfClassNameAndAppendsDotHTML() throws Exception { SpecificationLocator locator = new ClassNameBasedSpecificationLocator(); assertEquals("/spec/concordion/common/command/execute/ContinueAfterExceptions.html", locator.locateSpecification(new FixtureType(ContinueAfterExceptionsFixture.class), "html").getPath()); }