-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FACES-3220 Resource URL HTML encoded twice (clarify getAddToHeadSuppo…
…rt() return values)
- Loading branch information
1 parent
fe96bdd
commit 795f74f
Showing
6 changed files
with
198 additions
and
95 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...pl/src/test/java/com/liferay/faces/bridge/context/BridgePortalContextAjaxRequestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2000-2017 Liferay, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.liferay.faces.bridge.context; | ||
|
||
import javax.portlet.PortalContext; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.liferay.faces.bridge.context.internal.PortalContextBridgeImpl; | ||
|
||
|
||
/** | ||
* @author Kyle Stiemann | ||
*/ | ||
public class BridgePortalContextAjaxRequestTest { | ||
|
||
@Test | ||
public void testBridgePortalContextAjaxRequest() { | ||
|
||
boolean markupHeadElementSupport = true; | ||
boolean ajaxRequest = true; | ||
PortalContext portalContextBridgeImpl = new PortalContextBridgeImpl(new PortletRequestMockImpl( | ||
markupHeadElementSupport, ajaxRequest)); | ||
testBridgePortalContextAjaxRequest(portalContextBridgeImpl); | ||
|
||
markupHeadElementSupport = false; | ||
portalContextBridgeImpl = new PortalContextBridgeImpl(new PortletRequestMockImpl(markupHeadElementSupport, | ||
ajaxRequest)); | ||
testBridgePortalContextAjaxRequest(portalContextBridgeImpl); | ||
} | ||
|
||
private void testBridgePortalContextAjaxRequest(PortalContext portalContextBridgeImpl) { | ||
|
||
// During a Faces ajax request no elements can be added to the <head> section via the portlet API, so all | ||
// *_HEAD_*_SUPPORT properties should return null. | ||
Assert.assertNull(portalContextBridgeImpl.getProperty(PortalContext.MARKUP_HEAD_ELEMENT_SUPPORT)); | ||
Assert.assertNull(portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_SCRIPT_RESOURCE_TO_HEAD_SUPPORT)); | ||
Assert.assertNull(portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_SCRIPT_TEXT_TO_HEAD_SUPPORT)); | ||
Assert.assertNull(portalContextBridgeImpl.getProperty( | ||
BridgePortalContext.ADD_STYLE_SHEET_RESOURCE_TO_HEAD_SUPPORT)); | ||
Assert.assertNull(portalContextBridgeImpl.getProperty( | ||
BridgePortalContext.ADD_STYLE_SHEET_TEXT_TO_HEAD_SUPPORT)); | ||
Assert.assertNull(portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_ELEMENT_TO_HEAD_SUPPORT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ge-impl/src/test/java/com/liferay/faces/bridge/context/BridgePortalContextTestCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2000-2017 Liferay, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.liferay.faces.bridge.context; | ||
|
||
import javax.portlet.PortalContext; | ||
|
||
import org.junit.Assert; | ||
|
||
|
||
/** | ||
* @author Kyle Stiemann | ||
*/ | ||
public class BridgePortalContextTestCompat { | ||
|
||
protected void testBridgePortalContextAddToHeadSupport(PortalContext portalContextBridgeImpl, | ||
boolean markupHeadElementSupport) { | ||
|
||
// The Portlet 3.0 HeaderResponse.addDependency() API allows the portlet to add any valid element to the | ||
// <head> section, so all BridgePortalContext.ADD_*_TO_HEAD_SUPPORT properties | ||
// (such as ADD_ELEMENT_TO_HEAD_SUPPORT) should return "true". | ||
Assert.assertEquals("true", | ||
portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_SCRIPT_RESOURCE_TO_HEAD_SUPPORT)); | ||
Assert.assertEquals("true", | ||
portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_SCRIPT_TEXT_TO_HEAD_SUPPORT)); | ||
Assert.assertEquals("true", | ||
portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_STYLE_SHEET_RESOURCE_TO_HEAD_SUPPORT)); | ||
Assert.assertEquals("true", | ||
portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_STYLE_SHEET_TEXT_TO_HEAD_SUPPORT)); | ||
Assert.assertEquals("true", | ||
portalContextBridgeImpl.getProperty(BridgePortalContext.ADD_ELEMENT_TO_HEAD_SUPPORT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
bridge-impl/src/test/java/com/liferay/faces/bridge/context/PortletRequestMockCompatImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Copyright (c) 2000-2017 Liferay, Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.liferay.faces.bridge.context; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.portlet.PortletContext; | ||
import javax.portlet.PortletRequest; | ||
import javax.portlet.RenderParameters; | ||
import javax.portlet.faces.Bridge; | ||
|
||
|
||
/** | ||
* @author Kyle Stiemann | ||
*/ | ||
public abstract class PortletRequestMockCompatImpl implements PortletRequest { | ||
|
||
@Override | ||
public PortletContext getPortletContext() { | ||
throw new UnsupportedOperationException(""); | ||
} | ||
|
||
@Override | ||
public RenderParameters getRenderParameters() { | ||
throw new UnsupportedOperationException(""); | ||
} | ||
|
||
@Override | ||
public String getUserAgent() { | ||
throw new UnsupportedOperationException(""); | ||
} | ||
|
||
protected final Map<String, String[]> initParameters(boolean ajaxRequest) { | ||
|
||
Map<String, String[]> parameters; | ||
|
||
if (ajaxRequest) { | ||
|
||
parameters = new HashMap<String, String[]>(); | ||
parameters.put(Bridge.FACES_AJAX_PARAMETER, new String[] { "true" }); | ||
parameters = Collections.unmodifiableMap(parameters); | ||
} | ||
else { | ||
parameters = Collections.emptyMap(); | ||
} | ||
|
||
return parameters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters