Package com.dtolabs.rundeck.core.common

Examples of com.dtolabs.rundeck.core.common.NodesYamlGenerator



    public void testShouldSupportOutputStream() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("test1");
        nodeEntry.setHostname("testhostname");
        nodesYamlGenerator.addNode(nodeEntry);
        nodesYamlGenerator.generate();
        final byte[] bytes = baos.toByteArray();
        assertNotNull(bytes);
        assertTrue(bytes.length > 0);
    }
View Full Code Here


        assertTrue(bytes.length > 0);
    }
    public void testShouldSupportWriter() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(new OutputStreamWriter(baos));
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("test1");
        nodeEntry.setHostname("testhostname");
        nodesYamlGenerator.addNode(nodeEntry);
        nodesYamlGenerator.generate();
        final byte[] bytes = baos.toByteArray();
        assertNotNull(bytes);
        assertTrue(bytes.length > 0);
    }
View Full Code Here

    public void testShouldSupportFile() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        File tempfile = File.createTempFile("out", "temp");
        tempfile.deleteOnExit();

        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(tempfile);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("test1");
        nodeEntry.setHostname("testhostname");
        nodesYamlGenerator.addNode(nodeEntry);
        nodesYamlGenerator.generate();
        assertTrue(tempfile.length() > 0);
    }
View Full Code Here

        nodesYamlGenerator.addNode(nodeEntry);
        nodesYamlGenerator.generate();
        assertTrue(tempfile.length() > 0);
    }
    public void testGenerateShouldFailOnNullOutput() throws Exception{
        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator((File)null);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("test1");
        nodeEntry.setHostname("testhostname");
        nodesYamlGenerator.addNode(nodeEntry);
        try {
            nodesYamlGenerator.generate();
            fail("Should have failed");
        } catch (NullPointerException e) {
            assertNotNull(e);
        }
    }
