asset3.checkin("");
assertTrue(asset3.isBinary());
assertFalse(asset1.isBinary());
RestAPI api = new RestAPI(repo);
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);