Revision 46112 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/AbstractTestUtils.java
AbstractTestUtils.java | ||
---|---|---|
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
public File getTargetFolder() throws Exception { |
50 |
URL url = AbstractTestUtils.class.getResource("/"); |
|
50 |
URL url = this.getClass().getResource("/"); |
|
51 |
if (url == null) { |
|
52 |
url = AbstractTestUtils.class.getResource("/"); |
|
53 |
} |
|
51 | 54 |
File x = new File(url.toURI()); |
52 | 55 |
File target = x.getParentFile(); |
53 | 56 |
return target; |
... | ... | |
59 | 62 |
} |
60 | 63 |
|
61 | 64 |
public File getResourceAsFile(String pathname) throws Exception { |
62 |
URL url = AbstractTestUtils.class.getResource(pathname); |
|
65 |
URL url = this.getClass().getResource(pathname); |
|
66 |
if (url == null) { |
|
67 |
url = AbstractTestUtils.class.getResource(pathname); |
|
68 |
} |
|
63 | 69 |
if( StringUtils.equalsIgnoreCase(url.getProtocol(),"file") ) { |
64 | 70 |
File x = new File(url.toURI()); |
65 | 71 |
return x; |
... | ... | |
440 | 446 |
} |
441 | 447 |
} |
442 | 448 |
|
449 |
public List<String> getExpectedSQLs(String name) throws Exception { |
|
450 |
File f = getResourceAsFile(getExpectedsPath() + "/" + name); |
|
451 |
List<String> SQLs = new ArrayList<>(); |
|
452 |
List<String> lines = FileUtils.readLines(f); |
|
453 |
StringBuilder sb = new StringBuilder(); |
|
454 |
for (String line : lines) { |
|
455 |
line = StringUtils.stripStart(line, null); |
|
456 |
if (line.startsWith("--")) { |
|
457 |
continue; |
|
458 |
} |
|
459 |
if (line.endsWith(";")) { |
|
460 |
sb.append(line.substring(0, line.length() - 1)); |
|
461 |
SQLs.add(sb.toString()); |
|
462 |
sb.setLength(0); |
|
463 |
} else { |
|
464 |
sb.append(line); |
|
465 |
} |
|
466 |
} |
|
467 |
return SQLs; |
|
468 |
} |
|
469 |
|
|
470 |
|
|
443 | 471 |
// public abstract String getExpectedResourcesPrefix(); // Ex. "h2spatial" |
444 | 472 |
|
445 | 473 |
public abstract String getExpectedsPath(); |
Also available in: Unified diff