Package org.drools.guvnor.server.files

Examples of org.drools.guvnor.server.files.Response


                        String qString = req.getQueryString();
                        String ur = req.getRequestURI();
                        if (qString != null && qString.length() > 0) {
                            ur = ur + '?' + qString;
                        }
                        Response apiRes = api.get(ur);
                        res.setContentType("application/x-download");
                        res.setHeader("Content-Disposition",
                                "attachment; filename=data;");
                        apiRes.writeData(res.getOutputStream());
                        res.getOutputStream().flush();
                    }
                });

    }
View Full Code Here


        ass.checkin("hey");

        RestAPI api = new RestAPI(repo);
       api.setAssetValidator(new AssetValidator());
        String url = "packages/testRestGetSpaces";
        Response res = api.get(url);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        res.writeData(out);

        assertTrue(new String(out.toByteArray()).indexOf("\\ ") > -1);

        url = "packages/testRestGetSpaces/some space.drl";
        res = api.get(url);
View Full Code Here

        api.setAssetValidator(new AssetValidator());

        //this should get us the package configuration

        String url = "packages/testRestGetBasics/.package";
        Response res = api.get(url);
        assertNotNull(res.lastModified);
        assertEquals(pkg.getLastModified(), res.lastModified);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        res.writeData(out);

        String dotPackage = new String(out.toByteArray());
        assertEquals(pkg.getStringProperty(ModuleItem.HEADER_PROPERTY_NAME), dotPackage);

        res = api.get("packages/testRestGetBasics");
        assertTrue(res instanceof Text);
        assertNotNull(res.lastModified);
        out = new ByteArrayOutputStream();
        res.writeData(out);
        String listing = new String(out.toByteArray());
        assertNotNull(listing);

        Properties p = new Properties();
        p.load(new ByteArrayInputStream(out.toByteArray()));
        assertEquals(3, p.size());

        assertTrue(p.containsKey("asset1.drl"));
        assertTrue(p.containsKey("asset2.xml"));
        assertTrue(p.containsKey("asset3.xls"));

        assertNotNull(p.getProperty("asset1.drl"));
        String prop = p.getProperty("asset1.drl");
        System.err.println(prop);
        String[] dt = prop.split(",");


        SimpleDateFormat sdf = RestAPI.getISODateFormat();
        Date d= sdf.parse(dt[0]);
        assertNotNull(d);

        assertEquals(sdf.format(asset1.getLastModified().getTime()), dt[0]);
        assertEquals(asset1.getVersionNumber(), Long.parseLong(dt[1]));


        //try text
        res = api.get("packages/testRestGetBasics/asset1.drl");
        assertTrue(res instanceof Text);
        out = new ByteArrayOutputStream();
        assertNotNull(res.lastModified);
        assertTrue(res.lastModified.getTime().after(sdf.parse("2000-04-14T18:36:37")));
        res.writeData(out);

        String s = new String(out.toByteArray());
        assertEquals(asset1.getContent(), s);


        //now binary
        res = api.get("packages/testRestGetBasics/asset3.xls");
        assertTrue(res instanceof Binary);
        out = new ByteArrayOutputStream();
        assertNotNull(res.lastModified);
        assertTrue(res.lastModified.getTime().after(sdf.parse("2000-04-14T18:36:37")));
        res.writeData(out);

        byte[] data = out.toByteArray();
        assertNotNull(data);

        assertEquals("abc", new String(data));
View Full Code Here

        assertEquals(1, asset1.getVersionNumber());

        RestAPI api = new RestAPI(repo);
        api.setAssetValidator(new AssetValidator());
        Response res = api.get("packages/testRestGetVersionHistory/asset1.drl?version=all");
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        res.writeData(out);
        String d = new String(out.toByteArray());
        //System.err.println(d);
        assertTrue(d.indexOf(",alan_parsons,This is something") > 0);


        asset1.updateContent("new content");
        asset1.checkin("This is another");

        res = api.get("packages/testRestGetVersionHistory/asset1.drl?version=all");
        out = new ByteArrayOutputStream();

        res.writeData(out);
        d = new String(out.toByteArray());
        System.err.println(d);
        assertTrue(d.indexOf(",alan_parsons,This is something") > 0);
        assertTrue(d.indexOf(",alan_parsons,This is another") > 0);
        assertTrue(d.indexOf("1=") > -1);
        assertTrue(d.indexOf("2=") > -1);
        assertEquals(-1, d.indexOf("0="));

        res = api.get("packages/testRestGetVersionHistory/asset1.drl?version=1");
        out = new ByteArrayOutputStream();

        res.writeData(out);
        d = new String(out.toByteArray());
        assertEquals("this is content", d);


        res = api.get("packages");
View Full Code Here

        res = (Text) api.get("packages/testVersionHistoryAndArchived");
        assertEquals(-1, res.data.indexOf("asset2.drl"));


        Response resp = api.get("packages/testVersionHistoryAndArchived/asset1.drl?version=all");
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        res.writeData(out);
        String d = new String(out.toByteArray());
        assertNotNull(d);

        resp = api.get("packages/testVersionHistoryAndArchived/asset2.drl?version=all");
        out = new ByteArrayOutputStream();

        resp.writeData(out);
        d = new String(out.toByteArray());
        assertEquals("", d);
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.files.Response

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.