Remove legacy code following JSF 2.0 migration
- Remove JSF 1.2 components including ui package, faces-config.xml references and tld files - Remove AjaxViewRoot class - Polish JavaDocs Issues: SWF-1536
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.faces.component.UIForm;
|
||||
import javax.faces.component.UIPanel;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.render.RenderKitFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.myfaces.test.mock.MockResponseWriter;
|
||||
import org.springframework.faces.webflow.JSFMockHelper;
|
||||
import org.springframework.faces.webflow.MockViewHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.webflow.execution.View;
|
||||
|
||||
public class AjaxViewRootTests extends TestCase {
|
||||
|
||||
JSFMockHelper jsf = new JSFMockHelper();
|
||||
|
||||
UIViewRoot testTree = new UIViewRoot();
|
||||
|
||||
private final StringWriter output = new StringWriter();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
this.jsf.setUp();
|
||||
this.jsf.facesContext().getApplication().setViewHandler(new MockViewHandler());
|
||||
this.jsf.facesContext().setResponseWriter(new MockResponseWriter(this.output, null, null));
|
||||
|
||||
UIForm form = new UIForm();
|
||||
form.setId("foo");
|
||||
this.testTree.getChildren().add(form);
|
||||
UIPanel panel = new UIPanel();
|
||||
panel.setId("bar");
|
||||
form.getChildren().add(panel);
|
||||
ProgressiveUICommand command = new ProgressiveUICommand();
|
||||
command.setId("baz");
|
||||
panel.getChildren().add(command);
|
||||
|
||||
this.testTree.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
|
||||
|
||||
this.jsf.facesContext().setViewRoot(this.testTree);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
this.jsf.tearDown();
|
||||
}
|
||||
|
||||
public void testProcessDecodes() {
|
||||
this.jsf.externalContext().getRequestParameterMap().put("processIds", "foo:bar, foo:baz");
|
||||
|
||||
AjaxViewRoot ajaxRoot = new AjaxViewRoot(this.testTree);
|
||||
|
||||
ajaxRoot.processDecodes(this.jsf.facesContext());
|
||||
|
||||
assertEquals(1, ajaxRoot.getProcessIds().length);
|
||||
}
|
||||
|
||||
public void testEncodeAll_NoRenderIds() throws IOException {
|
||||
this.jsf.externalContext().getRequestParameterMap().put("processIds", "foo:bar, foo:baz");
|
||||
|
||||
AjaxViewRoot ajaxRoot = new AjaxViewRoot(this.testTree);
|
||||
|
||||
ajaxRoot.encodeAll(this.jsf.facesContext());
|
||||
|
||||
assertEquals(1, ajaxRoot.getProcessIds().length);
|
||||
assertEquals(1, ajaxRoot.getRenderIds().length);
|
||||
assertEquals(StringUtils.arrayToCommaDelimitedString(ajaxRoot.getProcessIds()),
|
||||
StringUtils.arrayToCommaDelimitedString(ajaxRoot.getRenderIds()));
|
||||
}
|
||||
|
||||
public void testEncodeAll_RenderIdsExpr() throws IOException {
|
||||
|
||||
this.jsf.externalContext()
|
||||
.getRequestMap()
|
||||
.put(View.RENDER_FRAGMENTS_ATTRIBUTE,
|
||||
StringUtils.delimitedListToStringArray("foo:bar,foo:baz", ",", " "));
|
||||
|
||||
AjaxViewRoot ajaxRoot = new AjaxViewRoot(this.testTree);
|
||||
|
||||
ajaxRoot.encodeAll(this.jsf.facesContext());
|
||||
|
||||
assertEquals(1, ajaxRoot.getRenderIds().length);
|
||||
|
||||
assertEquals("foo:bar", StringUtils.arrayToCommaDelimitedString(ajaxRoot.getRenderIds()));
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class EscapeQuotesTests extends TestCase {
|
||||
|
||||
public final void testEscapeQuotesInLink() {
|
||||
|
||||
String linkText = "<a id=\"mainForm:findHotels\" class=\"progressiveLink\" href=\"#\" name=\"mainForm:findHotels\"\\>";
|
||||
String expectedText = "<a id=\\\"mainForm:findHotels\\\" class=\\\"progressiveLink\\\" href=\\\"#\\\" name=\\\"mainForm:findHotels\\\"\\>";
|
||||
String result = linkText.replaceAll("\"", "\\\\\"");
|
||||
System.out.println(linkText);
|
||||
System.out.println(result);
|
||||
assertEquals(expectedText, result);
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import javax.faces.component.UIForm;
|
||||
import javax.faces.component.UIParameter;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.faces.webflow.JSFMockHelper;
|
||||
|
||||
public class ProgressiveCommandLinkRendererTests extends TestCase {
|
||||
|
||||
JSFMockHelper jsf = new JSFMockHelper();
|
||||
|
||||
ProgressiveCommandLinkRenderer renderer = new ProgressiveCommandLinkRenderer();
|
||||
|
||||
public void setUp() throws Exception {
|
||||
this.jsf.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
this.jsf.tearDown();
|
||||
}
|
||||
|
||||
public void testRenderOnClick_AjaxEnabled_NoParams() throws Exception {
|
||||
String expected = "<a onclick=\"Spring.remoting.submitForm('myForm:foo', 'myForm', "
|
||||
+ "{processIds: 'myForm:foo'}); return false;\"/>";
|
||||
|
||||
UIForm form = new UIForm();
|
||||
form.setId("myForm");
|
||||
ProgressiveUICommand link = new ProgressiveUICommand();
|
||||
link.setId("foo");
|
||||
form.getChildren().add(link);
|
||||
|
||||
RenderAttributeCallback callback = this.renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
callback.doRender(this.jsf.facesContext(), this.jsf.facesContext().getResponseWriter(), link, "onclick", null, "onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().endElement("a");
|
||||
|
||||
assertEquals(expected, this.jsf.contentAsString());
|
||||
}
|
||||
|
||||
public void testRenderOnClick_AjaxEnabled_WithParams() throws Exception {
|
||||
String expected = "<a onclick=\"Spring.remoting.submitForm('myForm:foo', 'myForm', "
|
||||
+ "{processIds: 'myForm:foo', foo : 'bar', zoo : 'baz'}"
|
||||
+ "); return false;\"/>";
|
||||
|
||||
UIForm form = new UIForm();
|
||||
form.setId("myForm");
|
||||
ProgressiveUICommand link = new ProgressiveUICommand();
|
||||
link.setId("foo");
|
||||
form.getChildren().add(link);
|
||||
UIParameter param1 = new UIParameter();
|
||||
param1.setName("foo");
|
||||
param1.setValue("bar");
|
||||
UIParameter param2 = new UIParameter();
|
||||
param2.setName("zoo");
|
||||
param2.setValue("baz");
|
||||
link.getChildren().add(param1);
|
||||
link.getChildren().add(param2);
|
||||
|
||||
RenderAttributeCallback callback = this.renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
callback.doRender(this.jsf.facesContext(), this.jsf.facesContext().getResponseWriter(), link, "onclick", null, "onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().endElement("a");
|
||||
|
||||
assertEquals(expected, this.jsf.contentAsString());
|
||||
}
|
||||
|
||||
public void testRenderOnClick_AjaxDisabled_NoParams() throws Exception {
|
||||
String expected = "<a onclick=\"this.submitFormFromLink('myForm','myForm:foo', []); return false;\"/>";
|
||||
|
||||
UIForm form = new UIForm();
|
||||
form.setId("myForm");
|
||||
ProgressiveUICommand link = new ProgressiveUICommand();
|
||||
link.setId("foo");
|
||||
link.setAjaxEnabled(false);
|
||||
form.getChildren().add(link);
|
||||
|
||||
RenderAttributeCallback callback = this.renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
callback.doRender(this.jsf.facesContext(), this.jsf.facesContext().getResponseWriter(), link, "onclick", null, "onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().endElement("a");
|
||||
|
||||
assertEquals(expected, this.jsf.contentAsString());
|
||||
}
|
||||
|
||||
public void testRenderOnClick_AjaxDisabled_WithParams() throws Exception {
|
||||
String expected = "<a onclick=\"this.submitFormFromLink('myForm','myForm:foo', ["
|
||||
+ "{name : 'foo', value : 'bar'}, {name : 'zoo', value : 'baz'}"
|
||||
+ "]); return false;\"/>";
|
||||
|
||||
UIForm form = new UIForm();
|
||||
form.setId("myForm");
|
||||
ProgressiveUICommand link = new ProgressiveUICommand();
|
||||
link.setId("foo");
|
||||
link.setAjaxEnabled(false);
|
||||
form.getChildren().add(link);
|
||||
UIParameter param1 = new UIParameter();
|
||||
param1.setName("foo");
|
||||
param1.setValue("bar");
|
||||
UIParameter param2 = new UIParameter();
|
||||
param2.setName("zoo");
|
||||
param2.setValue("baz");
|
||||
link.getChildren().add(param1);
|
||||
link.getChildren().add(param2);
|
||||
|
||||
RenderAttributeCallback callback = this.renderer.getAttributeCallbacks(link).get("onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().startElement("a", link);
|
||||
|
||||
callback.doRender(this.jsf.facesContext(), this.jsf.facesContext().getResponseWriter(), link, "onclick", null, "onclick");
|
||||
|
||||
this.jsf.facesContext().getResponseWriter().endElement("a");
|
||||
|
||||
assertEquals(expected, this.jsf.contentAsString());
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
|
||||
public class TestConverter implements Converter {
|
||||
|
||||
public TestConverter() {
|
||||
}
|
||||
|
||||
public Object getAsObject(FacesContext context, UIComponent component, String value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getAsString(FacesContext context, UIComponent component, Object value) {
|
||||
return ((TestValue) value).getStringValue();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package org.springframework.faces.ui;
|
||||
|
||||
public class TestValue {
|
||||
|
||||
public String getStringValue() {
|
||||
return "foo";
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package org.springframework.faces.ui.resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.myfaces.test.mock.MockResponseWriter;
|
||||
import org.springframework.faces.webflow.JSFMockHelper;
|
||||
|
||||
public class FlowResourceHelperTests extends TestCase {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
JSFMockHelper jsf = new JSFMockHelper();
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
this.jsf.setUp();
|
||||
// TODO figure out how to set the context path
|
||||
this.jsf.facesContext().setResponseWriter(new MockResponseWriter(this.writer, "text/html", "UTF-8"));
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
this.jsf.tearDown();
|
||||
}
|
||||
|
||||
public final void testRenderScriptLink() throws IOException {
|
||||
|
||||
String scriptPath = "/dojo/dojo.js";
|
||||
String expectedUrl = "null/resources/dojo/dojo.js";
|
||||
|
||||
ResourceHelper.renderScriptLink(this.jsf.facesContext(), scriptPath);
|
||||
ResourceHelper.renderScriptLink(this.jsf.facesContext(), scriptPath);
|
||||
|
||||
String expectedOutput = "<script type=\"text/javascript\" src=\"" + expectedUrl + "\"/>";
|
||||
|
||||
assertEquals(expectedOutput, this.writer.toString());
|
||||
|
||||
}
|
||||
|
||||
public final void testRenderStyleLink() throws IOException {
|
||||
|
||||
String scriptPath = "/dijit/themes/dijit.css";
|
||||
String expectedUrl = "null/resources/dijit/themes/dijit.css";
|
||||
|
||||
ResourceHelper.renderStyleLink(this.jsf.facesContext(), scriptPath);
|
||||
ResourceHelper.renderStyleLink(this.jsf.facesContext(), scriptPath);
|
||||
|
||||
String expectedOutput = "<link type=\"text/css\" rel=\"stylesheet\" href=\"" + expectedUrl + "\"/>";
|
||||
|
||||
assertEquals(expectedOutput, this.writer.toString());
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import junit.framework.TestCase;
|
||||
import org.apache.myfaces.test.mock.MockResponseWriter;
|
||||
import org.apache.myfaces.test.mock.MockStateManager;
|
||||
import org.easymock.EasyMock;
|
||||
import org.springframework.faces.ui.AjaxViewRoot;
|
||||
import org.springframework.webflow.core.collection.MutableAttributeMap;
|
||||
import org.springframework.webflow.execution.FlowExecutionContext;
|
||||
import org.springframework.webflow.execution.FlowExecutionKey;
|
||||
@@ -104,12 +103,6 @@ public class JsfViewTests extends TestCase {
|
||||
this.view.saveState();
|
||||
}
|
||||
|
||||
public final void testSaveState_AjaxViewRoot() {
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
this.view.setViewRoot(new AjaxViewRoot(this.view.getViewRoot()));
|
||||
this.view.saveState();
|
||||
}
|
||||
|
||||
public final void testRender() throws IOException {
|
||||
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
@@ -160,33 +153,6 @@ public class JsfViewTests extends TestCase {
|
||||
assertTrue("The lifecycle should have been invoked", ((NoEventLifecycle) lifecycle).executed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax Request - View already exists in view scope and must be restored and the lifecycle executed, no event
|
||||
* signaled
|
||||
*/
|
||||
public final void testProcessUserEvent_Restored_Ajax_NoEvent() {
|
||||
|
||||
EasyMock.expect(this.flashScope.getBoolean(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY))).andStubReturn(
|
||||
false);
|
||||
EasyMock.expect(this.flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
.andStubReturn(null);
|
||||
|
||||
Lifecycle lifecycle = new NoEventLifecycle(this.jsfMock.lifecycle());
|
||||
|
||||
UIViewRoot existingRoot = new UIViewRoot();
|
||||
existingRoot.setViewId(VIEW_ID);
|
||||
AjaxViewRoot ajaxRoot = new AjaxViewRoot(existingRoot);
|
||||
|
||||
EasyMock.replay(new Object[] { this.context, this.flowExecutionContext, this.flowMap, this.flashScope });
|
||||
|
||||
JsfView restoredView = new JsfView(ajaxRoot, lifecycle, this.context);
|
||||
|
||||
restoredView.processUserEvent();
|
||||
|
||||
assertFalse("An unexpected event was signaled,", restoredView.hasFlowEvent());
|
||||
assertTrue("The lifecycle should have been invoked", ((NoEventLifecycle) lifecycle).executed);
|
||||
}
|
||||
|
||||
/**
|
||||
* View already exists in view scope and must be restored and the lifecycle executed, an event is signaled
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user