Package org.drools.guvnor.server.files

Examples of org.drools.guvnor.server.files.RestAPI.post()


                new Command() {
                    public void execute() throws Exception {
                        res.setContentType("text/html");
                        RestAPI api = getAPI();
                        String comment = req.getHeader("Checkin-Comment");
                        api.post(req.getRequestURI(),
                                req.getInputStream(),
                                (comment != null) ? comment : "");
                        res.getWriter().write("OK");
                    }
                });
View Full Code Here


        repo.save();

        RestAPI api = new RestAPI(repo);
        api.setAssetValidator(new AssetValidator());
        ByteArrayInputStream in = new ByteArrayInputStream("abc".getBytes());
        api.post("/packages/testRestPost/asset1.drl", in, "a comment");

        AssetItem a = pkg.loadAsset("asset1");
        assertFalse(a.isBinary());
        assertEquals("drl", a.getFormat());
        assertEquals("abc", a.getContent());
View Full Code Here

        assertEquals("abc", a.getContent());
        assertEquals("a comment", a.getCheckinComment());


        in = new ByteArrayInputStream("qed".getBytes());
        api.post("/packages/testRestPost/asset2.xls", in, "a comment");
        a = pkg.loadAsset("asset2");

        assertTrue(a.isBinary());
        String s = new String(a.getBinaryContentAsBytes());
        assertEquals("qed", s);
View Full Code Here

    @Test
    public void testPostNewPackage() throws Exception {
        RulesRepository repo = RepositorySessionUtil.getRepository();
        RestAPI api = new RestAPI(repo);
        api.setAssetValidator(new AssetValidator());
        api.post("/packages/testPostNewPackage/.package", new ByteArrayInputStream("qaz".getBytes()), "This is a new package");
        ModuleItem pkg = repo.loadModule("testPostNewPackage");
        assertEquals("qaz", pkg.getStringProperty(ModuleItem.HEADER_PROPERTY_NAME));

        assertEquals("This is a new package", pkg.getCheckinComment());
    }
View Full Code Here

        l = RulesRepositoryTest.iteratorToList(pkg.listArchivedAssets());
        assertEquals(1, l.size());


        //now test it back from the dead
        api.post("packages/testRestDelete/asset1.drl", new ByteArrayInputStream("123".getBytes()), "new comment");
        AssetItem ass = pkg.loadAsset("asset1");
        assertEquals("123", ass.getContent());
        assertEquals("new comment", ass.getCheckinComment());
        assertFalse(ass.isArchived());
        l = RulesRepositoryTest.iteratorToList(pkg.listAssetsByFormat(new String[] {"drl"}));
View Full Code Here

        assertFalse(ass.isArchived());
        l = RulesRepositoryTest.iteratorToList(pkg.listAssetsByFormat(new String[] {"drl"}));
        assertEquals(1, l.size());

        try {
            api.post("packages/testRestDelete/asset1.drl", new ByteArrayInputStream("123".getBytes())"new comment");
            fail("this should be rejected as its not archived.");
        } catch (RulesRepositoryException e) {
            assertNotNull(e.getMessage());
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.