Search in sources :

Example 11 with Content

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();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    comp.addContents(new Container() {

        @Override
        public void add(@CheckForNull Content content) {
            try {
                content.writeTo(baos);
            } catch (IOException e) {
                fail(e.getMessage());
            }
        }
    });
    String fileContent = baos.toString();
    assertTrue(fileContent.contains("<name>node1</name>"));
}
Also used : Container(com.cloudbees.jenkins.support.api.Container) EnvVars(hudson.EnvVars) Content(com.cloudbees.jenkins.support.api.Content) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Content (com.cloudbees.jenkins.support.api.Content)11 Container (com.cloudbees.jenkins.support.api.Container)8 IOException (java.io.IOException)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PrefilteredContent (com.cloudbees.jenkins.support.filter.PrefilteredContent)4 Test (org.junit.Test)4 StringContent (com.cloudbees.jenkins.support.api.StringContent)3 Component (com.cloudbees.jenkins.support.api.Component)2 BufferedOutputStream (java.io.BufferedOutputStream)2 File (java.io.File)2 OutputStream (java.io.OutputStream)2 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2 TreeMap (java.util.TreeMap)2 TimeoutException (java.util.concurrent.TimeoutException)2 SupportProvider (com.cloudbees.jenkins.support.api.SupportProvider)1 UnfilteredStringContent (com.cloudbees.jenkins.support.api.UnfilteredStringContent)1 ContentFilter (com.cloudbees.jenkins.support.filter.ContentFilter)1 FilteredOutputStream (com.cloudbees.jenkins.support.filter.FilteredOutputStream)1 AboutJenkins (com.cloudbees.jenkins.support.impl.AboutJenkins)1