Java Code Examples for javax.portlet.PortletMode#EDIT

The following examples show how to use javax.portlet.PortletMode#EDIT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvokeHeaderTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Test
public void invoke2c() throws Exception {
   meths.reset();
   PortletInvoker i = new PortletInvoker(ams, "portlet2");
   PortletMode mode = PortletMode.EDIT;
   req.setMode(mode);
   i.renderHeaders(req, resp);
   List<String> names = meths.getMethods();
   assertNotNull(names);
   assertEquals(3, names.size());
   List<String> soll = Arrays.asList(new String[] {
         Header2.class.getSimpleName() + "#header2c",
         Header1.class.getSimpleName() + "#header2b",
         Header2.class.getSimpleName() + "#header2d",
         });
   assertArrayEquals(soll.toArray(), names.toArray());
}
 
Example 2
Source File: InvokeRenderTest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Test
public void invoke2c() throws Exception {
   meths.reset();
   PortletInvoker i = new PortletInvoker(ams, "portlet2", cfg);
   PortletMode mode = PortletMode.EDIT;
   req.setMode(mode);
   i.render(req, resp);
   List<String> names = meths.getMethods();
   assertNotNull(names);
   assertEquals(3, names.size());
   List<String> soll = Arrays.asList(new String[] {
         Render2.class.getSimpleName() + "#render2c",
         Render1.class.getSimpleName() + "#render2b",
         Render2.class.getSimpleName() + "#render2d",
         });
   assertArrayEquals(soll.toArray(), names.toArray());
}
 
Example 3
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public void doTestAdaptedHandleMethods(final Class<?> controllerClass) throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			GenericWebApplicationContext wac = new GenericWebApplicationContext();
			wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockActionRequest actionRequest = new MockActionRequest(PortletMode.VIEW);
	MockActionResponse actionResponse = new MockActionResponse();
	portlet.processAction(actionRequest, actionResponse);
	assertEquals("value", actionResponse.getRenderParameter("test"));

	MockRenderRequest request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("param1", "value1");
	request.addParameter("param2", "2");
	MockRenderResponse response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-value1-2", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.HELP);
	request.addParameter("name", "name1");
	request.addParameter("age", "2");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-name1-2", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.VIEW);
	request.addParameter("name", "name1");
	request.addParameter("age", "value2");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-name1-typeMismatch", response.getContentAsString());
}
 
Example 4
Source File: ResourceRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 5
Source File: PortletRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 6
Source File: ActionResponseWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 7
Source File: EventResponseWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 8
Source File: RenderRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 9
Source File: ActionRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 10
Source File: EventRequestWrapperChecker.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public PortletMode getPortletMode() {
   String meth = "getPortletMode";
   Object[] args = {};
   PortletMode ret = PortletMode.EDIT;
   retVal = ret;
   checkArgs(meth, args);
   return ret;
}
 
Example 11
Source File: GenericPortletFeaturesInvokeTest.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Test
public void test6doEdit() throws Exception {
   List<String> methNames = Arrays.asList(new String[] {
         TestPortlet6.class.getSimpleName() + "#doHeaders",
         TestPortlet6.class.getSimpleName() + "#doEdit",
   });
   PortletMode pm = PortletMode.EDIT;
   helper.renderWithHeaders("Portlet6", pm, methNames);
   assertTrue(meths.isConfigExists());
}
 
Example 12
Source File: InvokeRenderTest.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Test
public void invoke3c() throws Exception {
   meths.reset();
   PortletInvoker i = new PortletInvoker(ams, "portlet3", cfg);
   PortletMode mode = PortletMode.EDIT;
   req.setMode(mode);
   i.render(req, resp);
   List<String> names = meths.getMethods();
   assertNotNull(names);
   assertEquals(1, names.size());
   List<String> soll = Arrays.asList(new String[] {
         Render1.class.getSimpleName() + "#render3d",
         });
   assertArrayEquals(soll.toArray(), names.toArray());
}
 
