@Test public void beanMgrTest() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco = bm.createCreationalContext(bean); assertNotNull(coco); Object obj = bm.getReference(bean, TestPortlet1.class, coco); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Object obj2 = bm.getReference(bean, TestPortlet1.class, coco); assertNotNull(obj2); assertFalse(obj.equals(obj2)); assertFalse(obj == obj2); }
@Test public void appScopedTest() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco = bm.createCreationalContext(bean); assertNotNull(coco); Object obj = bm.getReference(bean, TestPortlet1AppScoped.class, coco); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Object obj2 = bm.getReference(bean, TestPortlet1AppScoped.class, coco); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); }
@Test public void appScopedTest2Coco() throws Exception { assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean = bm.resolve(beans); assertNotNull(bean); CreationalContext<?> coco1 = bm.createCreationalContext(bean); assertNotNull(coco1); Object obj = bm.getReference(bean, TestPortlet1AppScoped.class, coco1); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); CreationalContext<?> coco2 = bm.createCreationalContext(bean); assertNotNull(coco2); Object obj2 = bm.getReference(bean, TestPortlet1AppScoped.class, coco2); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); }
@Test public void appScopedTest2Coco2Bean() throws Exception { assertNotNull(bm); Set<Bean<?>> beans1 = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean1 = bm.resolve(beans1); assertNotNull(bean1); CreationalContext<?> coco1 = bm.createCreationalContext(bean1); assertNotNull(coco1); Object obj = bm.getReference(bean1, TestPortlet1AppScoped.class, coco1); assertNotNull(obj); assertTrue(obj instanceof GenericPortlet); assertTrue(obj instanceof Portlet); assertTrue(obj instanceof HeaderPortlet); assertTrue(obj instanceof EventPortlet); assertTrue(obj instanceof ResourceServingPortlet); Set<Bean<?>> beans2 = bm.getBeans(TestPortlet1AppScoped.class); Bean<?> bean2 = bm.resolve(beans2); assertNotNull(bean2); CreationalContext<?> coco2 = bm.createCreationalContext(bean2); assertNotNull(coco2); Object obj2 = bm.getReference(bean2, TestPortlet1AppScoped.class, coco2); assertNotNull(obj2); assertTrue(obj.equals(obj2)); assertTrue(obj == obj2); assertEquals(bean1, bean2); assertNotEquals(coco1, coco2); }
public ServletContext getServletContext(GenericPortlet portlet) { PortletContextImpl ctx = (PortletContextImpl)(portlet.getPortletContext()); return ctx.getServletContext(); }
public HttpServletRequest getHttpServletRequest(GenericPortlet portlet, PortletRequest request) { return (HttpServletRequest) ((HttpServletRequestWrapper) request).getRequest(); }
public HttpServletResponse getHttpServletResponse(GenericPortlet portlet, PortletResponse response) { return (HttpServletResponse) ((HttpServletResponseWrapper) response).getResponse(); }