*
* @throws Exception
*/
@Test
public void testFindResource() throws Exception {
GadgetSpec mockSpec = createMock(GadgetSpec.class);
Map<String, GadgetResource> jsResources, htmlResources, cssResources;
jsResources = Maps.newLinkedHashMap();
htmlResources = Maps.newLinkedHashMap();
cssResources = Maps.newLinkedHashMap();
GadgetResource jsResource = createMock(GadgetResource.class);
expect(jsResource.getName()).andReturn("foo.js");
jsResources.put("foo.js", jsResource);
GadgetResource htmlResource = createMock(GadgetResource.class);
expect(htmlResource.getName()).andReturn("bar.html");
htmlResources.put("bar.html", htmlResource);
GadgetResource cssResource = createMock(GadgetResource.class);
expect(cssResource.getName()).andReturn("baz.css");
cssResources.put("baz.css", cssResource);
GadgetResource xmlResource = createMock(GadgetResource.class);
expect(xmlResource.getName()).andReturn("gadget.xml").atLeastOnce();
expect(mockSpec.getJsResources()).andReturn(jsResources);
expect(mockSpec.getHtmlResources()).andReturn(htmlResources);
expect(mockSpec.getCssResources()).andReturn(cssResources);
expect(mockSpec.getGadgetResource()).andReturn(xmlResource).atLeastOnce();
replay(mockSpec, jsResource, htmlResource, cssResource, xmlResource, registry);
niceControl.replay();
assertEquals(jsResource, servlet.findResource(mockSpec, "foo.js"));