mirror of https://github.com/apache/ant-ivy
More Java 7 syntax in tests and other optimisations
This commit is contained in:
parent
3cf36b8cac
commit
973704dc1c
|
|
@ -170,7 +170,7 @@ public class IvyMakePomTest {
|
|||
// move to next sibling
|
||||
nextChild = nextChild.getNextSibling();
|
||||
}
|
||||
return new PomDependency(groupId, artifactId, version, scope, classifier, optional != null ? Boolean.parseBoolean(optional) : false);
|
||||
return new PomDependency(groupId, artifactId, version, scope, classifier, optional != null && Boolean.parseBoolean(optional));
|
||||
}
|
||||
|
||||
private static Node skipIfTextNode(final Node node) {
|
||||
|
|
@ -182,13 +182,8 @@ public class IvyMakePomTest {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PomDependency{" +
|
||||
"groupId='" + groupId + '\'' +
|
||||
", artifactId='" + artifactId + '\'' +
|
||||
", version='" + version + '\'' +
|
||||
", scope='" + scope + '\'' +
|
||||
", classifier='" + classifier + '\'' +
|
||||
'}';
|
||||
return String.format("PomDependency{groupId='%s', artifactId='%s', version='%s', scope='%s', classifier='%s'}",
|
||||
groupId, artifactId, version, scope, classifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,20 +62,14 @@ public class OBRXMLWriterTest {
|
|||
|
||||
new File("build/test-files").mkdirs();
|
||||
File obrFile = new File("build/test-files/obr-sources.xml");
|
||||
FileOutputStream out = new FileOutputStream(obrFile);
|
||||
try {
|
||||
try (FileOutputStream out = new FileOutputStream(obrFile)) {
|
||||
ContentHandler handler = OBRXMLWriter.newHandler(out, "UTF-8", true);
|
||||
OBRXMLWriter.writeBundles(bundles, handler);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
|
||||
FileInputStream in = new FileInputStream(obrFile);
|
||||
BundleRepoDescriptor repo;
|
||||
try {
|
||||
try (FileInputStream in = new FileInputStream(obrFile)) {
|
||||
repo = OBRXMLParser.parse(new URI("file:///test"), in);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
assertEquals(2, CollectionUtils.toList(repo.getModules()).size());
|
||||
|
||||
|
|
|
|||
|
|
@ -189,11 +189,7 @@ public class ArtifactLockStrategyTest {
|
|||
}
|
||||
} catch (ParseException e) {
|
||||
Message.info("parse exception " + e);
|
||||
} catch (RuntimeException e) {
|
||||
Message.info("exception " + e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} catch (Error e) {
|
||||
} catch (RuntimeException | Error e) {
|
||||
Message.info("exception " + e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
|
|
|
|||
|
|
@ -60,24 +60,29 @@ public class VfsURI {
|
|||
*/
|
||||
public static VfsURI vfsURIFactory(String scheme, String resource, Ivy ivy) {
|
||||
VfsURI vfsURI = null;
|
||||
if (scheme.equals(SCHEME_CIFS)) {
|
||||
vfsURI = new VfsURI(SCHEME_CIFS, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_SAMBA_REPO) + "/" + resource);
|
||||
} else if (scheme.equals(SCHEME_FILE)) {
|
||||
vfsURI = new VfsURI(SCHEME_FILE, null, null, null, VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
} else if (scheme.equals(SCHEME_FTP)) {
|
||||
vfsURI = new VfsURI(SCHEME_FTP, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST), VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
} else if (scheme.equals(SCHEME_SFTP)) {
|
||||
vfsURI = new VfsURI(SCHEME_SFTP, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST), VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
switch (scheme) {
|
||||
case SCHEME_CIFS:
|
||||
vfsURI = new VfsURI(SCHEME_CIFS, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_SAMBA_REPO) + "/" + resource);
|
||||
break;
|
||||
case SCHEME_FILE:
|
||||
vfsURI = new VfsURI(SCHEME_FILE, null, null, null, VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
break;
|
||||
case SCHEME_FTP:
|
||||
vfsURI = new VfsURI(SCHEME_FTP, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST), VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
break;
|
||||
case SCHEME_SFTP:
|
||||
vfsURI = new VfsURI(SCHEME_SFTP, ivy.getVariable(VfsTestHelper.PROP_VFS_USER_ID),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_USER_PASSWD),
|
||||
ivy.getVariable(VfsTestHelper.PROP_VFS_HOST), VfsTestHelper.CWD + "/"
|
||||
+ VfsTestHelper.TEST_REPO_DIR + "/" + resource);
|
||||
break;
|
||||
}
|
||||
return vfsURI;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue