Author: anil.saldhana(a)jboss.com
Date: 2012-02-29 17:12:10 -0500 (Wed, 29 Feb 2012)
New Revision: 1449
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java
Log:
PLFED-268: the trim() method should be able to take empty string
Modified:
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2012-02-28
16:49:30 UTC (rev 1448)
+++
federation/trunk/picketlink-fed-core/src/main/java/org/picketlink/identity/federation/core/parsers/util/StaxParserUtil.java 2012-02-29
22:12:10 UTC (rev 1449)
@@ -24,7 +24,6 @@
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_END_TAG;
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_TAG;
import static org.picketlink.identity.federation.core.ErrorCodes.EXPECTED_XSI;
-import static org.picketlink.identity.federation.core.ErrorCodes.NULL_INPUT_STREAM;
import java.io.IOException;
import java.io.InputStream;
@@ -44,6 +43,7 @@
import javax.xml.validation.Validator;
import org.apache.log4j.Logger;
+import org.picketlink.identity.federation.core.ErrorCodes;
import org.picketlink.identity.federation.core.exceptions.ConfigurationException;
import org.picketlink.identity.federation.core.exceptions.ParsingException;
import org.picketlink.identity.federation.core.saml.v2.constants.JBossSAMLConstants;
@@ -439,8 +439,8 @@
*/
public static final String trim(String str)
{
- if (str == null || str.length() == 0)
- throw new IllegalArgumentException(NULL_INPUT_STREAM);
+ if (str == null)
+ throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT);
return str.trim();
}
Modified:
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java
===================================================================
---
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java 2012-02-28
16:49:30 UTC (rev 1448)
+++
federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/util/StringUtilTestCase.java 2012-02-29
22:12:10 UTC (rev 1449)
@@ -22,12 +22,14 @@
package org.picketlink.test.identity.federation.core.util;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.util.StaxParserUtil;
import org.picketlink.identity.federation.core.util.StringUtil;
/**
@@ -80,4 +82,12 @@
throw new RuntimeException("Unknown");
}
}
+
+ @Test
+ public void trim() throws Exception
+ {
+ assertNotNull("".trim());
+ assertEquals(0, "".trim().length());
+ assertEquals(0, StaxParserUtil.trim("").length());
+ }
}
\ No newline at end of file
Show replies by date