コード例 #1
0
  /**
   * In the absence of webapp faces-config.xml and META-INF/services, verify that the overrides
   * specified in the implementation faces-config.xml take precedence.
   *
   * @throws java.lang.Exception
   */
  public void testJSFImplCase() throws Exception {
    Object factory = null;
    Class clazz = null;

    FactoryFinder.releaseFactories();
    int len, i = 0;

    // this testcase only simulates the "faces implementation
    // specific" part
    for (i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) {
      FactoryFinder.setFactory(
          FactoryFinderTestCase2.FACTORIES[i][0], FactoryFinderTestCase2.FACTORIES[i][1]);
    }

    for (i = 0, len = FactoryFinderTestCase2.FACTORIES.length; i < len; i++) {
      clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][0]);
      factory = FactoryFinder.getFactory(FactoryFinderTestCase2.FACTORIES[i][0]);
      assertTrue(
          "Factory for " + clazz.getName() + " not of expected type.",
          clazz.isAssignableFrom(factory.getClass()));
      clazz = Class.forName(FactoryFinderTestCase2.FACTORIES[i][1]);
      assertTrue(
          "Factory " + FactoryFinderTestCase2.FACTORIES[i][1] + " not of expected type",
          clazz.isAssignableFrom(factory.getClass()));
    }
  }
コード例 #2
0
  @Override
  public void setUp() throws Exception {
    FactoryFinder.releaseFactories();
    super.setUp();
    for (int i = 0, len = FACTORIES.length; i < len; i++) {
      System.getProperties().remove(FACTORIES[i][0]);
    }

    FactoryFinder.releaseFactories();
    int len, i = 0;

    // simulate the "faces implementation specific" part
    for (i = 0, len = FACTORIES.length; i < len; i++) {
      FactoryFinder.setFactory(FACTORIES[i][0], FACTORIES[i][1]);
    }

    UIViewRoot root = facesContext.getApplication().getViewHandler().createView(facesContext, null);
    root.setViewId("/viewId");
    facesContext.setViewRoot(root);
    RenderKitFactory renderKitFactory =
        (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
    RenderKit renderKit = new MockRenderKit();
    try {
      renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
    } catch (IllegalArgumentException e) {;
    }
  }