You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2021/02/25 09:06:56 UTC
[unomi] branch unomi-1.5.x updated: I test for update properties
action (#257)
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/unomi-1.5.x by this push:
new 5ea37d2 I test for update properties action (#257)
5ea37d2 is described below
commit 5ea37d2c1056b629daac8c1e7972935368df2703
Author: kevan Jahanshahi <ke...@jahia.com>
AuthorDate: Thu Feb 25 10:02:06 2021 +0100
I test for update properties action (#257)
* UNOMI-418: provide Integration test for recent fix on UpdatePropertiesAction
* UNOMI-418: make all test waiting for unomi full startup for more stability
---
.../test/java/org/apache/unomi/itests/BaseIT.java | 23 ++++++++++++++++++++++
.../test/java/org/apache/unomi/itests/BasicIT.java | 10 ----------
.../unomi/itests/PropertiesUpdateActionIT.java | 13 +++++++++---
.../java/org/apache/unomi/itests/SecurityIT.java | 10 ----------
.../java/org/apache/unomi/itests/SegmentIT.java | 9 ---------
5 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index bc2df79..a3d1d27 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -22,18 +22,26 @@ import org.apache.commons.io.IOUtils;
import org.apache.unomi.api.Item;
import org.apache.unomi.api.conditions.Condition;
import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.lifecycle.BundleWatcher;
import org.apache.unomi.persistence.spi.CustomObjectMapper;
import org.apache.unomi.persistence.spi.PersistenceService;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.options.extra.VMOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerSuite;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.io.File;
@@ -54,7 +62,11 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
*
* @author kevan
*/
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerSuite.class)
public abstract class BaseIT {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(BaseIT.class);
protected static final String HTTP_PORT = "8181";
protected static final String URL = "http://localhost:" + HTTP_PORT;
@@ -72,6 +84,17 @@ public abstract class BaseIT {
@Inject
protected BundleContext bundleContext;
+ @Inject @Filter(timeout = 600000)
+ protected BundleWatcher bundleWatcher;
+
+ @Before
+ public void waitForStartup() throws InterruptedException {
+ while (!bundleWatcher.isStartupComplete()) {
+ LOGGER.info("Waiting for startup to complete...");
+ Thread.sleep(1000);
+ }
+ }
+
protected void removeItems(final Class<? extends Item> ...classes) throws InterruptedException {
Condition condition = new Condition(definitionsService.getConditionType("matchAllCondition"));
for (Class<? extends Item> aClass : classes) {
diff --git a/itests/src/test/java/org/apache/unomi/itests/BasicIT.java b/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
index 033b762..a47910e 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BasicIT.java
@@ -92,16 +92,6 @@ public class BasicIT extends BaseIT {
protected ProfileService profileService;
@Inject @Filter(timeout = 600000)
protected DefinitionsService definitionsService;
- @Inject @Filter(timeout = 600000)
- protected BundleWatcher bundleWatcher;
-
- @Before
- public void setUp() throws InterruptedException {
- while (!bundleWatcher.isStartupComplete()) {
- LOGGER.info("Waiting for startup to complete...");
- Thread.sleep(1000);
- }
- }
@Test
public void testContextJS() throws IOException {
diff --git a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
index f1b6304..f161632 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
@@ -58,6 +58,9 @@ public class PropertiesUpdateActionIT extends BaseIT {
public void setUp() throws IOException, InterruptedException {
Profile profile = new Profile();
profile.setItemId(PROFILE_TEST_ID);
+ profile.setProperties(new HashMap<>());
+ profile.setProperty("lastName", "Jose"); // property that have a propertyType registered in the system
+ profile.setProperty("prop4", "New property 4"); // property that do not have a propertyType registered in the system
profileService.save(profile);
LOGGER.info("Profile saved with ID [{}].", profile.getItemId());
@@ -124,6 +127,8 @@ public class PropertiesUpdateActionIT extends BaseIT {
propertyToAdd.put("properties.prop1", "New property 1");
propertyToAdd.put("properties.prop2", "New property 2");
propertyToAdd.put("properties.prop3", "New property 3");
+ propertyToAdd.put("properties.prop4", "Updated property 4");
+ propertyToAdd.put("properties.lastName", "Michel");
updateProperties.setProperty(UpdatePropertiesAction.PROPS_TO_ADD, propertyToAdd);
updateProperties.setProperty(UpdatePropertiesAction.TARGET_ID_KEY, PROFILE_TEST_ID);
@@ -133,9 +138,11 @@ public class PropertiesUpdateActionIT extends BaseIT {
refreshPersistence();
profile = profileService.load(PROFILE_TEST_ID);
- Assert.assertEquals("New property 1", profile.getProperty("prop1"));
- Assert.assertEquals("New property 2", profile.getProperty("prop2"));
- Assert.assertEquals("New property 3", profile.getProperty("prop3"));
+ Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 1", profile.getProperty("prop1"));
+ Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 2", profile.getProperty("prop2"));
+ Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 3", profile.getProperty("prop3"));
+ Assert.assertEquals("Props_to_add should not override existing prop", "New property 4", profile.getProperty("prop4"));
+ Assert.assertEquals("Props_to_add should not override existing prop", "Jose", profile.getProperty("lastName"));
}
@Test
diff --git a/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java b/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
index b90e953..f423622 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
@@ -49,22 +49,12 @@ import static org.junit.Assert.assertFalse;
@ExamReactorStrategy(PerSuite.class)
public class SecurityIT extends BaseIT {
- private final static Logger LOGGER = LoggerFactory.getLogger(SecurityIT.class);
-
private static final String SESSION_ID = "vuln-session-id";
private ObjectMapper objectMapper;
- @Inject
- @Filter(timeout = 600000)
- protected BundleWatcher bundleWatcher;
-
@Before
public void setUp() throws InterruptedException {
- while (!bundleWatcher.isStartupComplete()) {
- LOGGER.info("Waiting for startup to complete...");
- Thread.sleep(1000);
- }
objectMapper = CustomObjectMapper.getObjectMapper();
}
diff --git a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
index 2b63ed8..fceb70c 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
@@ -22,7 +22,6 @@ import org.apache.unomi.api.conditions.Condition;
import org.apache.unomi.api.segments.Segment;
import org.apache.unomi.api.services.SegmentService;
import org.apache.unomi.api.exceptions.BadSegmentConditionException;
-import org.apache.unomi.lifecycle.BundleWatcher;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -47,16 +46,8 @@ public class SegmentIT extends BaseIT {
@Filter(timeout = 600000)
protected SegmentService segmentService;
-
- @Inject @Filter(timeout = 600000)
- protected BundleWatcher bundleWatcher;
-
@Before
public void setUp() throws InterruptedException {
- while (!bundleWatcher.isStartupComplete()) {
- LOGGER.info("Waiting for startup to complete...");
- Thread.sleep(1000);
- }
removeItems(Segment.class);
}