Package com.dtolabs.rundeck.core.common

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


        test1.responseHeaders.put("Content-Type", new Header("Content-Type", "text/yaml"));
        String yamlcontent = YAML_NODES_TEST;
        ByteArrayInputStream stringStream = new ByteArrayInputStream(yamlcontent.getBytes());
        test1.bodyStream=stringStream;
        provider.interaction= test1;
        final INodeSet nodes = provider.getNodes();
        assertNotNull(nodes);
        assertEquals(1, nodes.getNodes().size());
        assertNotNull(nodes.getNode("testnode1"));

        assertNotNull(test1.method);
        assertNotNull(test1.client);
        assertNotNull(test1.followRedirects);
        assertNotNull(test1.releaseConnectionCalled);
View Full Code Here


        test1.httpStatusText="OK";
        test1.responseHeaders.put("Content-Type", new Header("Content-Type", "text/xml"));
        ByteArrayInputStream stringStream = new ByteArrayInputStream(XML_NODES_TEXT.getBytes());
        test1.bodyStream=stringStream;
        provider.interaction= test1;
        final INodeSet nodes = provider.getNodes();
        assertNotNull(nodes);
        assertEquals(1, nodes.getNodes().size());
        assertNotNull(nodes.getNode("testnode1"));

        assertNotNull(test1.method);
        assertNotNull(test1.client);
        assertNotNull(test1.followRedirects);
        assertNotNull(test1.releaseConnectionCalled);
View Full Code Here

        final ByteArrayInputStream stringStream = new ByteArrayInputStream(YAML_NODES_TEST.getBytes());
        test1.bodyStream=stringStream;
        provider.interaction= test1;

        final INodeSet nodes = provider.getNodes();
        assertNotNull(nodes);
        assertEquals(1, nodes.getNodes().size());
        assertNotNull(nodes.getNode("testnode1"));

        assertNotNull(test1.method);
        assertNotNull(test1.client);
        assertNotNull(test1.followRedirects);
        assertNotNull(test1.releaseConnectionCalled);

        //make another request. assert etag, If-modified-since are used.


        final test1 test2 = new test1();
        test2.httpResultCode = 304;
        test2.httpStatusText = "Not Modified";
        //include etag, last-modified
        test2.responseHeaders.put("ETag", new Header("ETag", "monkey1"));
        test2.responseHeaders.put("Last-Modified", new Header("Last-Modified", "blahblee"));

        test2.bodyStream = null;
        provider.interaction = test2;

        final INodeSet nodes2 = provider.getNodes();
        assertNotNull(nodes2);
        assertEquals(1, nodes2.getNodes().size());
        assertNotNull(nodes2.getNode("testnode1"));

        assertNotNull(test2.method);
        assertNotNull(test2.client);
        assertNotNull(test2.followRedirects);
        assertNotNull(test2.releaseConnectionCalled);
View Full Code Here

        build.project(PROJ_NAME);
        build.url(new File("src/test/resources/com/dtolabs/rundeck/core/common/test-nodes1.xml").toURI().toURL().toExternalForm());

        provider.configure(build.getProperties());

        final INodeSet nodes = provider.getNodes();
        assertNotNull(nodes);
        assertEquals(2, nodes.getNodes().size());
        assertNotNull(nodes.getNode("test1"));
        assertNotNull(nodes.getNode("testnode2"));

        //write yaml to temp file
        File tempyaml = File.createTempFile("nodes", ".yaml");
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempyaml)));
        writer.write(YAML_NODES_TEST);
        writer.flush();
        writer.close();
        tempyaml.deleteOnExit();

        URLResourceModelSource provider2 = new URLResourceModelSource(getFrameworkInstance());
        final URLResourceModelSource.Configuration build2 = URLResourceModelSource.Configuration.build();

        build2.project(PROJ_NAME);
        build2.url(tempyaml.toURI().toURL().toExternalForm());

        provider2.configure(build2.getProperties());

        final INodeSet nodes2 = provider2.getNodes();
        assertNotNull(nodes2);
        assertEquals(1, nodes2.getNodes().size());
        assertNotNull(nodes2.getNode("testnode1"));

    }
View Full Code Here

        props.setProperty("generateFileAutomatically", "false");
        props.setProperty("includeServerNode", "false");
        final FileResourceModelSource fileNodesProvider = new FileResourceModelSource(getFrameworkInstance());
        fileNodesProvider.configure(props);

        final INodeSet nodes = fileNodesProvider.getNodes();
        assertNotNull(nodes);
        assertEquals(2, nodes.getNodes().size());
        assertNotNull(nodes.getNode("test1"));
        assertNotNull(nodes.getNode("testnode2"));

    }
View Full Code Here

        props.setProperty("generateFileAutomatically", "false");
        props.setProperty("includeServerNode", "false");
        final FileResourceModelSource fileNodesProvider = new FileResourceModelSource(getFrameworkInstance());
        fileNodesProvider.configure(props);

        final INodeSet nodes = fileNodesProvider.getNodes();
        assertNotNull(nodes);
        assertEquals(1, nodes.getNodes().size());
        assertNotNull(nodes.getNode("testyaml1"));
        testfile.delete();
    }
View Full Code Here

        props.setProperty("generateFileAutomatically", "false");
        props.setProperty("includeServerNode", "true");
        final FileResourceModelSource fileNodesProvider = new FileResourceModelSource(getFrameworkInstance());
        fileNodesProvider.configure(props);

        final INodeSet nodes = fileNodesProvider.getNodes();
        assertNotNull(nodes);
        assertEquals(1, nodes.getNodes().size());
        assertNotNull(nodes.getNode(getFrameworkInstance().getFrameworkNodeName()));
        assertFalse(testfile.exists());
    }
