diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/NonIDERunListener.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/NonIDERunListener.java new file mode 100644 index 0000000000..17947e4b6c --- /dev/null +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/util/NonIDERunListener.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed 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.keycloak.testsuite.util; + +import org.apache.log4j.Level; +import org.jboss.logging.Logger; +import org.junit.runner.Description; +import org.junit.runner.notification.RunListener; + +/** + * This is executed when test is run from maven (maven-surefire-plugin), but not when it is run from IDE. That allows to run some actions, which should be + * executed just for maven build (eg. disable logging) + * + * @author Marek Posolda + */ +public class NonIDERunListener extends RunListener { + + private static final Logger log = Logger.getLogger(NonIDERunListener.class); + + private static final String KEYCLOAK_LOGGING_LEVEL_NAME = "keycloak.logging.level"; + + @Override + public void testRunStarted(Description description) throws Exception { + disableKeycloakLogging(); + } + + private void disableKeycloakLogging() { + String loggingLevel = System.getProperty(KEYCLOAK_LOGGING_LEVEL_NAME); + if (loggingLevel == null || loggingLevel.isEmpty()) { + + log.infof("Setting %s to off. Keycloak server logging will be disabled", KEYCLOAK_LOGGING_LEVEL_NAME); + System.setProperty(KEYCLOAK_LOGGING_LEVEL_NAME, "off"); + org.apache.log4j.Logger.getLogger("org.keycloak").setLevel(Level.OFF); + } + } + +} diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/log4j.properties b/testsuite/integration-arquillian/tests/base/src/test/resources/log4j.properties index 58fde2c984..9c9bfc259c 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/resources/log4j.properties +++ b/testsuite/integration-arquillian/tests/base/src/test/resources/log4j.properties @@ -27,7 +27,7 @@ log4j.appender.testsuite.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}] # Logging with "info" when running test from IDE, but disabled when running test with "mvn" . Both cases can be overriden by use system property "keycloak.logging.level" (eg. -Dkeycloak.logging.level=debug ) keycloak.logging.level=info -log4j.logger.org.keycloak=${keycloak.logging.level}, keycloak +log4j.logger.org.keycloak=${keycloak.logging.level} log4j.logger.org.jboss.resteasy.resteasy_jaxrs.i18n=off diff --git a/testsuite/integration-arquillian/tests/pom.xml b/testsuite/integration-arquillian/tests/pom.xml index 228bc9e295..7d2edbe5f3 100755 --- a/testsuite/integration-arquillian/tests/pom.xml +++ b/testsuite/integration-arquillian/tests/pom.xml @@ -78,8 +78,6 @@ true true - off - ${project.build.directory}/dependency/test-constants.properties false @@ -217,8 +215,6 @@ ${firefox_binary} ${phantomjs.cli.args} - ${keycloak.logging.level} - ${project.version} ${migration.project.version} ${migration.product.version} @@ -237,7 +233,7 @@ listener - org.keycloak.testsuite.util.TestEventsLogger,org.keycloak.testsuite.util.junit.AggregateResultsReporter + org.keycloak.testsuite.util.TestEventsLogger,org.keycloak.testsuite.util.junit.AggregateResultsReporter,org.keycloak.testsuite.util.NonIDERunListener