### Question:
HashLockedDomainService implements LockedDomainService { public boolean gadgetCanRender(String host, Gadget gadget, String container) { container = normalizeContainer(container); if (enabled) { if (gadgetWantsLockedDomain(gadget) || hostRequiresLockedDomain(host) || containerRequiresLockedDomain(container)) { String neededHost = getLockedDomain(gadget, container); return host.equals(neededHost); } } return true; } @Inject  HashLockedDomainService(ContainerConfig config,
                                 @Named("shindig.locked-domain.enabled") boolean enabled); @Inject(optional = true) void setLockSecurityTokens(
      @Named("shindig.locked-domain.lock-security-tokens") Boolean lockSecurityTokens); boolean isEnabled(); boolean isSafeForOpenProxy(String host); boolean gadgetCanRender(String host, Gadget gadget, String container); String getLockedDomainForGadget(Gadget gadget, String container); static final String LOCKED_DOMAIN_REQUIRED_KEY; static final String LOCKED_DOMAIN_SUFFIX_KEY; }### Answer:
@Test public void testMissingConfig() throws Exception { ContainerConfig containerMissingConfig = mock(ContainerConfig.class); expect(containerMissingConfig.getContainers()) .andReturn(Arrays.asList(ContainerConfig.DEFAULT_CONTAINER)); replay(); lockedDomainService = new HashLockedDomainService(containerMissingConfig, true); assertFalse(lockedDomainService.gadgetCanRender("www.example.com", wantsLocked, "default")); assertTrue(lockedDomainService.gadgetCanRender("www.example.com", notLocked, "default")); }
@Test public void testMultiContainer() throws Exception { ContainerConfig inheritsConfig = mock(ContainerConfig.class); expect(inheritsConfig.getContainers()) .andReturn(Arrays.asList(ContainerConfig.DEFAULT_CONTAINER, "other")); expect(inheritsConfig.getBool(isA(String.class), eq(LOCKED_DOMAIN_REQUIRED_KEY))) .andReturn(true).anyTimes(); expect(inheritsConfig.getString(isA(String.class), eq(LOCKED_DOMAIN_SUFFIX_KEY))) .andReturn("-a.example.com:8080").anyTimes(); replay(); lockedDomainService = new HashLockedDomainService(inheritsConfig, true); assertFalse(lockedDomainService.gadgetCanRender("www.example.com", wantsLocked, "other")); assertFalse(lockedDomainService.gadgetCanRender("www.example.com", notLocked, "other")); assertTrue(lockedDomainService.gadgetCanRender( "8uhr00296d2o3sfhqilj387krjmgjv3v-a.example.com:8080", wantsLocked, "other")); }