ResourceFactory { public static IResource createResource(IResourceUrn urn, URL url, IResourceLocale locale, IResourceLibrary library) { return ResourceManager.INSTANCE.create(urn, url, locale, library); }  static IAggregatedResource createAggregatedResource(List<IResource> resources); static IInlineResource createInlineResource(String type, String content); static IExternalResource createExternalResource(String type, String url); static IResource createLibraryResource(String resourcePath); static IResource createResource(IResourceUrn urn, URL url, IResourceLocale locale, IResourceLibrary library); static IResource createResource(String resourcePath); static IResource createResourceByEl(String el); static IResource createResource(String resourceType, String namespace, String resourcePath); static IResource createResource(String resourceType, String namespace, String resourcePath,
         Map<String, Object> arguments); static IResource createResource(URL url, String locale, IResourceLibrary libraryInfo); static IResource createWarResource(String resourcePath);  }
@Test public void testCreateResource() { IResource sampleResource = ResourceFactory.createResource("/js/sample/sample.js"); Assert.assertNotNull(sampleResource); Assert.assertEquals("document.write(\"this is sample.js<br>\");", new String(sampleResource.getOriginalContent())); IResource sampleResource2 = ResourceFactory.createWarResource("/js/sample/sample.js"); Assert.assertNotNull(sampleResource2); Assert.assertEquals("document.write(\"this is sample.js<br>\");", new String(sampleResource2.getOriginalContent())); IResource img = ResourceFactory.createWarResource("/img/ebayLogo.gif"); Assert.assertNotNull(img); Assert.assertTrue(img.getOriginalUrl().toExternalForm().contains("ebayLogo.gif")); }
@Test public void testCSSBgUrl() { IResource resource = ResourceFactory.createResource("/css/sample/sample2.css"); String content = resource.getOriginalContent(); Assert.assertTrue(content.contains("ebayerror.gif")); Assert.assertTrue(content.contains("/BaseResourceTest/lrssvr/ry4sqfvidizw3iszva2fca1haul.gif")); Assert.assertTrue(!content.contains("/img/ebayLogo.gif")); Assert.assertTrue(!content.contains("ebayLogo.gif")); }
@Test public void testFlashResource() { IResource flash = ResourceFactory.createResource("/flash/local.swf"); Assert.assertTrue(flash instanceof FlashResource); Assert.assertEquals(200, ((FlashResource) flash).getWidth()); Assert.assertEquals(150, ((FlashResource) flash).getHeight()); }
@Test public void testTxtResource() { IResource resource = ResourceFactory.createResource("/mytext.txt"); Assert.assertEquals("common", resource.getUrn().getType()); Assert.assertEquals("this is my text", resource.getOriginalContent()); }