use of com.jayway.jsonpath.DocumentContext in project pom-manipulation-ext by release-engineering.
the class JSONIOTest method writeFile.
@Test
public void writeFile() throws ManipulationException, IOException {
DocumentContext doc = jsonIO.parseJSON(npmFile);
File target = tf.newFile();
jsonIO.writeJSON(target, doc.jsonString());
assertTrue(FileUtils.contentEquals(npmFile, target));
}
use of com.jayway.jsonpath.DocumentContext in project pom-manipulation-ext by release-engineering.
the class JSONIOTest method readFile.
@Test
public void readFile() throws ManipulationException, IOException {
DocumentContext o = jsonIO.parseJSON(npmFile);
logger.debug("Read {} ", o.jsonString());
logger.debug("File {}", FileUtils.readFileToString(npmFile));
// They won't be equal as jsonString is not pretty printed.
assertNotEquals(o.jsonString(), FileUtils.readFileToString(npmFile));
assertTrue(o != null);
}
use of com.jayway.jsonpath.DocumentContext in project pom-manipulation-ext by release-engineering.
the class JSONIOTest method updateURL.
@Test
public void updateURL() throws ManipulationException, IOException {
String modifyPath = "$.repository.url";
DocumentContext doc = jsonIO.parseJSON(pluginFile);
doc.set(modifyPath, "https://maven.repository.redhat.com/ga/");
logger.debug("Modified {} ", doc.jsonString());
File target = tf.newFile();
jsonIO.writeJSON(target, doc.jsonString());
assertTrue(doc.jsonString().contains("https://maven.repository.redhat.com/ga/"));
assertTrue(doc.jsonString().contains("1.2.2-SNAPSHOT"));
assertFalse(FileUtils.contentEquals(pluginFile, target));
}
use of com.jayway.jsonpath.DocumentContext in project pom-manipulation-ext by release-engineering.
the class JSONIOTest method updateVersions.
@Test
public void updateVersions() throws ManipulationException, IOException {
String modifyPath = "$..version";
DocumentContext doc = jsonIO.parseJSON(pluginFile);
doc.set(modifyPath, "1.3.0.rebuild-1");
logger.debug("Modified {} ", doc.jsonString());
File target = tf.newFile();
jsonIO.writeJSON(target, doc.jsonString());
assertTrue(!doc.jsonString().contains("1.2.2-SNAPSHOT"));
assertTrue(doc.jsonString().contains("1.3.0.rebuild-1"));
assertFalse(FileUtils.contentEquals(pluginFile, target));
}
use of com.jayway.jsonpath.DocumentContext in project pom-manipulation-ext by release-engineering.
the class JSONIOTest method updateWithInvalidPath.
@Test(expected = ManipulationException.class)
public void updateWithInvalidPath() throws ManipulationException, IOException {
String modifyPath = "$.I.really.do.not.exist.repository.url";
try {
DocumentContext doc = jsonIO.parseJSON(pluginFile);
doc.set(modifyPath, "https://maven.repository.redhat.com/ga/");
} catch (JsonPathException e) {
throw new ManipulationException("Caught JsonPath", e);
}
}
Aggregations