You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2019/10/02 06:14:05 UTC
[isis] branch v2 updated: ISIS-2158: config-beans: adding test case
for 'ConnectionURL'
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new 571ee25 ISIS-2158: config-beans: adding test case for 'ConnectionURL'
571ee25 is described below
commit 571ee2509f95772d9ade4514dc48ad93a25973a3
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Oct 2 08:13:55 2019 +0200
ISIS-2158: config-beans: adding test case for 'ConnectionURL'
---
.../java/org/apache/isis/config/IsisPresets.java | 4 ++
.../presets/H2InMemory_withUniqueSchema.properties | 22 +++++++++++
.../testdomain/conf/Configuration_usingJdo.java | 2 +-
.../isis/testdomain/config/FooProperties.java | 5 +++
.../org/apache/isis/testdomain/config/FooTest.java | 15 +++++++-
.../publishing/PublisherServiceTest.java | 45 +++++++++++++---------
6 files changed, 71 insertions(+), 22 deletions(-)
diff --git a/core/config/src/main/java/org/apache/isis/config/IsisPresets.java b/core/config/src/main/java/org/apache/isis/config/IsisPresets.java
index 81a93e9..4b9711c 100644
--- a/core/config/src/main/java/org/apache/isis/config/IsisPresets.java
+++ b/core/config/src/main/java/org/apache/isis/config/IsisPresets.java
@@ -29,6 +29,10 @@ public final class IsisPresets {
public static final String NoTranslations = "classpath:/presets/NoTranslations.properties";
public static final String H2InMemory = "classpath:/presets/H2InMemory.properties";
+
+ /** randomized (unique) database name, eg. to allow for concurrent testing */
+ public static final String H2InMemory_withUniqueSchema = "classpath:/presets/H2InMemory_withUniqueSchema.properties";
+
public static final String HsqlDbInMemory = "classpath:/presets/HsqlDbInMemory.properties";
public static final String DataNucleusAutoCreate = "classpath:/presets/DataNucleusAutoCreate.properties";
diff --git a/core/config/src/main/resources/presets/H2InMemory_withUniqueSchema.properties b/core/config/src/main/resources/presets/H2InMemory_withUniqueSchema.properties
new file mode 100644
index 0000000..82df5d8
--- /dev/null
+++ b/core/config/src/main/resources/presets/H2InMemory_withUniqueSchema.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+
+isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionURL = jdbc:h2:mem:t${random.long}
+#jdbc:h2:mem:test_${random.uuid}
+isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionDriverName = org.h2.Driver
+isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionUserName = sa
+isis.persistor.datanucleus.impl.javax.jdo.option.ConnectionPassword =
\ No newline at end of file
diff --git a/examples/smoketests/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJdo.java b/examples/smoketests/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJdo.java
index 6bd9065..d59544d 100644
--- a/examples/smoketests/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJdo.java
+++ b/examples/smoketests/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJdo.java
@@ -49,7 +49,7 @@ import org.apache.isis.testdomain.jdo.JdoTestDomainModule;
@PropertySources({
@PropertySource("classpath:/org/apache/isis/testdomain/conf/isis-non-changing.properties"),
@PropertySource("classpath:/org/apache/isis/testdomain/jdo/isis-persistence.properties"),
- @PropertySource(IsisPresets.H2InMemory),
+ @PropertySource(IsisPresets.H2InMemory_withUniqueSchema),
@PropertySource(IsisPresets.NoTranslations),
})
public class Configuration_usingJdo {
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooProperties.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooProperties.java
index 2ae6452..2fd0e72 100644
--- a/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooProperties.java
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooProperties.java
@@ -18,6 +18,8 @@
*/
package org.apache.isis.testdomain.config;
+import java.util.UUID;
+
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
@@ -27,5 +29,8 @@ import lombok.Data;
class FooProperties {
private boolean flag = false;
+ private UUID uuid;
+ private String randomSchema;
+ private String connectionURL;
}
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooTest.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooTest.java
index 0d151c2..bbac121 100644
--- a/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooTest.java
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/config/FooTest.java
@@ -37,10 +37,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
},
properties = {
"logging.config=log4j2-test.xml",
- "foo.flag=true"
+
+ "foo.flag=true",
+ "foo.uuid=${random.uuid}",
+ "foo.random-schema=test_${random.uuid}",
+ "foo.ConnectionURL=jdbc:h2:mem:test"
})
@EnableConfigurationProperties(FooProperties.class)
-public class FooTest {
+class FooTest {
@Configuration
static class Setup {
@@ -53,6 +57,13 @@ public class FooTest {
void foo() {
assertNotNull(foo);
assertTrue(foo.isFlag());
+
+ assertNotNull(foo.getUuid());
+ assertNotNull(foo.getRandomSchema());
+ assertNotNull(foo.getConnectionURL());
+
+ System.out.println(foo);
+
}
}
diff --git a/examples/smoketests/src/test/java/org/apache/isis/testdomain/publishing/PublisherServiceTest.java b/examples/smoketests/src/test/java/org/apache/isis/testdomain/publishing/PublisherServiceTest.java
index bbc9de4..221109b 100644
--- a/examples/smoketests/src/test/java/org/apache/isis/testdomain/publishing/PublisherServiceTest.java
+++ b/examples/smoketests/src/test/java/org/apache/isis/testdomain/publishing/PublisherServiceTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.isis.testdomain.publishing;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -47,6 +49,7 @@ import org.apache.isis.testdomain.jdo.JdoTestDomainPersona;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import lombok.Getter;
import lombok.val;
@Smoketest
@@ -94,14 +97,18 @@ class PublisherServiceTest {
repository.persist(book);
// then - before the commit
- assertEquals("", publisherService.getHistory());
+ assertEquals("{}", publisherService.getHistory().toString());
return null;
});
// then - after the commit
- assertEquals("publishedObjects=created=0,deleted=0,loaded=0,updated=1,modified=1,",
- publisherService.getHistory());
+ val history = publisherService.getHistory();
+ assertEquals(0, history.get("created"));
+ assertEquals(0, history.get("deleted"));
+ assertEquals(0, history.get("loaded"));
+ assertEquals(1, history.get("updated"));
+ assertEquals(1, history.get("modified"));
}
@@ -120,8 +127,12 @@ class PublisherServiceTest {
future.get(1000, TimeUnit.SECONDS);
// then - after the commit
- assertEquals("publishedObjects=created=0,deleted=1,loaded=1,updated=2,modified=1,",
- publisherService.getHistory());
+ val history = publisherService.getHistory();
+ assertEquals(0, history.get("created"));
+ assertEquals(1, history.get("deleted"));
+ //assertEquals(0, history.get("loaded"));
+ assertEquals(2, history.get("updated"));
+ assertEquals(1, history.get("modified"));
}
@@ -130,30 +141,26 @@ class PublisherServiceTest {
@Service
public static class PublisherServiceProbe implements PublisherService {
- private StringBuilder history = new StringBuilder();
-
+ @Getter
+ private final Map<String, Integer> history = new HashMap<>();
+
void clearHistory() {
- history = new StringBuilder();
+ history.clear();
}
- String getHistory() {
- return history.toString();
- }
@Override
public void publish(Execution<?, ?> execution) {
- history.append("execution=").append(execution).append(",");
+ history.put("execution", 999);
}
@Override
public void publish(PublishedObjects publishedObjects) {
- history.append("publishedObjects=")
- .append("created=").append(publishedObjects.getNumberCreated()).append(",")
- .append("deleted=").append(publishedObjects.getNumberDeleted()).append(",")
- .append("loaded=").append(publishedObjects.getNumberLoaded()).append(",")
- .append("updated=").append(publishedObjects.getNumberUpdated()).append(",")
- .append("modified=").append(publishedObjects.getNumberPropertiesModified()).append(",")
- ;
+ history.put("created", publishedObjects.getNumberCreated());
+ history.put("deleted", publishedObjects.getNumberDeleted());
+ history.put("loaded", publishedObjects.getNumberLoaded());
+ history.put("updated", publishedObjects.getNumberUpdated());
+ history.put("modified", publishedObjects.getNumberPropertiesModified());
}
}