@SuppressWarnings({"deprecation"})
  public void testUserAgentNeedsUpdate1() throws Exception {

    ResourceHandler handler = getFacesContext().getApplication().getResourceHandler();
    assertTrue(handler != null);

    // no If-Modified-Since request header, so this should always
    // return true
    Resource resource = handler.createResource("duke-nv.gif");
    assertTrue(resource.userAgentNeedsUpdate(getFacesContext()));

    // set the creation date of the ResourceHandler back in time so that
    // if the header was present it would return true - the lack of the header
    // should result in true being returned in this case
    Date date = new Date();
    date.setYear(1980);
    long origTime =
        (Long)
            TestingUtil.invokePrivateMethod(
                "getCreationTime", null, null, ResourceHandlerImpl.class, handler);
    TestingUtil.invokePrivateMethod(
        "setCreationTime",
        new Class[] {Long.TYPE},
        new Object[] {date.getTime()},
        ResourceHandlerImpl.class,
        handler);
    assertTrue(resource.userAgentNeedsUpdate(getFacesContext()));
    TestingUtil.invokePrivateMethod(
        "setCreationTime",
        new Class[] {Long.TYPE},
        new Object[] {origTime},
        ResourceHandlerImpl.class,
        handler);
  }
Example #2
0
 public static void clearResourceBundlesFromAssociate(ApplicationImpl application) {
   ApplicationAssociate associate =
       (ApplicationAssociate)
           TestingUtil.invokePrivateMethod(
               "getAssociate",
               RIConstants.EMPTY_CLASS_ARGS,
               RIConstants.EMPTY_METH_ARGS,
               ApplicationImpl.class,
               application);
   if (null != associate) {
     Map resourceBundles =
         (Map)
             TestingUtil.getPrivateField("resourceBundles", ApplicationAssociate.class, associate);
     if (null != resourceBundles) {
       resourceBundles.clear();
     }
   }
 }
Example #3
0
  public void testIsInjectable() throws Exception {

    ManagedBeanInfo bean =
        new ManagedBeanInfo(beanName, beanName, "session", null, null, null, null);
    BeanManager beanManager = ApplicationAssociate.getCurrentInstance().getBeanManager();
    beanManager.register(bean);
    BeanBuilder builder = beanManager.getBuilder(beanName);
    Boolean isInjectable =
        (Boolean)
            TestingUtil.invokePrivateMethod(
                "scanForAnnotations",
                new Class[] {Class.class},
                new Object[] {TestBean.class},
                BeanBuilder.class,
                builder);
    assertTrue(!isInjectable);

    bean =
        new ManagedBeanInfo(
            beanName,
            "com.sun.faces.config.TestManagedBeanFactory$InjectionBean",
            "request",
            null,
            null,
            null,
            null);
    beanManager.register(bean);

    isInjectable =
        (Boolean)
            TestingUtil.invokePrivateMethod(
                "scanForAnnotations",
                new Class[] {Class.class},
                new Object[] {InjectionBean.class},
                BeanBuilder.class,
                builder);

    assertTrue(isInjectable);
  }