use of org.opensolaris.opengrok.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class RuntimeEnvironmentTest method testSaveStatistics.
@Test
public void testSaveStatistics() throws IOException {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setStatistics(new Statistics());
env.getStatistics().addRequest(new DummyHttpServletRequest());
env.getStatistics().addRequest(new DummyHttpServletRequest(), "root");
env.getStatistics().addRequestTime(new DummyHttpServletRequest(), "root", 10L);
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
env.saveStatistics(out);
Assert.assertNotEquals("{}", out.toString());
Assert.assertEquals(env.getStatistics().toJson().toJSONString(), out.toString());
}
}
use of org.opensolaris.opengrok.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class AuthorizationPluginClassLoaderTest method testTruePlugin.
@Test
public void testTruePlugin() {
AuthorizationPluginClassLoader instance = new AuthorizationPluginClassLoader(pluginDirectory);
Class clazz = loadClass(instance, "org.sample.plugin.TruePlugin");
IAuthorizationPlugin plugin = getNewInstance(clazz);
Group g = new Group();
g.setName("group1");
Project p = new Project();
p.setName(("project1"));
Assert.assertTrue(plugin.isAllowed(new DummyHttpServletRequest(), g));
Assert.assertTrue(plugin.isAllowed(new DummyHttpServletRequest(), p));
}
use of org.opensolaris.opengrok.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class AuthorizationPluginClassLoaderTest method testFalsePlugin.
@Test
public void testFalsePlugin() {
AuthorizationPluginClassLoader instance = new AuthorizationPluginClassLoader(pluginDirectory);
Class clazz = loadClass(instance, "org.sample.plugin.FalsePlugin");
IAuthorizationPlugin plugin = getNewInstance(clazz);
Group g = new Group();
g.setName("group1");
Project p = new Project();
p.setName(("project1"));
Assert.assertFalse(plugin.isAllowed(new DummyHttpServletRequest(), g));
Assert.assertFalse(plugin.isAllowed(new DummyHttpServletRequest(), p));
}
use of org.opensolaris.opengrok.web.DummyHttpServletRequest in project OpenGrok by OpenGrok.
the class StatsMessageTest method testGet.
@Test
public void testGet() {
testClean();
env.getStatistics().addRequest(new DummyHttpServletRequest());
Message m = new StatsMessage();
m.setText("get");
byte[] out = null;
try {
out = m.apply(env);
} catch (Exception ex) {
Assert.fail("Should not throw any exception");
}
Assert.assertNotNull(out);
Assert.assertTrue(out.length > 0);
Assert.assertNotEquals("{}", new String(out));
}
Aggregations