You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/19 01:02:44 UTC
git commit: Consolidate RequiresNonNull and RequiresNonEmpty
validators.
Repository: logging-log4j2
Updated Branches:
refs/heads/master bb001dcae -> 616604889
Consolidate RequiresNonNull and RequiresNonEmpty validators.
- Combined into a @Required annotation.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/61660488
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/61660488
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/61660488
Branch: refs/heads/master
Commit: 616604889b0109a3220085f4aa78504ed854003a
Parents: bb001dc
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 18 18:02:38 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 18 18:02:38 2014 -0500
----------------------------------------------------------------------
.../log4j/core/appender/ConsoleAppender.java | 8 +-
.../log4j/core/appender/mom/JmsAppender.java | 8 +-
.../validation/constraints/Required.java | 44 +++++++++++
.../constraints/RequiresNonEmpty.java | 44 -----------
.../validation/constraints/RequiresNonNull.java | 44 -----------
.../validators/RequiredValidator.java | 80 ++++++++++++++++++++
.../validators/RequiresNonEmptyValidator.java | 80 --------------------
.../validators/RequiresNonNullValidator.java | 48 ------------
.../plugins/validation/ValidatingPlugin.java | 6 +-
.../validators/RequiredValidatorTest.java | 63 +++++++++++++++
.../RequiresNonNullValidatorTest.java | 63 ---------------
11 files changed, 198 insertions(+), 290 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
index 54d837e..a117e88 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
@@ -31,7 +31,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.RequiresNonNull;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.apache.logging.log4j.core.util.Booleans;
import org.apache.logging.log4j.core.util.Loader;
@@ -114,18 +114,18 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender<OutputSt
public static class Builder implements org.apache.logging.log4j.core.util.Builder<ConsoleAppender> {
@PluginElement("Layout")
- @RequiresNonNull
+ @Required
private Layout<? extends Serializable> layout = PatternLayout.createDefaultLayout();
@PluginElement("Filter")
private Filter filter;
@PluginBuilderAttribute
- @RequiresNonNull
+ @Required
private Target target = Target.SYSTEM_OUT;
@PluginBuilderAttribute
- @RequiresNonNull
+ @Required
private String name;
@PluginBuilderAttribute
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java
index c53a970..f3a6998 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java
@@ -32,7 +32,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginAliases;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.RequiresNonNull;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.layout.SerializedLayout;
import org.apache.logging.log4j.core.net.JndiManager;
@@ -75,7 +75,7 @@ public class JmsAppender extends AbstractAppender {
public static class Builder implements org.apache.logging.log4j.core.util.Builder<JmsAppender> {
@PluginBuilderAttribute
- @RequiresNonNull(message = "A name for the JmsAppender must be specified")
+ @Required(message = "A name for the JmsAppender must be specified")
private String name;
@PluginBuilderAttribute
@@ -94,12 +94,12 @@ public class JmsAppender extends AbstractAppender {
private String securityCredentials;
@PluginBuilderAttribute
- @RequiresNonNull(message = "A javax.jms.ConnectionFactory JNDI name must be specified")
+ @Required(message = "A javax.jms.ConnectionFactory JNDI name must be specified")
private String factoryBindingName;
@PluginBuilderAttribute
@PluginAliases({"queueBindingName", "topicBindingName"})
- @RequiresNonNull(message = "A javax.jms.Destination JNDI name must be specified")
+ @Required(message = "A javax.jms.Destination JNDI name must be specified")
private String destinationBindingName;
@PluginBuilderAttribute
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.java
new file mode 100644
index 0000000..e6f3c56
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.java
@@ -0,0 +1,44 @@
+/*
+ * 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.logging.log4j.core.config.plugins.validation.constraints;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.logging.log4j.core.config.plugins.validation.Constraint;
+import org.apache.logging.log4j.core.config.plugins.validation.validators.RequiredValidator;
+
+/**
+ * Marks a plugin builder field or plugin factory parameter as required.
+ *
+ * @since 2.1
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.PARAMETER})
+@Constraint(RequiredValidator.class)
+public @interface Required {
+
+ /**
+ * The message to be logged if this constraint is violated. This should normally be overridden.
+ */
+ String message() default "The parameter is null";
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonEmpty.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonEmpty.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonEmpty.java
deleted file mode 100644
index 116aa9c..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonEmpty.java
+++ /dev/null
@@ -1,44 +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.logging.log4j.core.config.plugins.validation.constraints;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.logging.log4j.core.config.plugins.validation.Constraint;
-import org.apache.logging.log4j.core.config.plugins.validation.validators.RequiresNonEmptyValidator;
-
-/**
- * Constraint to mark a field or parameter as requiring a non-empty value.
- *
- * @see RequiresNonEmptyValidator
- * @since 2.1
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.PARAMETER})
-@Constraint(RequiresNonEmptyValidator.class)
-public @interface RequiresNonEmpty {
-
- /**
- * The message to be logged if this constraint is violated. This should normally be overridden.
- */
- String message() default "The parameter is empty";
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonNull.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonNull.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonNull.java
deleted file mode 100644
index 7eb83e2..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/constraints/RequiresNonNull.java
+++ /dev/null
@@ -1,44 +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.logging.log4j.core.config.plugins.validation.constraints;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.logging.log4j.core.config.plugins.validation.Constraint;
-import org.apache.logging.log4j.core.config.plugins.validation.validators.RequiresNonNullValidator;
-
-/**
- * Marks a plugin builder field or plugin factory parameter as required.
- *
- * @since 2.1
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.PARAMETER})
-@Constraint(RequiresNonNullValidator.class)
-public @interface RequiresNonNull {
-
- /**
- * The message to be logged if this constraint is violated. This should normally be overridden.
- */
- String message() default "The parameter is null";
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidator.java
new file mode 100644
index 0000000..fa0b032
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidator.java
@@ -0,0 +1,80 @@
+/*
+ * 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.logging.log4j.core.config.plugins.validation.validators;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.config.plugins.validation.ConstraintValidator;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.status.StatusLogger;
+
+/**
+ * Validator that checks an object for emptiness. Emptiness is defined here as:
+ * <ul>
+ * <li>The value {@code null}</li>
+ * <li>An object of type {@link CharSequence} with length 0</li>
+ * <li>An empty array</li>
+ * <li>An empty {@link Collection}</li>
+ * <li>An empty {@link Map}</li>
+ * </ul>
+ *
+ * @since 2.1
+ */
+public class RequiredValidator implements ConstraintValidator<Required> {
+
+ private static final Logger LOGGER = StatusLogger.getLogger();
+
+ private Required annotation;
+
+ @Override
+ public void initialize(final Required annotation) {
+ this.annotation = annotation;
+ }
+
+ @Override
+ public boolean isValid(final Object value) {
+ if (value == null) {
+ return err();
+ }
+ if (value instanceof CharSequence) {
+ final CharSequence sequence = (CharSequence) value;
+ return sequence.length() != 0 || err();
+ }
+ final Class<?> clazz = value.getClass();
+ if (clazz.isArray()) {
+ final Object[] array = (Object[]) value;
+ return array.length != 0 || err();
+ }
+ if (Collection.class.isAssignableFrom(clazz)) {
+ final Collection<?> collection = (Collection<?>) value;
+ return collection.size() != 0 || err();
+ }
+ if (Map.class.isAssignableFrom(clazz)) {
+ final Map<?, ?> map = (Map<?, ?>) value;
+ return map.size() != 0 || err();
+ }
+ LOGGER.warn("RequiresNonEmpty annotation applied to type [{}] that is unsupported.", clazz.getName());
+ return true;
+ }
+
+ private boolean err() {
+ LOGGER.error(annotation.message());
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonEmptyValidator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonEmptyValidator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonEmptyValidator.java
deleted file mode 100644
index d8e8959..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonEmptyValidator.java
+++ /dev/null
@@ -1,80 +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.logging.log4j.core.config.plugins.validation.validators;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.validation.ConstraintValidator;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.RequiresNonEmpty;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Validator that checks an object for emptiness. Emptiness is defined here as:
- * <ul>
- * <li>The value {@code null}</li>
- * <li>An object of type {@link CharSequence} with length 0</li>
- * <li>An empty array</li>
- * <li>An empty {@link Collection}</li>
- * <li>An empty {@link Map}</li>
- * </ul>
- *
- * @since 2.1
- */
-public class RequiresNonEmptyValidator implements ConstraintValidator<RequiresNonEmpty> {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private RequiresNonEmpty annotation;
-
- @Override
- public void initialize(final RequiresNonEmpty annotation) {
- this.annotation = annotation;
- }
-
- @Override
- public boolean isValid(final Object value) {
- if (value == null) {
- return err();
- }
- if (value instanceof CharSequence) {
- final CharSequence sequence = (CharSequence) value;
- return sequence.length() != 0 || err();
- }
- final Class<?> clazz = value.getClass();
- if (clazz.isArray()) {
- final Object[] array = (Object[]) value;
- return array.length != 0 || err();
- }
- if (Collection.class.isAssignableFrom(clazz)) {
- final Collection<?> collection = (Collection<?>) value;
- return collection.size() != 0 || err();
- }
- if (Map.class.isAssignableFrom(clazz)) {
- final Map<?, ?> map = (Map<?, ?>) value;
- return map.size() != 0 || err();
- }
- LOGGER.warn("RequiresNonEmpty annotation applied to type [{}] that is unsupported.", clazz.getName());
- return true;
- }
-
- private boolean err() {
- LOGGER.error(annotation.message());
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidator.java
deleted file mode 100644
index 13c926d..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidator.java
+++ /dev/null
@@ -1,48 +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.logging.log4j.core.config.plugins.validation.validators;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.plugins.validation.ConstraintValidator;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.RequiresNonNull;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Validator implementation for {@link RequiresNonNull}.
- *
- * @since 2.1
- */
-public class RequiresNonNullValidator implements ConstraintValidator<RequiresNonNull> {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private RequiresNonNull annotation;
-
- @Override
- public void initialize(final RequiresNonNull annotation) {
- this.annotation = annotation;
- }
-
- @Override
- public boolean isValid(final Object value) {
- if (value != null) {
- return true;
- }
- LOGGER.error(annotation.message());
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/ValidatingPlugin.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/ValidatingPlugin.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/ValidatingPlugin.java
index 71bfbcc..51d0a76 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/ValidatingPlugin.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/ValidatingPlugin.java
@@ -20,7 +20,7 @@ import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.RequiresNonNull;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.util.Assert;
/**
@@ -41,7 +41,7 @@ public class ValidatingPlugin {
@PluginFactory
public static ValidatingPlugin newValidatingPlugin(
- @RequiresNonNull(message = "The name given by the factory is null") final String name) {
+ @Required(message = "The name given by the factory is null") final String name) {
return new ValidatingPlugin(name);
}
@@ -53,7 +53,7 @@ public class ValidatingPlugin {
public static class Builder implements org.apache.logging.log4j.core.util.Builder<ValidatingPlugin> {
@PluginBuilderAttribute
- @RequiresNonNull(message = "The name given by the builder is null")
+ @Required(message = "The name given by the builder is null")
private String name;
public Builder setName(final String name) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
new file mode 100644
index 0000000..a135d0a
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiredValidatorTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.logging.log4j.core.config.plugins.validation.validators;
+
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.NullConfiguration;
+import org.apache.logging.log4j.core.config.plugins.util.PluginBuilder;
+import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
+import org.apache.logging.log4j.core.config.plugins.util.PluginType;
+import org.apache.logging.log4j.core.config.plugins.validation.ValidatingPlugin;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class RequiredValidatorTest {
+
+ private PluginType<ValidatingPlugin> plugin;
+ private Node node;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() throws Exception {
+ final PluginManager manager = new PluginManager("Test");
+ manager.collectPlugins();
+ plugin = (PluginType<ValidatingPlugin>) manager.getPluginType("Validator");
+ node = new Node(null, "Validator", plugin);
+ }
+
+ @Test
+ public void testNullDefaultValue() throws Exception {
+ final ValidatingPlugin validatingPlugin = new PluginBuilder<ValidatingPlugin>(plugin)
+ .withConfiguration(new NullConfiguration())
+ .withConfigurationNode(node)
+ .build();
+ assertNull(validatingPlugin);
+ }
+
+ @Test
+ public void testNonNullValue() throws Exception {
+ node.getAttributes().put("name", "foo");
+ final ValidatingPlugin validatingPlugin = new PluginBuilder<ValidatingPlugin>(plugin)
+ .withConfiguration(new NullConfiguration())
+ .withConfigurationNode(node)
+ .build();
+ assertNotNull(validatingPlugin);
+ assertEquals("foo", validatingPlugin.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/61660488/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidatorTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidatorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidatorTest.java
deleted file mode 100644
index f685f04..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/RequiresNonNullValidatorTest.java
+++ /dev/null
@@ -1,63 +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.logging.log4j.core.config.plugins.validation.validators;
-
-import org.apache.logging.log4j.core.config.Node;
-import org.apache.logging.log4j.core.config.NullConfiguration;
-import org.apache.logging.log4j.core.config.plugins.util.PluginBuilder;
-import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.util.PluginType;
-import org.apache.logging.log4j.core.config.plugins.validation.ValidatingPlugin;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class RequiresNonNullValidatorTest {
-
- private PluginType<ValidatingPlugin> plugin;
- private Node node;
-
- @SuppressWarnings("unchecked")
- @Before
- public void setUp() throws Exception {
- final PluginManager manager = new PluginManager("Test");
- manager.collectPlugins();
- plugin = (PluginType<ValidatingPlugin>) manager.getPluginType("Validator");
- node = new Node(null, "Validator", plugin);
- }
-
- @Test
- public void testNullDefaultValue() throws Exception {
- final ValidatingPlugin validatingPlugin = new PluginBuilder<ValidatingPlugin>(plugin)
- .withConfiguration(new NullConfiguration())
- .withConfigurationNode(node)
- .build();
- assertNull(validatingPlugin);
- }
-
- @Test
- public void testNonNullValue() throws Exception {
- node.getAttributes().put("name", "foo");
- final ValidatingPlugin validatingPlugin = new PluginBuilder<ValidatingPlugin>(plugin)
- .withConfiguration(new NullConfiguration())
- .withConfigurationNode(node)
- .build();
- assertNotNull(validatingPlugin);
- assertEquals("foo", validatingPlugin.getName());
- }
-}
\ No newline at end of file