public FileSystemRepository(String... args) { if (args.length != 1) { throw new IllegalArgumentException("root"); } this.root = new File(URIUtil.decoded(args[0])); }
/** * @see SpecificationRunnerExecutor#outputFile(File) */ private String determineDestination(String source) { String destination; if (specificationRunner instanceof SuiteRunner) { // A suite does not have any specific output file. The output files // are generated by the child document runners in the output // directory. destination = ""; } else if (outputFile == null) { // No output file given: // LivingDoc's old // info.novatec.testit.livingdoc.runner.CommandLineRunner has // only flatten the filename // if a specific repository was set. But in our case it's okay if we // place the reports // always into one single directory with no sub directories. destination = flatten(source); } else { // Single file destination destination = outputFile.getName(); } return destination; }
public AtlassianRepository(String... args) { this.root = URI.create(URIUtil.raw(args[0])); String includeAtt = URIUtil.getAttribute(root, "includeStyle"); includeStyle = includeAtt == null ? true : Boolean.valueOf(includeAtt); if (args.length == 3) { username = args[1]; password = args[2]; } }
public static String flatten(String uri) { URI normalized = URI.create(raw(uri)).normalize(); String path = normalized.getPath(); path = stripLeadingSlash(path); path = path.replaceAll("/", "-"); return path; }
@Test public void testOperationsCanBeCombined() { String filePath = joinAsString(toArray("c:", "path", "to", "dir", "sub dir", "my file.html"), File.separator); String dirPath = joinAsString(toArray("c:", "path", "to"), File.separator); assertEquals("dir-sub dir-my file.html", flatten(relativize(dirPath, filePath))); }
private String outputNameOf(Report report) { String name = report.getName(); StringBuilder nameBuilder = new StringBuilder(name); if (automaticExtension && ! name.endsWith(extensionOf(report))) { nameBuilder.append(extensionOf(report)); } return URIUtil.escapeFileSystemForbiddenCharacters(nameBuilder.toString()); }
private List<Object> args(URI location) { String[] locationArgs = location.getPath().split("/"); List<Object> args = new ArrayList<Object>(); args.add(root.getFragment()); Collections.addAll(args, locationArgs); args.add(includeStyle); String implemented = URIUtil.getAttribute(location, "implemented"); args.add(implemented == null ? Boolean.valueOf(true) : Boolean.valueOf(implemented)); return args; } }
private List<Object> toHierarchyNodeList(File file) { List<Object> myList = new ArrayList(); myList.add(0, URIUtil.relativize(root.getAbsolutePath(), file.getAbsolutePath())); myList.add(1, ! file.isDirectory()); myList.add(2, false); Hashtable<String, Object> hashtable = new Hashtable<String, Object>(); if (file.isDirectory() && file.listFiles() != null) { for (File node : file.listFiles(NOT_HIDDEN)) { hashtable.put(node.getName(), toHierarchyNodeList(node)); } } myList.add(3, hashtable); return myList; } }
public LivingDocRepository(String... args) throws IllegalArgumentException { if (args.length == 0) { throw new IllegalArgumentException("No root specified"); } this.root = URI.create(URIUtil.raw(args[0])); String includeAtt = URIUtil.getAttribute(root, "includeStyle"); includeStyle = includeAtt == null || Boolean.valueOf(includeAtt); String implementedAtt = URIUtil.getAttribute(root, "implemented"); if (implementedAtt != null) { implemented = Boolean.parseBoolean(implementedAtt); } handler = URIUtil.getAttribute(root, "handler"); if (handler == null) { throw new IllegalArgumentException("No handler specified"); } sut = URIUtil.getAttribute(root, "sut"); if (sut == null) { throw new IllegalArgumentException("No sut specified"); } String postExecutionResultAtt = URIUtil.getAttribute(root, "postExecutionResult"); if (postExecutionResultAtt != null) { postExecutionResult = Boolean.parseBoolean(postExecutionResultAtt); } if (args.length == 3) { username = args[1]; password = args[2]; } }
@Test public void testEscapeFileSystemForbiddenCharacters_InferiorSign() { assertEquals("%3Cinf%3C", URIUtil.escapeFileSystemForbiddenCharacters("<inf<")); } }
@Test public void testWeCanRetrieveTheAttributesFromAnUri() { URI myUri = URI.create("http://domain:port/context/path?att1=attribute1&att2=attribute2&att3=attribute3"); assertEquals("attribute1", URIUtil.getAttribute(myUri, "att1")); assertEquals("attribute2", URIUtil.getAttribute(myUri, "att2")); assertEquals("attribute3", URIUtil.getAttribute(myUri, "att3")); }
@Test public void testCanComputeRelativePathFromBase() { assertEquals("subdir/file", relativize("c:/path/to/dir", "c:/path/to/dir/subdir/file")); }
private String getPath(String uri) { return URI.create(URIUtil.raw(uri)).getPath(); }
private String getOutput() { return decoded(cli.getArgument(1)); }
@Override public void run(String source, String destination) { List<String> names = listDocumentsAt(source); if (names.isEmpty()) { monitor.testRunning(source); monitor.testDone(0, 0, 0, 0); return; } for (String name : names) { runner.run(name, flatten(name)); } }
@Test public void testEscapeFileSystemForbiddenCharacters_DoubleQuote() { assertEquals("%22quote%22", URIUtil.escapeFileSystemForbiddenCharacters("\"quote\"")); }
private String withNoStyle(String location) { URI uri = URI.create(URIUtil.raw(location)); StringBuilder sb = new StringBuilder(22); if (uri.getScheme() != null) { sb.append(uri.getScheme()).append("://"); } if (uri.getAuthority() != null) { sb.append(uri.getAuthority()); } if (uri.getPath() != null) { sb.append(uri.getPath()); } String query = uri.getQuery(); if (query == null) { sb.append("??includeStyle=false"); } else { sb.append('?').append(query).append("&includeStyle=false"); } if (uri.getFragment() != null) { sb.append('#').append(uri.getFragment()); } return sb.toString(); }
private String getInput() { return decoded(cli.getArgument(0)); }