Resource r1 = registry.newResource();
r1.setContent("12345678"); // 8 byte is ok
registry.put("/bang", r1);
new ThrottlingJob().executeTask(task);
try {
putEmptyResource();
assertTrue(true);
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
r1.setContent("123456789"); // 9 byte is not ok
registry.put("/bang", r1);
new ThrottlingJob().executeTask(task);
try {
putEmptyResource();
assertTrue(false); // we expect the exception
} catch (Exception e) {
assertTrue(true);
assertEquals("Your data is big. Bigger than 8", e.getMessage());
}
registry.delete("/bang");
new ThrottlingJob().executeTask(task);
r1.setContent("1234567891011"); // > 10 byte is not ok
registry.put("/bang", r1);
new ThrottlingJob().executeTask(task);
try {
putEmptyResource();
assertTrue(true);
} catch (Exception e) {
assertTrue(false);
e.printStackTrace();
}
registry.delete("/bang");
new ThrottlingJob().executeTask(task);
r1.setContent("1234567890123456");
registry.put("/bang", r1);
new ThrottlingJob().executeTask(task);
try {
putEmptyResource();
assertTrue(false); // we expect the exception
} catch (Exception e) {
assertTrue(true);
assertEquals("the strange condition for test1 is met", e.getMessage());
}
registry.delete("/bang");
new ThrottlingJob().executeTask(task);
r1.setContent("12345678901234567");
registry.put("/bang", r1);
new ThrottlingJob().executeTask(task);
try {
putEmptyResource();
assertTrue(false); // we expect the exception
} catch (Exception e) {
assertTrue(true);