From 2499942f94da8b2c86dd6ce92c1c7d35112315b4 Mon Sep 17 00:00:00 2001 From: spbolton Date: Mon, 3 Jun 2024 17:18:15 +0100 Subject: [PATCH] pre J21 changes --- bom/application/pom.xml | 10 +- core-web/pom.xml | 3 - dotCMS/pom.xml | 10 + .../java/com/liferay/util/Randomizer.java | 146 --------- .../java/com/liferay/util/StringUtil.java | 6 - .../com/dotmarketing/util/ConfigTest.java | 292 +++++------------- .../util/ContentTypeUtilTest.java | 17 +- dotcms-integration/pom.xml | 15 + .../org/elasticsearch/bootstrap/JarHell.java | 3 +- .../core-plugins/tika-plugin/pom.xml | 5 +- justfile | 10 +- nodejs-parent/pom.xml | 2 - osgi-base/core-bundles/pom.xml | 2 - parent/pom.xml | 102 +++--- reports/pom.xml | 2 - 15 files changed, 183 insertions(+), 442 deletions(-) delete mode 100644 dotCMS/src/main/java/com/liferay/util/Randomizer.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 83c1fb87a422..6570634c593c 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -26,7 +26,6 @@ 2.16.1 2.22.1 22.3.3 - 2023.09.8 @@ -59,7 +58,7 @@ com.dotcms.core.plugins com.dotcms.tika-api - ${dotcms.tika-api.version} + ${project.version} @@ -1505,7 +1504,12 @@ mockito-core 5.11.0 - + + org.mockito + mockito-junit-jupiter + 5.11.0 + test + org.hamcrest diff --git a/core-web/pom.xml b/core-web/pom.xml index e782c4864b5e..0ee8393d6d6a 100644 --- a/core-web/pom.xml +++ b/core-web/pom.xml @@ -14,9 +14,6 @@ false - 11 - ${java.version} - ${java.version} UTF-8 1.9.0 9 diff --git a/dotCMS/pom.xml b/dotCMS/pom.xml index f05a8d66c264..8f0fc7cee2c4 100644 --- a/dotCMS/pom.xml +++ b/dotCMS/pom.xml @@ -1293,6 +1293,16 @@ junit-jupiter-engine test + + org.junit.jupiter + junit-jupiter-params + test + + + org.junit.platform + junit-platform-suite + test + org.junit.vintage junit-vintage-engine diff --git a/dotCMS/src/main/java/com/liferay/util/Randomizer.java b/dotCMS/src/main/java/com/liferay/util/Randomizer.java deleted file mode 100644 index b73aa0971fa5..000000000000 --- a/dotCMS/src/main/java/com/liferay/util/Randomizer.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Copyright (c) 2000-2005 Liferay, LLC. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.liferay.util; - -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Random; -import java.util.Set; - -/** - * View Source - * - * @author Brian Wing Shun Chan - * @version $Revision: 1.8 $ - * - */ -public class Randomizer extends Random { - - public Randomizer() { - super(); - } - - public Randomizer(long seed) { - super(seed); - } - - public int[] nextInt(int n, int size) { - if (size > n) { - size = n; - } - - Set set = new LinkedHashSet(); - - for (int i = 0; i < size; i++) { - while (true) { - Integer value = Integer.valueOf(nextInt(n)); - - if (!set.contains(value)) { - set.add(value); - - break; - } - } - } - - int[] array = new int[set.size()]; - - Iterator itr = set.iterator(); - - for (int i = 0; i < array.length; i++) { - array[i] = ((Integer)itr.next()).intValue(); - } - - return array; - } - - public void randomize(char array[]) { - int length = array.length; - - for(int i = 0; i < length - 1; i++) { - int x = nextInt(length); - char y = array[i]; - - array[i] = array[i + x]; - array[i + x] = y; - - length--; - } - } - - public void randomize(int array[]) { - int length = array.length; - - for(int i = 0; i < length - 1; i++) { - int x = nextInt(length); - int y = array[i]; - - array[i] = array[i + x]; - array[i + x] = y; - - length--; - } - } - - public void randomize(List list) { - int size = list.size(); - - for(int i = 0; i <= size; i++) { - int j = nextInt(size); - Object obj = list.get(i); - - list.set(i, list.get(i + j)); - list.set(i + j, obj); - - size--; - } - } - - public void randomize(Object array[]) { - int length = array.length; - - for(int i = 0; i < length - 1; i++) { - int x = nextInt(length); - Object y = array[i]; - - array[i] = array[i + x]; - array[i + x] = y; - - length--; - } - } - - public String randomize(String s) { - if (s == null) { - return null; - } - - char[] array = s.toCharArray(); - - randomize(array); - - return new String(array); - } - -} \ No newline at end of file diff --git a/dotCMS/src/main/java/com/liferay/util/StringUtil.java b/dotCMS/src/main/java/com/liferay/util/StringUtil.java index 7d217a959f73..f0d3a4502b1a 100644 --- a/dotCMS/src/main/java/com/liferay/util/StringUtil.java +++ b/dotCMS/src/main/java/com/liferay/util/StringUtil.java @@ -205,12 +205,6 @@ public static String merge(String array[], String delimiter) { return sb.toString(); } - public static String randomize(String s) { - Randomizer r = new Randomizer(); - - return r.randomize(s); - } - public static String read(ClassLoader classLoader, String name) throws IOException { InputStream is=classLoader.getResourceAsStream(name); diff --git a/dotCMS/src/test/java/com/dotmarketing/util/ConfigTest.java b/dotCMS/src/test/java/com/dotmarketing/util/ConfigTest.java index 60dfde988f5c..df25c171b821 100644 --- a/dotCMS/src/test/java/com/dotmarketing/util/ConfigTest.java +++ b/dotCMS/src/test/java/com/dotmarketing/util/ConfigTest.java @@ -5,24 +5,23 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -import org.tuckey.web.filters.urlrewrite.Conf; +import sun.misc.Unsafe; public class ConfigTest { - private static final Map DEFAULTS = new HashMap<>(System.getenv()); private static final Map envMap = new HashMap<>(); @@ -35,293 +34,196 @@ public class ConfigTest { final static String SIMPLE_TESTING_STRING = "SIMPLE_TESTING_STRING"; final static String TESTING_VALUE = "TESTING_VALUE"; final static String[] TESTING_ARRAY = new String[]{"TESTING_VALUE"}; - final static String NO_VALUE = "NO_VALUE"; final static String DOT_TESTING_STRING_WITH_COMMA ="DOT_TESTING_STRING_WITH_COMMA"; final static String DOT_TESTING_STRING_WITH_SPACES ="DOT_TESTING_STRING_WITH_SPACES"; final static String DOT_TESTING_STRING ="DOT_TESTING_STRING"; final static String UNABLE_TO_READ_VAR="UNABLE_TO_READ_VAR"; - - /** * This method sets environmental variables that are intended for testing. - * */ private static void setTestEnvVariables() { EnvironmentVariablesService.getInstance().put(DOT_TESTING_INTEGER, String.valueOf(Integer.MAX_VALUE)) - .put(XXX_TESTING_INTEGER, String.valueOf(Integer.MIN_VALUE)) - .put(DOT_TESTING_LONG, String.valueOf(Long.MAX_VALUE)) - .put(DOT_TESTING_BOOLEAN, String.valueOf(Boolean.TRUE)) - .put(DOT_TESTING_FLOAT, String.valueOf(Float.MAX_VALUE)) - .put(DOT_TESTING_STRING_WITH_COMMA, "VALUE1,VALUE2") - .put(DOT_TESTING_STRING_WITH_SPACES, "VALUE1 VALUE2") - .put(DOT_TESTING_STRING, "VALUE_ABC") - .put(UNABLE_TO_READ_VAR, "NOPE"); - - //This forces a re-load. + .put(XXX_TESTING_INTEGER, String.valueOf(Integer.MIN_VALUE)) + .put(DOT_TESTING_LONG, String.valueOf(Long.MAX_VALUE)) + .put(DOT_TESTING_BOOLEAN, String.valueOf(Boolean.TRUE)) + .put(DOT_TESTING_FLOAT, String.valueOf(Float.MAX_VALUE)) + .put(DOT_TESTING_STRING_WITH_COMMA, "VALUE1,VALUE2") + .put(DOT_TESTING_STRING_WITH_SPACES, "VALUE1 VALUE2") + .put(DOT_TESTING_STRING, "VALUE_ABC") + .put(UNABLE_TO_READ_VAR, "NOPE"); + + // This forces a re-load. Config.props.clear(); Config.initializeConfig(); } - - @Test public void testing_string_with_comma() { - String value = Config.getStringProperty("TESTING_STRING_WITH_COMMA"); - assert(value.equals(Config.getStringProperty("testing.String.with_comma"))); - - + assertEquals(value, Config.getStringProperty("testing.String.with_comma")); } - /** - * Method to rest: {@link org.apache.commons.configuration.PropertiesConfiguration#addProperty(String, Object)} - * Given Scenario: We add several properties under the same key to demo that the internal method addProperty generates an array list - * Expected result: The property now holds an array. - */ @Test public void Test_Multiple_Calls_To_AddProperty_On_The_Same_Key() { + Config.props.addProperty("anyKey", "anyValue"); + assertEquals("anyValue", Config.props.getProperty("anyKey")); - Config.props.addProperty("anyKey","anyValue"); - assertEquals ("anyValue",Config.props.getProperty("anyKey")); - - Config.props.addProperty("anyKey","anyValue"); + Config.props.addProperty("anyKey", "anyValue"); final List values1 = Arrays.asList("anyValue", "anyValue"); final Object property1 = Config.props.getProperty("anyKey"); final boolean equals1 = values1.equals(property1); assertTrue(equals1); - Config.props.addProperty("anyKey","anyValue"); + Config.props.addProperty("anyKey", "anyValue"); final List values2 = Arrays.asList("anyValue", "anyValue", "anyValue"); final Object property2 = Config.props.getProperty("anyKey"); final boolean equals2 = values2.equals(property2); assertTrue(equals2); } - /** - * Method to rest: {@link Config#getStringProperty(String)} - * Given Scenario: We set an environment prop that starts with DOT_ and certain value. Lets say X then we test getting that value through the property name that does not stat with such prefix. - * Expected result: We should get the values set to the env variable since it overrides the original property. - */ @Test public void Test_Add_Env_Prop_Then_Test_Read_Value() { final String propertyName = "fictional_property"; - // Here we need to set the original property - // as we are testing overriding it with the "DOT_" env variable - // Otherwise our setProperty will update as a configOverride and we - // will not see the change of the env variable - Config.props.setProperty(propertyName,"var"); + Config.props.setProperty(propertyName, "var"); final String fictionalProperty = Config.getStringProperty(propertyName); - assertEquals("var",fictionalProperty); + assertEquals("var", fictionalProperty); EnvironmentVariablesService.getInstance().put("DOT_FICTIONAL_PROPERTY", "foo"); - Config.props.clear(); //force props reload + Config.props.clear(); // force props reload final String fictionalPropertyOverride = Config.getStringProperty(propertyName); - assertEquals("foo",fictionalPropertyOverride); + assertEquals("foo", fictionalPropertyOverride); } @Test public void testing_null_returns() { - String test = Config.getStringProperty(SIMPLE_TESTING_STRING, null); assertNull(test); - - } @Test public void testing_default_returns() { - - String test = Config.getStringProperty(SIMPLE_TESTING_STRING, TESTING_VALUE); - assertEquals(test, TESTING_VALUE); - - + assertEquals(TESTING_VALUE, test); } @Test public void testing_notfound_string_returns() { - - - assert(Config.getStringProperty("no-property") ==null); - - - - + assertNull(Config.getStringProperty("no-property")); } - - @Test public void testing_notfound_int_returns() { - try { Config.getIntProperty("no-property"); assert(false); + } catch (Exception e) { + assertTrue(e instanceof NoSuchElementException); } - catch(Exception e) { - assert(e instanceof NoSuchElementException); - - } - - } @Test public void testing_notfound_float_returns() { - try { Config.getFloatProperty("no-property"); - assert(false); - } - catch(Exception e) { - assert(e instanceof NoSuchElementException); - + fail(); + } catch (Exception e) { + assertTrue(e instanceof NoSuchElementException); } - - } - @Test - public void testing_notfound_booean_returns() { - + public void testing_notfound_boolean_returns() { try { Config.getBooleanProperty("no-property"); - assert(false); + Assert.fail("Expected a NoSuchElementException to be thrown"); + } catch (Exception e) { + Assert.assertTrue("Exception should be of type NoSuchElementException", + e instanceof NoSuchElementException); } - catch(Exception e) { - assert(e instanceof NoSuchElementException); - - } - - } - - @Test public void test_get_integer_from_env() { + int value = Config.getIntProperty("no-property", -99); + assertEquals(-99, value); + value = Config.getIntProperty(XXX_TESTING_INTEGER, -99); + assertEquals(-99, value); - int value =Config.getIntProperty("no-property", -99); - assert(value==-99); - - // this should not work, as we prefix DOT_ to the env variable lookup - value =Config.getIntProperty(XXX_TESTING_INTEGER, -99); - assert(value==-99); - - // we should get back Integer.MAX_VALUE, as this get transformed into DOT_TESTING_INTEGER - value =Config.getIntProperty("testing.integer", -99); - assert(value==Integer.MAX_VALUE); + value = Config.getIntProperty("testing.integer", -99); + assertEquals(Integer.MAX_VALUE, value); } @Test public void test_get_float_from_env() { + float value = Config.getFloatProperty("no-property", 3.14f); + assertEquals(3.14f, value, 0.0); + value = Config.getFloatProperty(XXX_TESTING_INTEGER, 3.14f); + assertEquals(3.14f, value, 0.0); - float value =Config.getFloatProperty("no-property", 3.14f); - assert(value==3.14f); - - // this should not work, as we prefix DOT_ to the env variable lookup - value =Config.getFloatProperty(XXX_TESTING_INTEGER, 3.14f); - assert(value==3.14f); - - // we should get back Integer.MAX_VALUE, not the default - value =Config.getFloatProperty("testing_float",-1f); - assert(value==Float.MAX_VALUE); + value = Config.getFloatProperty("testing_float", -1f); + assertEquals(Float.MAX_VALUE, value, 0.0); } - @Test public void test_get_string_from_env() { + String value = Config.getStringProperty("no-property", TESTING_VALUE); + assertEquals(TESTING_VALUE, value); + value = Config.getStringProperty("testing.integer", TESTING_VALUE); + assertEquals(value, String.valueOf(Integer.MAX_VALUE)); - - String value =Config.getStringProperty("no-property", TESTING_VALUE); - assert(value.equals(TESTING_VALUE)); - - // this should work, as we prefix DOT_ to the env variable lookup - value =Config.getStringProperty("testing.integer", TESTING_VALUE); - assert(value.equals(String.valueOf(Integer.MAX_VALUE))); - - // we should get back VALUE_ABC - value =Config.getStringProperty("testing.string","VALUE_ABC"); - + value = Config.getStringProperty("testing.string", "VALUE_ABC"); + assertEquals("VALUE_ABC", value); } @Test public void test_get_string_array_from_env() { - - - - String[] value =Config.getStringArrayProperty("no-property", TESTING_ARRAY); + String[] value = Config.getStringArrayProperty("no-property", TESTING_ARRAY); assertArrayEquals(value, TESTING_ARRAY); - // this should work, as we prefix DOT_ to the env variable lookup - value =Config.getStringArrayProperty("testing_string_with_comma"); - assert(value.length==2); - assert(value[1].equals("VALUE2")); + value = Config.getStringArrayProperty("testing_string_with_comma"); + assertEquals(2, value.length); + assertEquals("VALUE2", value[1]); - String notArray =Config.getStringProperty("testing_string_with_comma"); - assertEquals(notArray, "VALUE1,VALUE2"); + String notArray = Config.getStringProperty("testing_string_with_comma"); + assertEquals("VALUE1,VALUE2", notArray); } - /** - * Method to test {@link Config#getBooleanProperty(String, boolean)} - * Here we test that the "same" property seen as an environmental var overrides the other regular property already set in the map - */ @Test @Ignore("Logic needs updating when initial config is set by env vars in test ") - public void Test_Env_Prop_Overrides_Regular_Prop(){ - + public void Test_Env_Prop_Overrides_Regular_Prop() { + final String DOT_MY_BOOLEAN_PROPERTY = "DOT_MY_BOOLEAN_PROPERTY"; + final String MY_BOOLEAN_PROPERTY = "my.boolean.property"; - final String DOT_MY_BOOLEAN_PROPERTY = "DOT_MY_BOOLEAN_PROPERTY"; - final String MY_BOOLEAN_PROPERTY = "my.boolean.property"; + Config.setProperty(DOT_MY_BOOLEAN_PROPERTY, false); + Config.setProperty(MY_BOOLEAN_PROPERTY, true); - //Now lets suppose the two properties exits in the Config - Config.setProperty(DOT_MY_BOOLEAN_PROPERTY, false); - Config.setProperty(MY_BOOLEAN_PROPERTY, true); - //But one must take precedence over the other and that's the one that starts with dot. + assertFalse(Config.getBooleanProperty(DOT_MY_BOOLEAN_PROPERTY, true)); + assertFalse(Config.getBooleanProperty(MY_BOOLEAN_PROPERTY, true)); - //if I request the dot prop one should easily expect the value it was initialized with - assertFalse(Config.getBooleanProperty(DOT_MY_BOOLEAN_PROPERTY, true)); - //if I request the regular non-dot prop we should still get the value assigned to the dot prop because it overrides it - assertFalse(Config.getBooleanProperty(MY_BOOLEAN_PROPERTY, true)); - - //The second I get rid of the DOT property now I should get the original regular prop - Config.setProperty(DOT_MY_BOOLEAN_PROPERTY, null); - assertTrue(Config.getBooleanProperty(MY_BOOLEAN_PROPERTY, false)); + Config.setProperty(DOT_MY_BOOLEAN_PROPERTY, null); + assertTrue(Config.getBooleanProperty(MY_BOOLEAN_PROPERTY, false)); } - /** - * Method to test {@link Config#isKeyEnvBased(String)} - * Given a property name verify if it belongs to the properties set by environment variables, that is with the - * 'DOT_' prefix. - */ @Test public void test_isKeyEnvBased() { final String DOT_MY_ENV_VAR_PROPERTY = "DOT_MY_ENV_VAR_PROPERTY"; final String MY_ENV_VAR_PROPERTY = "my.env.var.property"; - // no sight of property assertFalse(Config.isKeyEnvBased(MY_ENV_VAR_PROPERTY)); - // add empty property Config.setProperty(DOT_MY_ENV_VAR_PROPERTY, null); assertFalse(Config.isKeyEnvBased(MY_ENV_VAR_PROPERTY)); - // add property with actual value Config.setProperty(DOT_MY_ENV_VAR_PROPERTY, "not null"); assertTrue(Config.isKeyEnvBased(MY_ENV_VAR_PROPERTY)); } - /** - * Method to test {@link Config#envKey(String)} - * Checks if the method is converting the key to env key successfully. - */ @Test public void test_envKey_keyWithoutPrefix_returnsEnvKey() { final String MY_ENV_VAR_PROPERTY = "my.env.var.property"; @@ -331,10 +233,6 @@ public void test_envKey_keyWithoutPrefix_returnsEnvKey() { assertFalse(convertedProperty.contains(".")); } - /** - * Method to test {@link Config#envKey(String)} - * If the key is already an Env Key it doesn't need to be converted. - */ @Test public void test_envKey_keyWithPrefix_returnsEnvKey() { final String DOT_MY_ENV_VAR_PROPERTY = "DOT_MY_ENV_VAR_PROPERTY"; @@ -345,67 +243,43 @@ public void test_envKey_keyWithPrefix_returnsEnvKey() { assertFalse(convertedProperty.contains("DOT_DOT_")); } - /** - * Method to test {@link Config#subsetContainsAsList(String)} - * Pull out all the properties that contains the given string, in this case testSubset. - */ @Test - public void test_subsetContainsAsList(){ - Config.props.addProperty("DOT_testSubset_anyKey","anyValue"); - Config.props.addProperty("testSubset.anyKey","anyValue"); + public void test_subsetContainsAsList() { + Config.props.addProperty("DOT_testSubset_anyKey", "anyValue"); + Config.props.addProperty("testSubset.anyKey", "anyValue"); final List properties = Config.subsetContainsAsList("testSubset"); - assertTrue(properties.size()>=2); + assertTrue(properties.size() >= 2); assertTrue(properties.contains("DOT_testSubset_anyKey")); assertTrue(properties.contains("testSubset.anyKey")); } - /* - * - * Restore default variables for each test - */ @AfterClass public static void resetMap() { envMap.clear(); envMap.putAll(DEFAULTS); } - - - - - @BeforeClass public static void accessFields() throws Exception { - envMap.putAll(DEFAULTS); Class clazz = Class.forName("java.lang.ProcessEnvironment"); - //Field theCaseInsensitiveEnvironmentField = clazz.getDeclaredField("theCaseInsensitiveEnvironment"); Field theUnmodifiableEnvironmentField = clazz.getDeclaredField("theUnmodifiableEnvironment"); - //removeStaticFinalAndSetValue(theCaseInsensitiveEnvironmentField, envMap); - removeStaticFinalAndSetValue(theUnmodifiableEnvironmentField, envMap); + removeStaticFinalAndSetValue(theUnmodifiableEnvironmentField); setTestEnvVariables(); } + private static void removeStaticFinalAndSetValue(Field field) throws Exception { + // Obtain the Unsafe instance + Field theUnsafeField = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafeField.setAccessible(true); + Unsafe unsafe = (Unsafe) theUnsafeField.get(null); + // Make the field accessible and remove the final modifier + long fieldOffset = unsafe.staticFieldOffset(field); + Object staticFieldBase = unsafe.staticFieldBase(field); - private static void removeStaticFinalAndSetValue(Field field, Object newValue) throws Exception { - field.setAccessible(true); - Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class); - getDeclaredFields0.setAccessible(true); - Field[] fields = (Field[]) getDeclaredFields0.invoke(Field.class, false); - Field modifiersField = null; - for (Field each : fields) { - if ("modifiers".equals(each.getName())) { - modifiersField = each; - break; - } - } - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, newValue); + // Use Unsafe to update the field value + unsafe.putObject(staticFieldBase, fieldOffset, ConfigTest.envMap); } - - - -} +} \ No newline at end of file diff --git a/dotCMS/src/test/java/com/dotmarketing/util/ContentTypeUtilTest.java b/dotCMS/src/test/java/com/dotmarketing/util/ContentTypeUtilTest.java index 25661b560d86..4eba82b8abbf 100644 --- a/dotCMS/src/test/java/com/dotmarketing/util/ContentTypeUtilTest.java +++ b/dotCMS/src/test/java/com/dotmarketing/util/ContentTypeUtilTest.java @@ -21,6 +21,9 @@ import com.liferay.portal.util.WebKeys; import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.junit.Test; @@ -75,7 +78,17 @@ public void testGetActionUrl() throws DotDataException { String actionUrl = contentTypeUtil.getActionUrl(new StructureTransformer(structure).from()); System.out.println("actionUrl = " + actionUrl); - assertEquals("The expected actionUrl is not the same as the one generated by the Util.", expected, actionUrl); + + // Parse the URLs into maps of query parameters + Map expectedParams = parseQueryParams(expected); + Map actualParams = parseQueryParams(actionUrl); + + assertEquals("The expected actionUrl parameters are not the same as the ones generated by the Util.", expectedParams, actualParams); } -} + private Map parseQueryParams(String url) { + return Stream.of(url.substring(url.indexOf('?') + 1).split("&")) + .map(param -> param.split("=")) + .collect(Collectors.toMap(param -> param[0], param -> param.length > 1 ? param[1] : "")); + } +} \ No newline at end of file diff --git a/dotcms-integration/pom.xml b/dotcms-integration/pom.xml index b0c3f53de380..01f7832db14e 100644 --- a/dotcms-integration/pom.xml +++ b/dotcms-integration/pom.xml @@ -163,6 +163,11 @@ mockito-core test + + org.mockito + mockito-junit-jupiter + test + com.tngtech.junit.dataprovider junit4-dataprovider @@ -183,6 +188,16 @@ junit-jupiter-engine test + + org.junit.jupiter + junit-jupiter-params + test + + + org.junit.platform + junit-platform-suite + test + org.junit.vintage junit-vintage-engine diff --git a/dotcms-integration/src/test/java/org/elasticsearch/bootstrap/JarHell.java b/dotcms-integration/src/test/java/org/elasticsearch/bootstrap/JarHell.java index 882cfa16f8ef..e68df7b9bf49 100644 --- a/dotcms-integration/src/test/java/org/elasticsearch/bootstrap/JarHell.java +++ b/dotcms-integration/src/test/java/org/elasticsearch/bootstrap/JarHell.java @@ -1,6 +1,5 @@ package org.elasticsearch.bootstrap; -import com.google.common.collect.ImmutableSet; import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; @@ -13,5 +12,5 @@ public static void checkJarHell(URL urls[]) throws Exception {} public static void checkJarHell(Set urls) throws URISyntaxException, IOException{} public static void checkVersionFormat(String targetVersion) {} public static void checkJavaVersion(String resource, String targetVersion) {} - public static Set parseClassPath() {return ImmutableSet.of();} + public static Set parseClassPath() {return Set.of();} } diff --git a/independent-projects/core-plugins/tika-plugin/pom.xml b/independent-projects/core-plugins/tika-plugin/pom.xml index 2af5ef65c32a..13a0d9fa661e 100644 --- a/independent-projects/core-plugins/tika-plugin/pom.xml +++ b/independent-projects/core-plugins/tika-plugin/pom.xml @@ -9,22 +9,19 @@ com.dotcms.tika bundle - 11 - 11 UTF-8 5.1.8 8.0.0 7.0.0 2.8.0 true - ${project.version} com.dotcms.core.plugins com.dotcms.tika-api - ${tika.api.version} + ${project.version} diff --git a/justfile b/justfile index 22e1dfa4992c..925267bb8a61 100644 --- a/justfile +++ b/justfile @@ -111,9 +111,17 @@ test-integration: test-integration-debug-suspend: ./mvnw -pl :dotcms-integration verify -Dcoreit.test.skip=false -Pdebug-suspend +# Just rebuild core and its deps without docker, e.g. pickup changes for it tests +build-core-with-deps: + ./mvnw install -pl :dotcms-core --am -DskipTests -Ddocker.skip=true + +# Just rebuild core without docker, e.g. pickup changes for it tests +build-core-only: + ./mvnw install -pl :dotcms-core -DskipTests -Ddocker.skip=true + # Prepares the environment for running integration tests in an IDE test-integration-ide: - ./mvnw -pl :dotcms-integration -Pdocker-start -Dcoreit.test.skip=false + ./mvnw -pl :dotcms-integration pre-integration-test -Dcoreit.test.skip=false # Stops integration test services test-integration-stop: diff --git a/nodejs-parent/pom.xml b/nodejs-parent/pom.xml index 95e52815a569..48db0666c87c 100644 --- a/nodejs-parent/pom.xml +++ b/nodejs-parent/pom.xml @@ -10,8 +10,6 @@ dotcms-nodejs-parent pom - 11 - 11 UTF-8 v18.18.2 v1.22.19 diff --git a/osgi-base/core-bundles/pom.xml b/osgi-base/core-bundles/pom.xml index b38b84f3aa13..684f1b8a9286 100644 --- a/osgi-base/core-bundles/pom.xml +++ b/osgi-base/core-bundles/pom.xml @@ -13,8 +13,6 @@ false - 11 - 11 diff --git a/parent/pom.xml b/parent/pom.xml index 5ac27f4933de..a88acabe1568 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -15,6 +15,43 @@ oss false + + 11 + 11 + 11 + 11 + ${maven.compiler.source} + ${maven.compiler.target} + + --illegal-access=deny + --add-modules java.se + --add-exports java.base/jdk.internal.ref=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.nio=ALL-UNNAMED + --add-opens java.base/sun.nio.ch=ALL-UNNAMED + --add-opens java.management/sun.management=ALL-UNNAMED + --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED + --add-opens java.base/java.lang.ref=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/java.nio=ALL-UNNAMED + --add-opens java.base/java.nio.charset=ALL-UNNAMED + --add-opens java.base/java.time=ALL-UNNAMED + --add-opens java.base/java.time.zone=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.util.concurrent=ALL-UNNAMED + --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED + --add-opens java.base/java.util.regex=ALL-UNNAMED + --add-opens java.base/javax.crypto.spec=ALL-UNNAMED + --add-opens java.management/javax.management=ALL-UNNAMED + --add-opens java.base/sun.nio.cs=ALL-UNNAMED + --add-opens java.base/sun.util.calendar=ALL-UNNAMED + --add-opens java.base/sun.util.locale=ALL-UNNAMED + + false 9.0.85 @@ -45,7 +82,7 @@ WARN 1.2.3 - 11 + -Xdoclint:none --allow-script-in-comments ${maven.compiler.argument.source} ${maven.compiler.source} @@ -53,11 +90,7 @@ ${maven.compiler.testSource} ${maven.compiler.testTarget} true - 11 - 11 - 11 - ${maven.compiler.source} - ${maven.compiler.target} + 3.8.1 UTF-8 UTF-8 @@ -130,7 +163,7 @@ false ${skipTests} 1 - 2.9.0 + 2.10.1 dotcms/dotcms-test ${project.version} @@ -652,33 +685,7 @@ files and hence the coverage report. --> @{argLine} -Xmx1024m - --illegal-access=deny - --add-modules java.se - --add-exports java.base/jdk.internal.ref=ALL-UNNAMED - --add-opens java.base/java.lang=ALL-UNNAMED - --add-opens java.base/java.nio=ALL-UNNAMED - --add-opens java.base/sun.nio.ch=ALL-UNNAMED - --add-opens java.management/sun.management=ALL-UNNAMED - --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED - --add-opens java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED - --add-opens java.base/java.lang.ref=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.base/java.net=ALL-UNNAMED - --add-opens java.base/java.nio=ALL-UNNAMED - --add-opens java.base/java.nio.charset=ALL-UNNAMED - --add-opens java.base/java.time=ALL-UNNAMED - --add-opens java.base/java.time.zone=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED - --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED - --add-opens java.base/java.util.regex=ALL-UNNAMED - --add-opens java.base/javax.crypto.spec=ALL-UNNAMED - --add-opens java.management/javax.management=ALL-UNNAMED - --add-opens java.base/sun.nio.cs=ALL-UNNAMED - --add-opens java.base/sun.util.calendar=ALL-UNNAMED - --add-opens java.base/sun.util.locale=ALL-UNNAMED + ${java.module.args} false @@ -830,32 +837,7 @@ true @{argLine} -Xmx1024m --illegal-access=deny - --add-modules java.se - --add-exports java.base/jdk.internal.ref=ALL-UNNAMED - --add-opens java.base/java.lang=ALL-UNNAMED - --add-opens java.base/java.nio=ALL-UNNAMED - --add-opens java.base/sun.nio.ch=ALL-UNNAMED - --add-opens java.management/sun.management=ALL-UNNAMED - --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED - --add-opens java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED - --add-opens java.base/java.lang.ref=ALL-UNNAMED - --add-opens java.base/java.lang.reflect=ALL-UNNAMED - --add-opens java.base/java.net=ALL-UNNAMED - --add-opens java.base/java.nio=ALL-UNNAMED - --add-opens java.base/java.nio.charset=ALL-UNNAMED - --add-opens java.base/java.time=ALL-UNNAMED - --add-opens java.base/java.time.zone=ALL-UNNAMED - --add-opens java.base/java.util=ALL-UNNAMED - --add-opens java.base/java.util.concurrent=ALL-UNNAMED - --add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED - --add-opens java.base/java.util.regex=ALL-UNNAMED - --add-opens java.base/javax.crypto.spec=ALL-UNNAMED - --add-opens java.management/javax.management=ALL-UNNAMED - --add-opens java.base/sun.nio.cs=ALL-UNNAMED - --add-opens java.base/sun.util.calendar=ALL-UNNAMED - --add-opens java.base/sun.util.locale=ALL-UNNAMED + ${java.module.args} diff --git a/reports/pom.xml b/reports/pom.xml index 4fa2b3337ef8..d7a9e52cbf9c 100644 --- a/reports/pom.xml +++ b/reports/pom.xml @@ -13,8 +13,6 @@ dotcms-reports - 11 - 11 UTF-8 verify