Package com.firefly.mvc.web

Examples of com.firefly.mvc.web.Resource$ResourceSet


        if (includeDependencies) {
            for (int n = mFlatLibraries.size() - 1 ; n >= 0 ; n--) {
                LibraryDependency dependency = mFlatLibraries.get(n);
                File resFolder = dependency.getResFolder();
                if (resFolder.isDirectory()) {
                    ResourceSet resourceSet = new ResourceSet(dependency.getFolder().getName());
                    resourceSet.addSource(resFolder);
                    resourceSets.add(resourceSet);
                }
            }
        }

        Set<File> mainResDirs = mDefaultSourceProvider.getResDirectories();

        ResourceSet resourceSet = new ResourceSet(BuilderConstants.MAIN);
        resourceSet.addSources(mainResDirs);
        if (generatedResFolder != null) {
            resourceSet.addSource(generatedResFolder);
        }
        resourceSets.add(resourceSet);

        // the list of flavor must be reversed to use the right overlay order.
        for (int n = mFlavorSourceProviders.size() - 1; n >= 0 ; n--) {
            SourceProvider sourceProvider = mFlavorSourceProviders.get(n);

            Set<File> flavorResDirs = sourceProvider.getResDirectories();
            // we need the same of the flavor config, but it's in a different list.
            // This is fine as both list are parallel collections with the same number of items.
            resourceSet = new ResourceSet(mFlavorConfigs.get(n).getName());
            resourceSet.addSources(flavorResDirs);
            resourceSets.add(resourceSet);
        }

        if (mBuildTypeSourceProvider != null) {
            Set<File> typeResDirs = mBuildTypeSourceProvider.getResDirectories();
            resourceSet = new ResourceSet(mBuildType.getName());
            resourceSet.addSources(typeResDirs);
            resourceSets.add(resourceSet);
        }

        return resourceSets;
    }
View Full Code Here


public class TestResource {
 
  @Test
  public void testResource() throws NoSuchMethodException, SecurityException {
    IndexController controller = new IndexController();
    Resource resource = new Resource("utf-8");
    ControllerMetaInfo cm = new ControllerMetaInfo(controller,
        IndexController.class.getMethod("index4", HttpServletRequest.class, HttpServletResponse.class));
   
    resource.add("/user/id-?-?", cm);
    resource.add("/user/id-?-?/?", cm);
    resource.add("/user/add", cm);
    resource.add("/document/_?/?", cm);
   
    resource.add("/shop/fruit/apple/?", cm);
    resource.add("/shop/fruit/banana", cm);
    resource.add("/file/info.txt", cm);
   
    Result ret = resource.match("/user/id-3344-2222/55555");
    Assert.assertThat(ret.getParams().length, is(3));
    Assert.assertThat(ret.getParams()[1], is("2222"));
    Assert.assertThat(ret.getParams()[2], is("55555"));
   
    ret = resource.match("/shop/fruit/banana");
    Assert.assertThat(ret.getParams(), nullValue());
   
    ret = resource.match("/hello");
    Assert.assertThat(ret, nullValue());
   
    ret = resource.match("/file/info.txt");
    Assert.assertThat(ret, notNullValue());
   
    ret = resource.match("/document/_pengpeng");
    Assert.assertThat(ret, nullValue());
   
    Assert.assertThat(resource.getEncoding(), is("utf-8"));
  }
View Full Code Here

TOP

Related Classes of com.firefly.mvc.web.Resource$ResourceSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.