use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.
the class VsftpRepository method lslToResource.
/**
* Parses a ls -l line and transforms it in a resource
*
* @param file ditto
* @param responseLine ditto
* @return Resource
*/
protected Resource lslToResource(String file, String responseLine) {
if (responseLine == null || responseLine.startsWith("ls")) {
return new BasicResource(file, false, 0, 0, false);
} else {
String[] parts = responseLine.split("\\s+");
if (parts.length != LS_PARTS_NUMBER) {
Message.debug("unrecognized ls format: " + responseLine);
return new BasicResource(file, false, 0, 0, false);
} else {
try {
long contentLength = Long.parseLong(parts[LS_SIZE_INDEX]);
String date = parts[LS_DATE_INDEX1] + " " + parts[LS_DATE_INDEX2] + " " + parts[LS_DATE_INDEX3] + " " + parts[LS_DATE_INDEX4];
return new BasicResource(file, true, contentLength, FORMAT.parse(date).getTime(), false);
} catch (Exception ex) {
Message.warn("impossible to parse server response: " + responseLine, ex);
return new BasicResource(file, false, 0, 0, false);
}
}
}
}
use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithExtendsAndConfigurationsInheritance.
/**
* Test case for IVY-1437.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1437">IVY-1437</a>
*/
@Test
public void testMergedUpdateWithExtendsAndConfigurationsInheritance() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-configurations-inherit.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 2, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("configurations defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
assertTrue(updatedXml.contains("dependencies defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
}
use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithInclude.
/**
* Test case for IVY-1315.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1315">IVY-1315</a>
*/
@Test
public void testMergedUpdateWithInclude() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-update-excludedconfs6.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 6, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("dependencies defaultconf=\"conf1->default\""));
}
use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testUpdateWithExcludeConfigurations5.
@Test
public void testUpdateWithExcludeConfigurations5() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/" + "test-update-excludedconfs5.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer, getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] { "myconf2" }));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
DependencyDescriptor[] deps = updatedMd.getDependencies();
assertNotNull("Dependencies shouldn't be null", deps);
assertEquals("Number of dependencies is incorrect", 8, deps.length);
// check that none of the dependencies contains myconf2
for (DependencyDescriptor dep : deps) {
String name = dep.getDependencyId().getName();
assertFalse("Dependency " + name + " shouldn't have myconf2 as module configuration", Arrays.asList(dep.getModuleConfigurations()).contains("myconf2"));
assertEquals("Dependency " + name + " shouldn't have a dependency artifact for configuration myconf2", 0, dep.getDependencyArtifacts("myconf2").length);
}
}
use of org.apache.ivy.plugins.repository.BasicResource in project ant-ivy by apache.
the class XmlModuleUpdaterTest method testMergedUpdateWithExtendsAndExcludes.
/**
* Test case for IVY-1356.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1356">IVY-1356</a>
*/
@Test
public void testMergedUpdateWithExtendsAndExcludes() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-dependencies-exclude.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer, getUpdateOptions("release", "mynewrev").setMerge(true).setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(), new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0, false), true);
DependencyDescriptor[] deps = updatedMd.getDependencies();
assertNotNull("Dependencies shouldn't be null", deps);
assertEquals("Number of dependencies is incorrect", 2, deps.length);
// test indentation
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains(XmlModuleDescriptorUpdater.LINE_SEPARATOR + "\t\t<dependency org=\"myorg\" name=\"mymodule1\" rev=\"1.0\" conf=\"default->default\"/>" + XmlModuleDescriptorUpdater.LINE_SEPARATOR));
}
Aggregations