Example 13
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void doTestAdaptedHandleMethods(final Class<?> controllerClass) throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			GenericWebApplicationContext wac = new GenericWebApplicationContext();
			wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerClass));
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockActionRequest actionRequest = new MockActionRequest(PortletMode.VIEW);
	MockActionResponse actionResponse = new MockActionResponse();
	portlet.processAction(actionRequest, actionResponse);
	assertEquals("value", actionResponse.getRenderParameter("test"));

	MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
	request.setSession(actionRequest.getPortletSession());
	request.setParameters(actionResponse.getRenderParameterMap());
	request.addParameter("name", "name1");
	request.addParameter("age", "value2");
	MockRenderResponse response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-name1-typeMismatch", response.getContentAsString());
	assertNull(request.getPortletSession().getAttribute("testBean"));

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("param1", "value1");
	request.addParameter("param2", "2");
	request.addProperty("header1", "10");
	request.setCookies(new Cookie("cookie1", "3"));
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-value1-2-10-3", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.HELP);
	request.addParameter("name", "name1");
	request.addParameter("age", "2");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test-name1-2", response.getContentAsString());
}
 
Example 14
Source File: Portlet20AnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void typeLevelParameterDispatchingController() throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
			wac.setPortletContext(new MockPortletContext());
			RootBeanDefinition bd = new RootBeanDefinition(MyTypeLevelParameterDispatchingController.class);
			bd.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller", bd);
			RootBeanDefinition bd2 = new RootBeanDefinition(MySpecialParameterDispatchingController.class);
			bd2.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller2", bd2);
			RootBeanDefinition bd3 = new RootBeanDefinition(MyOtherSpecialParameterDispatchingController.class);
			bd3.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller3", bd3);
			RootBeanDefinition bd4 = new RootBeanDefinition(MyParameterDispatchingController.class);
			bd4.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller4", bd4);
			AnnotationConfigUtils.registerAnnotationConfigProcessors(wac);
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockRenderRequest request = new MockRenderRequest(PortletMode.HELP);
	MockRenderResponse response = new MockRenderResponse();
	try {
		portlet.render(request, response);
		fail("Should have thrown NoHandlerFoundException");
	}
	catch (NoHandlerFoundException ex) {
		// expected
	}

	request = new MockRenderRequest(PortletMode.EDIT);
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myDefaultView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "mySpecialValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("mySpecialView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myOtherSpecialValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myOtherSpecialView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.VIEW);
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("view", "other");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myOtherView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("view", "my");
	request.addParameter("lang", "de");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myLangView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("surprise", "!");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("mySurpriseView", response.getContentAsString());
}
 
Example 15
Source File: PortletAnnotationControllerTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void typeLevelParameterDispatchingController() throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			StaticPortletApplicationContext wac = new StaticPortletApplicationContext();
			wac.setPortletContext(new MockPortletContext());
			RootBeanDefinition bd = new RootBeanDefinition(MyTypeLevelParameterDispatchingController.class);
			bd.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller", bd);
			RootBeanDefinition bd2 = new RootBeanDefinition(MySpecialParameterDispatchingController.class);
			bd2.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller2", bd2);
			RootBeanDefinition bd3 = new RootBeanDefinition(MyOtherSpecialParameterDispatchingController.class);
			bd3.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller3", bd3);
			RootBeanDefinition bd4 = new RootBeanDefinition(MyParameterDispatchingController.class);
			bd4.setScope(WebApplicationContext.SCOPE_REQUEST);
			wac.registerBeanDefinition("controller4", bd4);
			AnnotationConfigUtils.registerAnnotationConfigProcessors(wac);
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockRenderRequest request = new MockRenderRequest(PortletMode.HELP);
	MockRenderResponse response = new MockRenderResponse();
	try {
		portlet.render(request, response);
		fail("Should have thrown NoHandlerFoundException");
	}
	catch (NoHandlerFoundException ex) {
		// expected
	}

	request = new MockRenderRequest(PortletMode.EDIT);
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myDefaultView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "mySpecialValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("mySpecialView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myOtherSpecialValue");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myOtherSpecialView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.VIEW);
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("view", "other");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myOtherView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("view", "my");
	request.addParameter("lang", "de");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("myLangView", response.getContentAsString());

	request = new MockRenderRequest(PortletMode.EDIT);
	request.addParameter("myParam", "myValue");
	request.addParameter("surprise", "!");
	response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("mySurpriseView", response.getContentAsString());
}