use of com.cloudbees.jenkins.support.api.Content in project support-core-plugin by jenkinsci.
the class SupportTestUtils method invokeComponentToString.
/**
* Invoke a component, and return the component contents as a String.
*/
public static String invokeComponentToString(final Component component) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
component.addContents(new Container() {
@Override
public void add(@CheckForNull Content content) {
try {
content.writeTo(baos);
} catch (IOException e) {
e.printStackTrace();
}
}
});
return baos.toString();
}
use of com.cloudbees.jenkins.support.api.Content in project support-core-plugin by jenkinsci.
the class AgentsConfigFileTest method agentsConfigFile.
@Test
public void agentsConfigFile() throws Exception {
j.createSlave("node1", "node1", new EnvVars());
AgentsConfigFile comp = new AgentsConfigFile();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
comp.addContents(new Container() {
@Override
public void add(@CheckForNull Content content) {
try {
content.writeTo(baos);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
});
String fileContent = baos.toString();
Assert.assertTrue(fileContent.contains("<name>node1</name>"));
}
Aggregations