View Full Code Here

            props.setProperty("generateFileAutomatically", "true");
            props.setProperty("includeServerNode", "true");
            final FileResourceModelSource fileNodesProvider = new FileResourceModelSource(getFrameworkInstance());
            fileNodesProvider.configure(props);

            final INodeSet nodes = fileNodesProvider.getNodes();
            assertNotNull(nodes);
            assertEquals(1, nodes.getNodes().size());
            assertNotNull(nodes.getNode(getFrameworkInstance().getFrameworkNodeName()));
            assertTrue(testfile.exists());
            testfile.delete();
        }

        //explicit format resourcexml
        {
            File testfile2 = new File(frameworkProject.getEtcDir(), "testresources2.blah");
            assertFalse(testfile2.exists());

            Properties props2 = new Properties();

            props2.setProperty("format", "resourcexml");

            props2.setProperty("project", PROJ_NAME);
            props2.setProperty("file", testfile2.getAbsolutePath());
            props2.setProperty("generateFileAutomatically", "true");
            props2.setProperty("includeServerNode", "true");
            final FileResourceModelSource provider2 = new FileResourceModelSource(getFrameworkInstance());
            provider2.configure(props2);

            final INodeSet nodes2 = provider2.getNodes();
            assertNotNull(nodes2);
            assertEquals(1, nodes2.getNodes().size());
            assertNotNull(nodes2.getNode(getFrameworkInstance().getFrameworkNodeName()));
            assertTrue(testfile2.exists());
            testfile2.delete();
        }

        //implicit from filename
        {
            File testfile2 = new File(frameworkProject.getEtcDir(), "testresources2.yaml");
            assertFalse(testfile2.exists());

            Properties props2 = new Properties();
            props2.setProperty("project", PROJ_NAME);
            props2.setProperty("file", testfile2.getAbsolutePath());
            props2.setProperty("generateFileAutomatically", "true");
            props2.setProperty("includeServerNode", "true");
            final FileResourceModelSource provider2 = new FileResourceModelSource(getFrameworkInstance());
            provider2.configure(props2);

            final INodeSet nodes2 = provider2.getNodes();
            assertNotNull(nodes2);
            assertEquals(1, nodes2.getNodes().size());
            assertNotNull(nodes2.getNode(getFrameworkInstance().getFrameworkNodeName()));
            assertTrue(testfile2.exists());
        }
        //implicit from filename
        {
            File testfile2 = new File(frameworkProject.getEtcDir(), "testresources2.xml");
            assertFalse(testfile2.exists());

            Properties props2 = new Properties();
            props2.setProperty("project", PROJ_NAME);
            props2.setProperty("file", testfile2.getAbsolutePath());
            props2.setProperty("generateFileAutomatically", "true");
            props2.setProperty("includeServerNode", "true");
            final FileResourceModelSource provider2 = new FileResourceModelSource(getFrameworkInstance());
            provider2.configure(props2);

            final INodeSet nodes2 = provider2.getNodes();
            assertNotNull(nodes2);
            assertEquals(1, nodes2.getNodes().size());
            assertNotNull(nodes2.getNode(getFrameworkInstance().getFrameworkNodeName()));
            assertTrue(testfile2.exists());
        }
    }
View Full Code Here

        }
    }

    public void testParseFile() throws Exception {
        File testfile= new File("src/test/resources/com/dtolabs/rundeck/core/common/test-nodes1.xml");
        final INodeSet iNodeSet = FileResourceModelSource.parseFile(testfile, getFrameworkInstance(), PROJ_NAME);
        assertNotNull(iNodeSet);
        assertEquals(2, iNodeSet.getNodes().size());
        assertNotNull(iNodeSet.getNode("test1"));
        assertNotNull(iNodeSet.getNode("testnode2"));

        File testfile2 = File.createTempFile("testParseFile", ".yaml");
        //create yaml file
        final BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
            (testfile2))));
        bufferedWriter.write("testyaml1: \n"
                             + "  hostname: test\n"
                             + "  description: a description\n"
                             + "  tags: a, b, c\n"
                             + "  osArch: x86_64\n"
                             + "  osFamily: unix\n"
                             + "  osVersion: 10.6.5\n"
                             + "  osName: Mac OS X\n"
                             + "  username: a user\n");
        bufferedWriter.flush();
        bufferedWriter.close();
        assertTrue(testfile2.exists());

        final INodeSet nodeSet2 = FileResourceModelSource.parseFile(testfile2, getFrameworkInstance(), PROJ_NAME);
        assertNotNull(nodeSet2);
        assertEquals(1, nodeSet2.getNodes().size());
        assertNotNull(nodeSet2.getNode("testyaml1"));

        //test failures
        File dneFile = new File("build/DNEFile.xml");

        try {
            final INodeSet result = FileResourceModelSource.parseFile(dneFile, getFrameworkInstance(), PROJ_NAME);
            fail();
        } catch (ResourceModelSourceException e) {
            assertEquals("File does not exist: " + dneFile.getAbsolutePath(), e.getMessage());
        }
    }
View Full Code Here

    public void testExecuteWorkflow() throws Exception {
        {
            final FrameworkProject frameworkProject = testFramework.getFrameworkProjectMgr().getFrameworkProject(
                TEST_PROJECT);
            final INodeSet nodes = frameworkProject.getNodeSet();
            assertNotNull(nodes);
            assertEquals(2, nodes.getNodes().size());

        }

        {
            //test empty workflow
View Full Code Here

TOP

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

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.