Skip to content

Commit 0231837

Browse files
dantewangbrianchandotcom
authored andcommitted
LPS-144246 Fix test: SessionClicks reads portal properties as constants at class initialization, so the test cases must run in new env.
1 parent 1089be4 commit 0231837

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

portal-impl/test/unit/com/liferay/portal/kernel/util/SessionClicksTest.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import com.liferay.portal.kernel.portlet.PortalPreferences;
1818
import com.liferay.portal.kernel.portlet.PortletPreferencesFactory;
1919
import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
20+
import com.liferay.portal.kernel.test.rule.NewEnv;
21+
import com.liferay.portal.kernel.test.util.PropsTestUtil;
2022
import com.liferay.portal.kernel.test.util.RandomTestUtil;
2123
import com.liferay.portal.test.rule.LiferayUnitTestRule;
22-
import com.liferay.portal.test.rule.PortalProps;
2324
import com.liferay.portlet.PortalPreferencesImpl;
2425

2526
import java.util.List;
@@ -38,18 +39,25 @@
3839
/**
3940
* @author Dante Wang
4041
*/
42+
@NewEnv(type = NewEnv.Type.CLASSLOADER)
4143
public class SessionClicksTest {
4244

4345
@ClassRule
4446
@Rule
4547
public static final LiferayUnitTestRule liferayUnitTestRule =
4648
LiferayUnitTestRule.INSTANCE;
4749

48-
@PortalProps(
49-
properties = PropsKeys.SESSION_CLICKS_MAX_ALLOWED_VALUES + "=" + _MAX_ALLOWED_VALUES
50-
)
5150
@Test
5251
public void testPutMaxAllowedValues() {
52+
PropsTestUtil.setProps(
53+
HashMapBuilder.<String, Object>put(
54+
PropsKeys.SESSION_CLICKS_MAX_ALLOWED_VALUES,
55+
String.valueOf(_MAX_ALLOWED_VALUES)
56+
).put(
57+
PropsKeys.SESSION_CLICKS_MAX_SIZE_TERMS,
58+
String.valueOf(Integer.MAX_VALUE)
59+
).build());
60+
5361
PortalPreferences portalPreferences = new PortalPreferencesImpl();
5462

5563
PortletPreferencesFactoryUtil portletPreferencesFactoryUtil =
@@ -106,11 +114,17 @@ public void testPutMaxAllowedValues() {
106114
attributeNames.size());
107115
}
108116

109-
@PortalProps(
110-
properties = PropsKeys.SESSION_CLICKS_MAX_SIZE_TERMS + "=" + _MAX_SIZE_TERMS
111-
)
112117
@Test
113118
public void testPutMaxSizeTerms() {
119+
PropsTestUtil.setProps(
120+
HashMapBuilder.<String, Object>put(
121+
PropsKeys.SESSION_CLICKS_MAX_ALLOWED_VALUES,
122+
String.valueOf(Integer.MAX_VALUE)
123+
).put(
124+
PropsKeys.SESSION_CLICKS_MAX_SIZE_TERMS,
125+
String.valueOf(_MAX_SIZE_TERMS)
126+
).build());
127+
114128
HttpSession httpSession = new MockHttpSession();
115129

116130
String key = RandomTestUtil.randomString(_MAX_SIZE_TERMS - 1);

0 commit comments

Comments
 (0)