From cccd29885e414f5dff42fb11101d64abe9870ca4 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 13 Jul 2015 15:32:01 +0000
Subject: [PATCH] Code cleanup
---
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java | 14 +++++++++-----
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java | 3 ++-
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java | 23 ++++++++---------------
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java | 15 ++++++---------
4 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
index 41215d3..6d2b657 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
@@ -22,11 +22,11 @@
*
*
* Copyright 2009 Sun Microsystems, Inc.
- * Portions copyright 2014 ForgeRock AS.
+ * Portions copyright 2014-2015 ForgeRock AS.
*/
package org.forgerock.opendj.ldap.schema;
-import static org.testng.Assert.fail;
+import static org.testng.Assert.*;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
@@ -34,9 +34,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-/**
- * Syntax tests.
- */
+/** Syntax tests. */
@SuppressWarnings("javadoc")
public abstract class AbstractSyntaxTestCase extends AbstractSchemaTestCase {
/**
@@ -49,27 +47,22 @@
@DataProvider(name = "acceptableValues")
public abstract Object[][] createAcceptableValues();
- /**
- * Test the normalization and the approximate comparison.
- */
+ /** Test the normalization and the approximate comparison. */
@Test(dataProvider = "acceptableValues")
public void testAcceptableValues(final String value, final Boolean result) throws Exception {
// Make sure that the specified class can be instantiated as a task.
final Syntax syntax = getRule();
final LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
- // test the valueIsAcceptable method
final Boolean liveResult = syntax.valueIsAcceptable(ByteString.valueOf(value), reason);
-
- if (!liveResult.equals(result)) {
- fail(syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
- }
+ assertEquals(liveResult, result,
+ syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
}
/**
- * Get an instance of the attribute syntax that muste be tested.
+ * Get an instance of the attribute syntax that must be tested.
*
- * @return An instance of the attribute syntax that muste be tested.
+ * @return An instance of the attribute syntax that must be tested.
*/
protected abstract Syntax getRule() throws SchemaException, DecodeException;
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java
index 39bf5f0..e0eab34 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java
@@ -31,17 +31,21 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-/**
- * Bit string syntax tests.
- */
+/** Bit string syntax tests. */
@Test
public class BitStringSyntaxTest extends AbstractSyntaxTestCase {
/** {@inheritDoc} */
@Override
@DataProvider(name = "acceptableValues")
public Object[][] createAcceptableValues() {
- return new Object[][] { { "'0101'B", true }, { "'1'B", true }, { "'0'B", true }, { "invalid", false },
- { "1", false }, { "'010100000111111010101000'B", true }, };
+ return new Object[][] {
+ { "'0101'B", true },
+ { "'1'B", true },
+ { "'0'B", true },
+ { "invalid", false },
+ { "1", false },
+ { "'010100000111111010101000'B", true },
+ };
}
/** {@inheritDoc} */
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java
index 9eb3c2c..fe48ba2 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java
@@ -86,15 +86,12 @@
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABlBMVEX/JgAAAAAP"
+ "IsinAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg==";
- try {
- return new Object[][] {
- { ByteString.valueOfBase64(nonImage), false },
- { ByteString.valueOfBase64(jfifImage), true },
- { ByteString.valueOfBase64(exifImage), true },
- { ByteString.valueOfBase64(pngImage), false } };
- } catch (Exception e) {
- return new Object[][] {};
- }
+ return new Object[][] {
+ { ByteString.valueOfBase64(nonImage), false },
+ { ByteString.valueOfBase64(jfifImage), true },
+ { ByteString.valueOfBase64(exifImage), true },
+ { ByteString.valueOfBase64(pngImage), false }
+ };
}
/** Test acceptable values for this syntax when not allowing malformed JPEG photos. */
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
index 3287587..1713437 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
@@ -1200,7 +1200,8 @@
// directoryOperation can't inherit from userApplications
scBuild.addAttributeType("(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE SUP cn "
- + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" + " SUBSTR caseIgnoreSubstringsMatch"
+ + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch"
+ + " SUBSTR caseIgnoreSubstringsMatch"
+ " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE"
+ " NO-USER-MODIFICATION USAGE directoryOperation )", true);
scBuild.addSchema(Schema.getCoreSchema(), false);
--
Gitblit v1.10.0