@Test
public void testGlobalLookupsForVirtualHostsWithSameIP() {
final Server server = new Server();
IGlobalScope g0 = new DummyGlobalScope("default");
IGlobalScope g1 = new DummyGlobalScope("default.vhost1");
IGlobalScope g2 = new DummyGlobalScope("default.vhost2");
//local server
server.registerGlobal(g0);
server.addMapping("localhost", "", "default");
server.addMapping("localhost", "oflaDemo", "default");
//virtual host 1
server.registerGlobal(g1);
server.addMapping("", "", "default.vhost1");
server.addMapping("localhost", "oflaDemo", "default.vhost1");
server.addMapping("localhost:8088", "", "default.vhost1");
server.addMapping("127.0.0.1", "oflaDemo", "default.vhost1");
//
server.addMapping("vhost1.localdomain", "", "default.vhost1");
server.addMapping("vhost1.localdomain", "oflaDemo", "default.vhost1");
//virtual host 2
server.registerGlobal(g2);
server.addMapping("", "", "default.vhost2");
server.addMapping("localhost", "oflaDemo", "default.vhost2");
server.addMapping("localhost:8088", "", "default.vhost2");
server.addMapping("127.0.0.1", "oflaDemo", "default.vhost2");
//
server.addMapping("vhost2.localdomain", "", "default.vhost2");
server.addMapping("vhost2.localdomain", "oflaDemo", "default.vhost2");
//assertions
Assert.assertTrue(server.lookupGlobal("vhost2.localdomain", "blah") != null);
Assert.assertTrue(server.lookupGlobal("vhost2.localdomain", "oflaDemo") != null);
IGlobalScope tmp = server.lookupGlobal("vhost2.localdomain", "oflaDemo");
log.debug("Global 2: {}", tmp);
Assert.assertTrue(tmp.getName().equals("default.vhost2"));
tmp = server.lookupGlobal("vhost1.localdomain", "oflaDemo");
log.debug("Global 1: {}", tmp);
Assert.assertTrue(tmp.getName().equals("default.vhost1"));
}