@Test
public void testAddResourceService() throws Exception {

  Resource.Type type = new Resource.Type("resource");
  ViewInstanceEntity definition = ViewInstanceEntityTest.getViewInstanceEntity();
  ViewExternalSubResourceService service = new ViewExternalSubResourceService(type, definition);
  Object fooService = new Object();
  service.addResourceService("foo", fooService);
  Assert.assertEquals(fooService, service.getResource("foo"));
  try {
    service.getResource("bar");
    Assert.fail("Expected IllegalArgumentException for unknown service name.");
  } catch (IllegalArgumentException e) {
    // expected
  }
}