View Full Code Here

    }
    public void testGenerate() throws Exception {
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);

            try {
                nodesYamlGenerator.generate();
                fail("Should have thrown an Exception");
            }
            catch (NodesGeneratorException ex) {
            }
        }
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
            final NodeEntryImpl nodeEntry = new NodeEntryImpl();
            nodeEntry.setNodename("test1");
            nodeEntry.setHostname("testhostname");
            nodesYamlGenerator.addNode(nodeEntry);

            nodesYamlGenerator.generate();
            final String outputString = baos.toString();
            assertNotNull(outputString);
            //convert via yaml
            Map parsed = parseYamlMap(outputString);
            assertNotNull(parsed.get("test1"));
            assertTrue(parsed.get("test1") instanceof Map);
            Map node1 = (Map) parsed.get("test1");
            assertEquals("testhostname", node1.get("hostname"));
            assertEquals("test1", node1.get("nodename"));
            assertEquals("", node1.get("tags"));
        }
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
            final NodeEntryImpl nodeEntry = new NodeEntryImpl();
            nodeEntry.setNodename("test1");
            nodeEntry.setHostname("testhostname");
            nodeEntry.setDescription("test description");
            nodeEntry.setOsArch("an os arch");
            nodeEntry.setOsFamily("an os fam");
            nodeEntry.setOsName("an os name");
            nodeEntry.setOsVersion("an os vers");
            nodeEntry.setUsername("someUser");
            nodeEntry.setTags(new HashSet());

            nodesYamlGenerator.addNode(nodeEntry);

            nodesYamlGenerator.generate();
            final String outputString = baos.toString();
            assertNotNull(outputString);
            //convert via yaml
            Map parsed = parseYamlMap(outputString);
            assertNotNull(parsed.get("test1"));
            assertTrue(parsed.get("test1") instanceof Map);
            Map node1 = (Map) parsed.get("test1");
            assertEquals("test description", node1.get("description"));
            assertEquals("testhostname", node1.get("hostname"));
            assertEquals("test1", node1.get("nodename"));
            assertEquals("an os arch", node1.get("osArch"));
            assertEquals("an os fam", node1.get("osFamily"));
            assertEquals("an os name", node1.get("osName"));
            assertEquals("an os vers", node1.get("osVersion"));
            assertEquals("someUser", node1.get("username"));
            assertEquals("", node1.get("tags"));
        }
        {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
            final NodeEntryImpl nodeEntry = new NodeEntryImpl();
            nodeEntry.setNodename("strongbad");
            nodeEntry.setHostname("strongbad");
            nodeEntry.setDescription("Rundeck server node");
            nodeEntry.setOsArch("x86_64");
            nodeEntry.setOsFamily("unix");
            nodeEntry.setOsName("Mac OS X");
            nodeEntry.setOsVersion("10.6.5");
            nodeEntry.setUsername("alexh");
            nodeEntry.setFrameworkProject("ignored");
            final HashSet tags = new HashSet();
            tags.add("rundeck");
            tags.add("dev");
            tags.add("ops");
            nodeEntry.setTags(tags);
            /**
             * strongbad:

             type: Node
             description: "Rundeck server node"
             hostname: "strongbad"
             osArch: "x86_64"
             osFamily: "unix"
             osName: "Mac OS X"
             osVersion: "10.6.5"
             username: "alexh"
             editUrl: ""
             remoteUrl: ""
             tags: "rundeck"
             */

            nodesYamlGenerator.addNode(nodeEntry);

            nodesYamlGenerator.generate();
            final String outputString = baos.toString();
            assertNotNull(outputString);
            //convert via yaml
            Map parsed = parseYamlMap(outputString);
            assertNotNull(parsed.get("strongbad"));
View Full Code Here

        return (Map) load;
    }

    public void testShouldOutputEditUrl() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("strongbad");
        nodeEntry.setHostname("strongbad");
        nodeEntry.getAttributes().put("editUrl","http://some.com/test/url");

        nodesYamlGenerator.addNode(nodeEntry);

        nodesYamlGenerator.generate();
        final String outputString = baos.toString();
        assertNotNull(outputString);

        //convert via yaml
        Map parsed = parseYamlMap(outputString);
View Full Code Here

    }
   
    public void testShouldOutputRemoteUrl() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("strongbad");
        nodeEntry.setHostname("strongbad");

        nodeEntry.getAttributes().put("remoteUrl", "http://somez.com/test/other/url");

        nodesYamlGenerator.addNode(nodeEntry);

        nodesYamlGenerator.generate();
        final String outputString = baos.toString();
        assertNotNull(outputString);
        //convert via yaml
        Map parsed = parseYamlMap(outputString);
        assertNotNull(parsed.get("strongbad"));
View Full Code Here

        assertEquals("", node1.get("tags"));
    }

    public void testShouldOutputAnyAttribtue() throws Exception{
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(baos);
        final NodeEntryImpl nodeEntry = new NodeEntryImpl();
        nodeEntry.setNodename("strongbad");
        nodeEntry.setHostname("strongbad");
       
        nodeEntry.getAttributes().put("test-attribute", "some value");

        nodesYamlGenerator.addNode(nodeEntry);

        nodesYamlGenerator.generate();
        final String outputString = baos.toString();
        assertNotNull(outputString);
        //convert via yaml
        Map parsed = parseYamlMap(outputString);
        assertNotNull(parsed.get("strongbad"));
View Full Code Here

    }

    public void generateDocument(final INodeSet nodeset, final OutputStream stream) throws
        ResourceFormatGeneratorException,
        IOException {
        final NodesYamlGenerator nodesYamlGenerator = new NodesYamlGenerator(stream);
        nodesYamlGenerator.addNodes(nodeset.getNodes());
        try {
            nodesYamlGenerator.generate();
        } catch (NodesGeneratorException e) {
            throw new ResourceFormatGeneratorException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.common.NodesYamlGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.