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/09/17 10:03:14 UTC
[isis] branch v2 updated: ISIS-2158 showcase the DomainModel
validation with 'simpleapp'
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 6597326 ISIS-2158 showcase the DomainModel validation with 'simpleapp'
6597326 is described below
commit 6597326136ab7ec47de5adebb2dfcde37707faa7
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Sep 17 12:03:06 2019 +0200
ISIS-2158 showcase the DomainModel validation with 'simpleapp'
- realized as a test-case with 'DomainModel_IntegTest'
- this replaces the 'validate' functionality of the former
isis-maven-plugin
---
.../validate/ValidateDomainModel.java | 77 ++++++++++++++++++++++
.../org/apache/isis/mavenplugin/util/Log4j.java | 55 ----------------
.../integtests/mml/DomainModel_IntegTest.java | 35 ++++++++++
.../integtests/mml/MetaModelService_IntegTest.java | 1 -
4 files changed, 112 insertions(+), 56 deletions(-)
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/integtestsupport/validate/ValidateDomainModel.java b/core/integtestsupport/src/main/java/org/apache/isis/integtestsupport/validate/ValidateDomainModel.java
new file mode 100644
index 0000000..b009257
--- /dev/null
+++ b/core/integtestsupport/src/main/java/org/apache/isis/integtestsupport/validate/ValidateDomainModel.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+package org.apache.isis.integtestsupport.validate;
+
+import java.util.Collection;
+
+import org.apache.isis.metamodel.spec.DomainModelException;
+import org.apache.isis.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtime.system.context.IsisContext;
+
+import lombok.val;
+import lombok.extern.log4j.Log4j2;
+
+/**
+ *
+ * @since 2.0
+ *
+ */
+@Log4j2
+public class ValidateDomainModel implements Runnable {
+
+ public void run() {
+
+ val specificationLoader = IsisContext.getSpecificationLoader();
+ val validationFailures = specificationLoader.validate();
+
+ val objectSpecifications = specificationLoader.currentSpecifications();
+
+ if(log.isDebugEnabled()) {
+ for (ObjectSpecification objectSpecification : objectSpecifications) {
+ log.debug("loaded: " + objectSpecification.getFullIdentifier());
+ }
+ }
+
+ if (validationFailures.occurred()) {
+ throwFailureException(
+ validationFailures.getNumberOfMessages() + " problems found.",
+ validationFailures.getMessages());
+ }
+ }
+
+ // -- HELPER
+
+ private void throwFailureException(String errorMessage, Collection<String> logMessages) {
+ logErrors(logMessages);
+ throw new DomainModelException(errorMessage);
+ }
+
+ private void logErrors(Collection<String> logMessages) {
+ log.error("");
+ log.error("");
+ log.error("");
+ for (String logMessage : logMessages) {
+ log.error(logMessage);
+ }
+ log.error("");
+ log.error("");
+ log.error("");
+ }
+
+}
\ No newline at end of file
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java b/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java
deleted file mode 100644
index 061bd61..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/mavenplugin/util/Log4j.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-package org.apache.isis.mavenplugin.util;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configurator;
-
-
-public final class Log4j {
-
- private Log4j(){}
-
- public static void configureIfRequired() {
- if(isConfigured()) return;
- //org.apache.log4j.BasicConfigurator.configure(); //log4j v1
- Configurator.setLevel(LogManager.getRootLogger().getName(), Level.INFO);
- }
-
- private static boolean isConfigured() {
- return LoggerContext.getContext().isInitialized();
-
- //log4j v1
- // Enumeration<?> appenders = LogManager.getRootLogger(). getAllAppenders();
- // if (appenders.hasMoreElements()) {
- // return true;
- // }
- // Enumeration<?> loggers = LogManager.getCurrentLoggers();
- // while (loggers.hasMoreElements()) {
- // Logger c = (Logger) loggers.nextElement();
- // if (c.getAllAppenders().hasMoreElements())
- // return true;
- // }
- // return false;
- }
-
-
-}
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/DomainModel_IntegTest.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/DomainModel_IntegTest.java
new file mode 100644
index 0000000..7ec4502
--- /dev/null
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/DomainModel_IntegTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+package domainapp.application.integtests.mml;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.isis.integtestsupport.validate.ValidateDomainModel;
+
+import domainapp.application.integtests.SpringIntegrationTest;
+
+class DomainModel_IntegTest extends SpringIntegrationTest {
+
+ @Test
+ void validateDomainModel() {
+ new ValidateDomainModel().run();
+ }
+
+
+}
\ No newline at end of file
diff --git a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
index 6ee3246..e480cc2 100644
--- a/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
+++ b/examples/apps/simpleapp/application/src/test/java/domainapp/application/integtests/mml/MetaModelService_IntegTest.java
@@ -43,7 +43,6 @@ import static org.junit.Assume.assumeThat;
import domainapp.application.integtests.SpringIntegrationTest;
-//@SpringBootTest(classes = SimpleAppConfiguration.class)
class MetaModelService_IntegTest extends SpringIntegrationTest {
@Inject MetaModelService metaModelService;