IComponentSpecification spec = new ComponentSpecification();
ClasspathResource base = new ClasspathResource(new DefaultClassResolver(), "/org/apache/tapestry/resolver/MyComponent.jwc");
spec.setSpecificationLocation(base);
spec.setComponentClassName("org.apache.tapestry.resolver.MyComponent");
AssetFactory classpathFactory = newMock(AssetFactory.class);
AssetFactory contextFactory = newMock(AssetFactory.class);
Resource contextRoot = newMock(Resource.class);
Resource webinfLocation = newMock(Resource.class);
Resource webinfAppLocation = newMock(Resource.class);
ComponentResourceResolverImpl resolver = new ComponentResourceResolverImpl();
resolver.setApplicationId("foo");
resolver.setClasspathAssetFactory(classpathFactory);
resolver.setContextAssetFactory(contextFactory);
resolver.setContextRoot(contextRoot);
expect(contextRoot.getRelativeResource("WEB-INF/")).andReturn(webinfLocation);
expect(webinfLocation.getRelativeResource("foo/")).andReturn(webinfAppLocation);
expect(comp.getSpecification()).andReturn(spec).anyTimes();
expect(comp.getNamespace()).andReturn(namespace);
expect(namespace.getPropertyValue("org.apache.tapestry.component-class-packages")).andReturn("org.apache.tapestry.resolver");
Location l = newMock(Location.class);
IAsset asset = newMock(IAsset.class);
Resource resource = newMock(Resource.class);
expect(contextFactory.assetExists(spec, webinfAppLocation, "MyComponent.html", null)).andReturn(false);
expect(contextFactory.assetExists(spec, webinfLocation, "MyComponent.html", null)).andReturn(false);
expect(classpathFactory.assetExists(spec, base, "MyComponent.html", null)).andReturn(true);
expect(comp.getLocation()).andReturn(l);
expect(classpathFactory.createAsset(base, spec, "MyComponent.html", null, l)).andReturn(asset);
expect(asset.getResourceLocation()).andReturn(resource);