You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/06/24 23:55:53 UTC
svn commit: r957726 - in /harmony/enhanced/java/branches/java6: ./ classlib/
classlib/depends/files/ classlib/depends/jars/ classlib/depends/libs/
classlib/depends/manifests/xerces_2.10.0/
classlib/depends/manifests/xerces_2.10.0/META-INF/ classlib/dep...
Author: hindessm
Date: Thu Jun 24 21:55:52 2010
New Revision: 957726
URL: http://svn.apache.org/viewvc?rev=957726&view=rev
Log:
Merge changes from trunk@957725.
Added:
harmony/enhanced/java/branches/java6/classlib/depends/manifests/xerces_2.10.0/
- copied from r957713, harmony/enhanced/java/trunk/classlib/depends/manifests/xerces_2.10.0/
harmony/enhanced/java/branches/java6/classlib/depends/manifests/xerces_2.10.0/META-INF/
- copied from r957713, harmony/enhanced/java/trunk/classlib/depends/manifests/xerces_2.10.0/META-INF/
harmony/enhanced/java/branches/java6/classlib/depends/manifests/xerces_2.10.0/META-INF/MANIFEST.MF
- copied unchanged from r957713, harmony/enhanced/java/trunk/classlib/depends/manifests/xerces_2.10.0/META-INF/MANIFEST.MF
Removed:
harmony/enhanced/java/branches/java6/classlib/depends/manifests/xerces_2.9.1/
Modified:
harmony/enhanced/java/branches/java6/ (props changed)
harmony/enhanced/java/branches/java6/classlib/ (props changed)
harmony/enhanced/java/branches/java6/classlib/build.xml
harmony/enhanced/java/branches/java6/classlib/depends/files/bootclasspath.properties
harmony/enhanced/java/branches/java6/classlib/depends/jars/ (props changed)
harmony/enhanced/java/branches/java6/classlib/depends/libs/ (props changed)
harmony/enhanced/java/branches/java6/classlib/make/depends.properties
harmony/enhanced/java/branches/java6/classlib/make/depends.xml
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompositeName.java
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompoundName.java
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/Reference.java
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java
harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
harmony/enhanced/java/branches/java6/common_resources/ (props changed)
harmony/enhanced/java/branches/java6/common_resources/make/depends.properties
harmony/enhanced/java/branches/java6/drlvm/ (props changed)
harmony/enhanced/java/branches/java6/jdktools/ (props changed)
Propchange: harmony/enhanced/java/branches/java6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,3 +1,3 @@
/harmony/enhanced/java/branches/mrh:935751-941490
-/harmony/enhanced/java/trunk:929253-956455
+/harmony/enhanced/java/trunk:929253-957725
/harmony/enhanced/trunk:810871-929252
Propchange: harmony/enhanced/java/branches/java6/classlib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,7 +1,7 @@
/harmony/enhanced/classlib/trunk:713674-735919,765923-926091,926318-926838
/harmony/enhanced/classlib/trunk/working_classlib:884014-884286
/harmony/enhanced/java/branches/mrh/classlib:935751-941490
-/harmony/enhanced/java/trunk/classlib:929253-956455
+/harmony/enhanced/java/trunk/classlib:929253-957725
/harmony/enhanced/trunk/classlib:476395-929252
/harmony/enhanced/trunk/working_classlib:476396-920147
/incubator/harmony/enhanced/trunk/working_classlib:423974-476394
Modified: harmony/enhanced/java/branches/java6/classlib/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/build.xml?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/build.xml (original)
+++ harmony/enhanced/java/branches/java6/classlib/build.xml Thu Jun 24 21:55:52 2010
@@ -202,7 +202,7 @@ module:
<fileset dir="${depends.jars}">
<patternset includes="icu4j_4.2.1/*.jar" />
<patternset includes="xalan-j_2.7.0/xalan.jar" />
- <patternset includes="xerces_2.9.1/*.jar" />
+ <patternset includes="xerces_2.10.0/*.jar" />
</fileset>
<fileset dir="${depends.manifests}"/>
</copy>
Modified: harmony/enhanced/java/branches/java6/classlib/depends/files/bootclasspath.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/depends/files/bootclasspath.properties?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/depends/files/bootclasspath.properties (original)
+++ harmony/enhanced/java/branches/java6/classlib/depends/files/bootclasspath.properties Thu Jun 24 21:55:52 2010
@@ -166,9 +166,9 @@ bootclasspath.32=icu4j_4.2.1/icu4j-chars
# The following JARs are from Xerces/Xalan
bootclasspath.34=xalan-j_2.7.0/xalan.jar
-bootclasspath.35=xerces_2.9.1/resolver.jar
-bootclasspath.36=xerces_2.9.1/xercesImpl.jar
-bootclasspath.37=xerces_2.9.1/xml-apis.jar
+bootclasspath.35=xerces_2.10.0/resolver.jar
+bootclasspath.36=xerces_2.10.0/xercesImpl.jar
+bootclasspath.37=xerces_2.10.0/xml-apis.jar
# The following JARs are from mx4j.sf.net
bootclasspath.38=mx4j_3.0.2/mx4j.jar
Propchange: harmony/enhanced/java/branches/java6/classlib/depends/jars/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Jun 24 21:55:52 2010
@@ -19,3 +19,4 @@ geronimo-ws-metadata_2.0_spec-1.1.2
geronimo-jaxws_2.1_spec-1.0
xmlsec-1.4.3
bsf-3.0
+xerces_2.10.0
Propchange: harmony/enhanced/java/branches/java6/classlib/depends/libs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,3 +1,3 @@
/harmony/enhanced/classlib/trunk/depends/libs:544451-926091
-/harmony/enhanced/java/trunk/classlib/depends/libs:929253-956455
+/harmony/enhanced/java/trunk/classlib/depends/libs:929253-957725
/harmony/enhanced/trunk/classlib/depends/libs:476395-929252
Modified: harmony/enhanced/java/branches/java6/classlib/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/make/depends.properties?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/make/depends.properties (original)
+++ harmony/enhanced/java/branches/java6/classlib/make/depends.properties Thu Jun 24 21:55:52 2010
@@ -27,10 +27,10 @@ xalan.jar=${xalan.dir}/xalan.jar
xalan.url=${maven2.base}/xalan/xalan/2.7.0/xalan-2.7.0.jar
xalan.md5=a018d032c21a873225e702b36b171a10
-xerces.dir=${depends.jars}/xerces_2.9.1
+xerces.dir=${depends.jars}/xerces_2.10.0
xerces.zip=${xerces.dir}/xerces.zip
-xerces.url=http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.9.1.zip
-xerces.md5=a0e07ede1c3bd5231fe15eae24032b2e
+xerces.url=http://www.apache.org/dist/xerces/j/Xerces-J-bin.2.10.0.zip
+xerces.md5=8da14a7b2848eff131b7cc10668887e8
junit.dir=${depends.jars}/junit_4.6
junit.jar=${junit.dir}/junit-4.6.jar
Modified: harmony/enhanced/java/branches/java6/classlib/make/depends.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/make/depends.xml?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/make/depends.xml (original)
+++ harmony/enhanced/java/branches/java6/classlib/make/depends.xml Thu Jun 24 21:55:52 2010
@@ -72,7 +72,7 @@
<target name="-extract-xerces" unless="xerces.uptodate">
<unzip src="${xerces.zip}" dest="${xerces.dir}.tmp" />
<copy todir="${xerces.dir}" flatten="yes">
- <fileset dir="${xerces.dir}.tmp/xerces-2_9_1">
+ <fileset dir="${xerces.dir}.tmp/xerces-2_10_0">
<include name="resolver.jar" />
<include name="xercesImpl.jar" />
<include name="xml-apis.jar" />
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompositeName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompositeName.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompositeName.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompositeName.java Thu Jun 24 21:55:52 2010
@@ -22,6 +22,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OptionalDataException;
import java.util.Enumeration;
+import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -203,15 +204,14 @@ public class CompositeName implements Na
*/
private static Vector<String> parseName(String name)
throws InvalidNameException {
-
- Vector<String> l = new Vector<String>();
-
+ Vector<String> result = new Vector<String>();
// special case: all '/', means same number of empty elements
if (isAllSlash(name)) {
- for (int i = 0; i < name.length(); i++) {
- l.add(""); //$NON-NLS-1$
+ int length = name.length();
+ for (int index = 0; index < length; index++) {
+ result.add(""); //$NON-NLS-1$
}
- return l;
+ return result;
}
// general simple case, without escape and quote
@@ -219,25 +219,25 @@ public class CompositeName implements Na
&& name.indexOf('\\') < 0) {
int i = 0, j = 0;
while ((j = name.indexOf('/', i)) >= 0) {
- l.add(name.substring(i, j));
+ result.add(name.substring(i, j));
i = j + 1;
}
- l.add(name.substring(i));
- return l;
+ result.add(name.substring(i));
+ return result;
}
// general complicated case, consider escape and quote
- char c;
+ char curC, nextC;
char chars[] = name.toCharArray();
StringBuilder buf = new StringBuilder();
int status = OUT_OF_QUOTE;
- for (int i = 0; i < chars.length; i++) {
- c = chars[i];
+ for (int index = 0; index < chars.length; index++) {
+ curC = chars[index];
// check end quote violation
if (status == QUOTE_ENDED) {
- if (c == '/') {
- l.add(buf.toString());
+ if (curC == '/') {
+ result.add(buf.toString());
buf.setLength(0);
status = OUT_OF_QUOTE;
continue;
@@ -246,15 +246,16 @@ public class CompositeName implements Na
throw new InvalidNameException(Messages.getString("jndi.0C")); //$NON-NLS-1$
}
- if (c == '\\') {
+ if (curC == '\\') {
// escape char
try {
- char nc = chars[++i];
- if (nc == '\\' || nc == '\'' || nc == '"' || nc == '/') {
- buf.append(nc);
+ nextC = chars[++index];
+ if (nextC == '\\' || nextC == '\'' || nextC == '"'
+ || nextC == '/') {
+ buf.append(nextC);
} else {
- buf.append(c);
- buf.append(nc);
+ buf.append(curC);
+ buf.append(nextC);
}
} catch (ArrayIndexOutOfBoundsException e) {
// jndi.0D=Escape cannot be at the end of element
@@ -263,41 +264,44 @@ public class CompositeName implements Na
}
continue;
}
- if (c != '/' && c != '"' && c != '\'') {
+ if (curC != '/' && curC != '"' && curC != '\'') {
// normal char
- buf.append(c);
+ buf.append(curC);
continue;
}
// special char
- if (status == OUT_OF_QUOTE && c == '/') {
- l.add(buf.toString());
+ if (status == OUT_OF_QUOTE && curC == '/') {
+ result.add(buf.toString());
buf.setLength(0);
- } else if (status == OUT_OF_QUOTE && c == '\'' && buf.length() == 0) {
+ } else if (status == OUT_OF_QUOTE && curC == '\''
+ && buf.length() == 0) {
status = IN_SINGLE_QUOTE;
- } else if (status == OUT_OF_QUOTE && c == '"' && buf.length() == 0) {
+ } else if (status == OUT_OF_QUOTE && curC == '"'
+ && buf.length() == 0) {
status = IN_DOUBLE_QUOTE;
- } else if (status == IN_SINGLE_QUOTE && c == '\'') {
+ } else if (status == IN_SINGLE_QUOTE && curC == '\'') {
status = QUOTE_ENDED;
- } else if (status == IN_DOUBLE_QUOTE && c == '"') {
+ } else if (status == IN_DOUBLE_QUOTE && curC == '"') {
status = QUOTE_ENDED;
} else {
- buf.append(c);
+ buf.append(curC);
}
}
- l.add(buf.toString());
+ result.add(buf.toString());
// check end status
if (status != OUT_OF_QUOTE && status != QUOTE_ENDED) {
// jndi.0E=Wrong quote usage.
throw new InvalidNameException(Messages.getString("jndi.0E")); //$NON-NLS-1$
}
- return l;
+ return result;
}
private static boolean isAllSlash(String name) {
- for (int i = 0; i < name.length(); i++) {
- if (name.charAt(i) != '/') {
+ char[] nameChars = name.toCharArray();
+ for (int index = 0; index < nameChars.length; index++) {
+ if (nameChars[index] != '/') {
return false;
}
}
@@ -308,39 +312,39 @@ public class CompositeName implements Na
* Format name elements to its string representation.
*/
private static String formatName(Vector<String> elems) {
- // special case: all empty elements
+ StringBuilder sb = new StringBuilder();
+ int elemSize = elems.size();
if (isAllEmptyElements(elems)) {
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < elems.size(); i++) {
- buf.append("/"); //$NON-NLS-1$
+ // special case: all empty elements
+ for (int index = 0; index < elemSize; index++) {
+ sb.append('/');
}
- return buf.toString();
+ return sb.toString();
}
// general case
- StringBuilder buf = new StringBuilder();
- for (int i = 0; i < elems.size(); i++) {
- String elem = elems.get(i);
- if (i > 0) {
- buf.append("/"); //$NON-NLS-1$
- }
-
- // Add quotation while elem contains separater char
- if (elem.indexOf('/') != -1){
- buf.append("\"");
- buf.append(elem);
- buf.append("\"");
- }else{
- buf.append(elem);
+ String elem = null;
+ for (int index = 0; index < elemSize; index++) {
+ elem = elems.get(index);
+ if (index > 0) {
+ sb.append('/'); //$NON-NLS-1$
+ }
+ // Add quotation while elem contains separator char
+ if (elem.indexOf('/') != -1) {
+ sb.append('\"');
+ sb.append(elem);
+ sb.append('\"');
+ } else {
+ sb.append(elem);
}
}
- return buf.toString();
+ return sb.toString();
}
private static boolean isAllEmptyElements(Vector<String> elems) {
- for (int i = 0; i < elems.size(); i++) {
- String elem = elems.get(i);
- if (elem.length() > 0) {
+ int elemSize = elems.size();
+ for (int index = 0; index < elemSize; index++) {
+ if (elems.get(index).length() > 0) {
return false;
}
}
@@ -436,19 +440,14 @@ public class CompositeName implements Na
if (!(name instanceof CompositeName)) {
return false;
}
-
// check size
if (name.size() > elems.size()) {
return false;
}
-
// compare 1 by 1
Enumeration<String> enumeration = name.getAll();
- String me, he;
- for (int i = 0; enumeration.hasMoreElements(); i++) {
- me = elems.get(i);
- he = enumeration.nextElement();
- if (!(null == me ? null == he : me.equals(he))) {
+ for (int index = 0; enumeration.hasMoreElements(); index++) {
+ if (!elems.get(index).equals(enumeration.nextElement())) {
return false;
}
}
@@ -459,7 +458,6 @@ public class CompositeName implements Na
if (!(name instanceof CompositeName)) {
return false;
}
-
// check size
if (name.size() > elems.size()) {
return false;
@@ -467,11 +465,9 @@ public class CompositeName implements Na
// compare 1 by 1
Enumeration<String> enumeration = name.getAll();
- String me, he;
- for (int i = elems.size() - name.size(); enumeration.hasMoreElements(); i++) {
- me = elems.get(i);
- he = enumeration.nextElement();
- if (!(null == me ? null == he : me.equals(he))) {
+ for (int index = elems.size() - name.size(); enumeration
+ .hasMoreElements(); index++) {
+ if (!elems.get(index).equals(enumeration.nextElement())) {
return false;
}
}
@@ -495,24 +491,29 @@ public class CompositeName implements Na
* when <code>o</code> is not a <code>CompositeName</code>.
*/
public int compareTo(Object o) {
- if (o instanceof CompositeName) {
- CompositeName he = (CompositeName) o;
- int r;
- for (int i = 0; i < elems.size() && i < he.elems.size(); i++) {
- r = (elems.get(i)).compareTo(he.elems.get(i));
- if (r != 0) {
- return r;
- }
- }
- if (elems.size() == he.elems.size()) {
- return 0;
- } else if (elems.size() < he.elems.size()) {
- return -1;
- } else {
- return 1;
+ if (o == this) {
+ return 0;
+ }
+ if (!(o instanceof CompositeName)) {
+ throw new ClassCastException();
+ }
+
+ Iterator<String> thisIter = elems.iterator();
+ Iterator<String> thatIter = ((CompositeName) o).elems.iterator();
+ int compareResult;
+ while (thisIter.hasNext() && thatIter.hasNext()) {
+ compareResult = thisIter.next().compareTo(thatIter.next());
+ if (0 != compareResult) {
+ return compareResult;
}
}
- throw new ClassCastException();
+ if (thisIter.hasNext()) {
+ return 1;
+ }
+ if (thatIter.hasNext()) {
+ return -1;
+ }
+ return 0;
}
/**
@@ -553,16 +554,23 @@ public class CompositeName implements Na
*/
@Override
public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
// check type
if (!(o instanceof CompositeName)) {
return false;
}
+ CompositeName that = (CompositeName) o;
+ if (this.size() != that.size()) {
+ return false;
+ }
- return this.elems.equals(((CompositeName) o).elems);
+ Iterator<String> thisIter = elems.iterator();
+ Iterator<String> thatIter = that.elems.iterator();
+ while (thisIter.hasNext() && thatIter.hasNext()) {
+ if (!thisIter.next().equals(thatIter.next())) {
+ return false;
+ }
+ }
+ return true;
}
/**
@@ -573,11 +581,11 @@ public class CompositeName implements Na
*/
@Override
public int hashCode() {
- int sum = 0;
- for (int i = 0; i < elems.size(); i++) {
- sum += elems.get(i).hashCode();
+ int hashCode = 0;
+ for (int index = 0; index < elems.size(); index++) {
+ hashCode += elems.get(index).hashCode();
}
- return sum;
+ return hashCode;
}
/**
@@ -616,5 +624,4 @@ public class CompositeName implements Na
elems.add((String) ois.readObject());
}
}
-
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompoundName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompoundName.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompoundName.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/CompoundName.java Thu Jun 24 21:55:52 2010
@@ -21,19 +21,20 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Enumeration;
+import java.util.Iterator;
import java.util.Properties;
import java.util.Vector;
import org.apache.harmony.jndi.internal.nls.Messages;
/**
- * A <code>CompoundName</code> is a series of string elements, and it
- * represents a name in a naming service within a single namespace. Typically
- * these names have a structure which is hierarchical.
- * <p>
- * A <code>CompoundName</code> has a sequence of zero or more elements
- * delimited by the char specified in the property "jndi.syntax.separator". This
- * property is required except when the direction of the name is "flat" (see
+ * A <code>CompoundName</code> is a series of string elements, and it represents
+ * a name in a naming service within a single namespace. Typically these names
+ * have a structure which is hierarchical.
+ * <p>
+ * A <code>CompoundName</code> has a sequence of zero or more elements delimited
+ * by the char specified in the property "jndi.syntax.separator". This property
+ * is required except when the direction of the name is "flat" (see
* jndi.syntax.direction). The property "jndi.syntax.separator2" allows for the
* specification of an additional separator. A separator string will be treated
* as normal characters if it is preceded by the escape string or is within
@@ -44,8 +45,8 @@ import org.apache.harmony.jndi.internal.
* name is read. Permitted values are "right_to_left", "left_to_right" and
* "flat". A flat name does not have a hierarchical structure. If this property
* is not specified then the default is "flat". If this property is specified
- * with an invalid value then an <code>IllegalArgumentException</code> should
- * be raised.
+ * with an invalid value then an <code>IllegalArgumentException</code> should be
+ * raised.
* </p>
* <p>
* Each element can be accessed using its position. The first element is at
@@ -57,18 +58,18 @@ import org.apache.harmony.jndi.internal.
* There are other properties which affect the syntax of a
* <code>CompoundName</code>. The following properties are all optional:
* <ul>
- * <li> jndi.syntax.escape - Escape sequence,The escape sequence is used to
+ * <li>jndi.syntax.escape - Escape sequence,The escape sequence is used to
* escape a quote, separator or escape. When preceded itself by the escape
* sequence it is treated as ordinary characters. When it is followed by chars
* which are not quote or separator strings then it is treated as ordinary
* characters</li>
- * <li> jndi.syntax.beginquote - Used as start of quoted string (Defaults to
+ * <li>jndi.syntax.beginquote - Used as start of quoted string (Defaults to
* endquote)</li>
- * <li> jndi.syntax.endquote - Used as end of quoted string (Defaults to
+ * <li>jndi.syntax.endquote - Used as end of quoted string (Defaults to
* beginquote)</li>
- * <li> jndi.syntax.beginquote2 - Additionally used as start of quoted string
+ * <li>jndi.syntax.beginquote2 - Additionally used as start of quoted string
* (Defaults to endquote2)</li>
- * <li> jndi.syntax.endquote2 - Additionally used as end of quoted string
+ * <li>jndi.syntax.endquote2 - Additionally used as end of quoted string
* (Defaults to beginquote2)</li>
* </ul>
* <p>
@@ -84,9 +85,9 @@ import org.apache.harmony.jndi.internal.
* </p>
* <p>
* <ul>
- * <li> jndi.syntax.ignorecase - If 'true' then ignore case when name elements
+ * <li>jndi.syntax.ignorecase - If 'true' then ignore case when name elements
* are compared. If false or not set then case is important.</li>
- * <li> jndi.syntax.trimblanks - If 'true' then ignore leading & trailing blanks
+ * <li>jndi.syntax.trimblanks - If 'true' then ignore leading & trailing blanks
* when name elements are compared. If false or not set then blanks are
* important.</li>
* </ul>
@@ -116,9 +117,9 @@ import org.apache.harmony.jndi.internal.
* <p>
* Consider the string "CN=$Mandy Jennings, O=Apache, C=UK" with
* <ul>
- * <li> jndi.syntax.direction set to "right_to_left"</li>
- * <li> jndi.syntax.separator set to ","</li>
- * <li> jndi.syntax.separator.typeval set to "="</li>
+ * <li>jndi.syntax.direction set to "right_to_left"</li>
+ * <li>jndi.syntax.separator set to ","</li>
+ * <li>jndi.syntax.separator.typeval set to "="</li>
* </ul>
* When no jndi.syntax.beginquote is set then this creates a valid
* <code>CompoundName</code> with 3 elements.
@@ -132,8 +133,8 @@ import org.apache.harmony.jndi.internal.
* quotes round Mandy Jennings now balance.
* </p>
* <p>
- * A <code>CompoundName</code> may be empty. An empty
- * <code>CompoundName</code> has no elements. Elements may also be empty.
+ * A <code>CompoundName</code> may be empty. An empty <code>CompoundName</code>
+ * has no elements. Elements may also be empty.
* </p>
*
* <pre>
@@ -300,7 +301,7 @@ public class CompoundName implements Nam
private transient boolean flat;
// elements of compound name
- private transient Vector<String> elem;
+ private transient Vector<String> elems;
// property setting
protected transient Properties mySyntax;
@@ -328,16 +329,16 @@ public class CompoundName implements Nam
throw new NullPointerException();
}
init(props);
- this.elem = new Vector<String>();
+ this.elems = new Vector<String>();
while (elements.hasMoreElements()) {
- this.elem.add(elements.nextElement());
+ this.elems.add(elements.nextElement());
}
}
/**
- * Constructs a <code>CompoundName</code> with supplied
- * <code>String</code> and <code>Properties</code>, taking the supplied
- * <code>s</code> and breaking it down into its elements.
+ * Constructs a <code>CompoundName</code> with supplied <code>String</code>
+ * and <code>Properties</code>, taking the supplied <code>s</code> and
+ * breaking it down into its elements.
*
* @param s
* a string containing the full compound name
@@ -427,7 +428,7 @@ public class CompoundName implements Nam
* parse name from string to elements
*/
private void parseName(String s) throws InvalidNameException {
- this.elem = new Vector<String>();
+ this.elems = new Vector<String>();
if ("".equals(s)) { //$NON-NLS-1$
// if empty string, return empty vector
return;
@@ -523,7 +524,7 @@ public class CompoundName implements Nam
throw new InvalidNameException(Messages.getString("jndi.08", s)); //$NON-NLS-1$
}
if (!hasNotNullElement) {
- elem.remove(elem.size() - 1);
+ elems.remove(elems.size() - 1);
}
}
@@ -543,9 +544,9 @@ public class CompoundName implements Nam
*/
private void addElement(StringBuilder element) {
if (LEFT_TO_RIGHT == direction) {
- elem.add(element.toString());
+ elems.add(element.toString());
} else {
- elem.add(0, element.toString());
+ elems.add(0, element.toString());
}
element.setLength(0);
}
@@ -599,12 +600,12 @@ public class CompoundName implements Nam
}
public Enumeration<String> getAll() {
- return this.elem.elements();
+ return this.elems.elements();
}
public String get(int index) {
validateIndex(index, false);
- return elem.elementAt(index);
+ return elems.elementAt(index);
}
/*
@@ -612,29 +613,29 @@ public class CompoundName implements Nam
* this.size() is considered as valid, otherwise invalid
*/
private void validateIndex(int index, boolean isInclude) {
- if (0 > index || index > elem.size()
- || (!isInclude && index == elem.size())) {
+ if (0 > index || index > elems.size()
+ || (!isInclude && index == elems.size())) {
throw new ArrayIndexOutOfBoundsException();
}
}
public Name getPrefix(int index) {
validateIndex(index, true);
- return new CompoundName(new Vector<String>(elem.subList(0, index))
+ return new CompoundName(new Vector<String>(elems.subList(0, index))
.elements(), mySyntax);
}
public Name getSuffix(int index) {
- if (index == elem.size()) {
+ if (index == elems.size()) {
return new CompoundName(new Vector<String>().elements(), mySyntax);
}
validateIndex(index, false);
- return new CompoundName(new Vector<String>(elem.subList(index, elem
+ return new CompoundName(new Vector<String>(elems.subList(index, elems
.size())).elements(), mySyntax);
}
public Name addAll(Name name) throws InvalidNameException {
- return addAll(elem.size(), name);
+ return addAll(elems.size(), name);
}
public Name addAll(int index, Name name) throws InvalidNameException {
@@ -654,7 +655,7 @@ public class CompoundName implements Nam
validateIndex(index, true);
Enumeration<String> enumeration = name.getAll();
while (enumeration.hasMoreElements()) {
- elem.add(index++, enumeration.nextElement());
+ elems.add(index++, enumeration.nextElement());
}
return this;
}
@@ -668,7 +669,7 @@ public class CompoundName implements Nam
// jndi.0A=A flat name can only have a single component
throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$
}
- elem.add(element);
+ elems.add(element);
return this;
}
@@ -697,7 +698,7 @@ public class CompoundName implements Nam
throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$
}
validateIndex(index, true);
- elem.add(index, element);
+ elems.add(index, element);
return this;
}
@@ -716,7 +717,7 @@ public class CompoundName implements Nam
*/
public Object remove(int index) throws InvalidNameException {
validateIndex(index, false);
- return elem.remove(index);
+ return elems.remove(index);
}
@Override
@@ -725,11 +726,11 @@ public class CompoundName implements Nam
}
public int size() {
- return elem.size();
+ return elems.size();
}
public boolean isEmpty() {
- return elem.isEmpty();
+ return elems.isEmpty();
}
public boolean startsWith(Name name) {
@@ -770,9 +771,10 @@ public class CompoundName implements Nam
private void writeObject(ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
oos.writeObject(mySyntax);
- oos.writeInt(elem.size());
- for (int i = 0; i < elem.size(); i++) {
- String element = elem.elementAt(i);
+ int elemSize = elems.size();
+ oos.writeInt(elemSize);
+ for (int i = 0; i < elemSize; i++) {
+ String element = elems.elementAt(i);
oos.writeObject(element);
}
}
@@ -795,59 +797,58 @@ public class CompoundName implements Nam
ois.defaultReadObject();
init(((Properties) ois.readObject()));
int size = ois.readInt();
- elem = new Vector<String>();
+ elems = new Vector<String>();
for (int i = 0; i < size; i++) {
- elem.add((String) ois.readObject());
+ elems.add((String) ois.readObject());
}
}
/**
- * Compare this <code>CompoundName</code> with the one supplied as a
- * param.
+ * Compare this <code>CompoundName</code> with the one supplied as a param.
* <p>
* See the definition of the <code>equals()</code> method to see how the
* direction, ignorecase and trimblanks properties affect the comparison of
- * a <code>CompoundName</code>. Other than that the comparison is the
- * same as that for a <code>CompositeName</code>.
+ * a <code>CompoundName</code>. Other than that the comparison is the same
+ * as that for a <code>CompositeName</code>.
* </p>
*
* @return a negative number means this is less than the supplied Object
- * <code>o</code>. a positive number means this is greater than
- * the supplied Object <code>o</code>. zero means the two objects
- * are equal.
+ * <code>o</code>. a positive number means this is greater than the
+ * supplied Object <code>o</code>. zero means the two objects are
+ * equal.
* @param o
* the object to compare - cannot be null.
* @throws ClassCastException
* when <code>o</code> is not a compatible class that can be
- * compared or if the object to compare <code>o</code> is
- * null.
+ * compared or if the object to compare <code>o</code> is null.
*/
public int compareTo(Object o) {
+ if (o == this) {
+ return 0;
+ }
if (!(o instanceof CompoundName)) {
throw new ClassCastException();
}
- int result = -1;
- CompoundName otherName = (CompoundName) o;
- Enumeration<String> otherEnum = otherName.getAll();
- String thisElement;
- String otherElement;
- int i;
- for (i = 0; i < size() && otherEnum.hasMoreElements(); i++) {
- thisElement = preProcess(elem.get(i), ignoreCase, trimBlanks);
- otherElement = preProcess(otherEnum.nextElement(), ignoreCase,
- trimBlanks);
- result = (null == thisElement ? (null == otherElement ? 0 : -1)
- : thisElement.compareTo(otherElement));
- if (0 != result) {
- return result;
+
+ Iterator<String> thisIter = elems.iterator();
+ Iterator<String> thatIter = ((CompoundName) o).elems.iterator();
+ int compareResult;
+ String thisString, thatString;
+ while (thisIter.hasNext() && thatIter.hasNext()) {
+ thisString = preProcess(thisIter.next(), ignoreCase, trimBlanks);
+ thatString = preProcess(thatIter.next(), ignoreCase, trimBlanks);
+ compareResult = thisString.compareTo(thatString);
+ if (0 != compareResult) {
+ return compareResult;
}
}
- if (i < size()) {
- result = 1;
- } else if (otherEnum.hasMoreElements()) {
- result = -1;
+ if (thisIter.hasNext()) {
+ return 1;
}
- return result;
+ if (thatIter.hasNext()) {
+ return -1;
+ }
+ return 0;
}
/**
@@ -866,13 +867,13 @@ public class CompoundName implements Nam
*/
@Override
public int hashCode() {
- int result = 0;
- Enumeration<String> enumeration = elem.elements();
+ int hashCode = 0;
+ Enumeration<String> enumeration = elems.elements();
while (enumeration.hasMoreElements()) {
- result += preProcess(enumeration.nextElement(), ignoreCase,
+ hashCode += preProcess(enumeration.nextElement(), ignoreCase,
trimBlanks).hashCode();
}
- return result;
+ return hashCode;
}
/**
@@ -896,12 +897,13 @@ public class CompoundName implements Nam
: endQuoteString;
String separator = NULL_STRING.equals(separatorString) ? separatorString2
: separatorString;
+ int elemSize = elems.size();
if (RIGHT_TO_LEFT.equals(direction)) {
- for (int i = elem.size() - 1; i >= 0; i--) {
+ for (int i = elemSize - 1; i >= 0; i--) {
addElement(sb, i, separator, begin, end);
}
} else {
- for (int i = 0; i < elem.size(); i++) {
+ for (int i = 0; i < elemSize; i++) {
addElement(sb, i, separator, begin, end);
}
}
@@ -914,9 +916,10 @@ public class CompoundName implements Nam
}
private void addElement(StringBuilder sb, int index, String separator,
- String begin, String end) {
- String elemString = elem.get(index);
- if (0 == elemString.length()) {
+ String begin, final String end) {
+ final String elemString = elems.get(index);
+ final int elemStringLength = elemString.length();
+ if (0 == elemStringLength) {
// if empty element, append a separator and continue
sb.append(separator);
return;
@@ -930,8 +933,9 @@ public class CompoundName implements Nam
sb.insert(pos, begin);
pos += begin.length();
// if quoted, then every endquote char must be escaped
+ int endLenght = end.length();
for (int i = 0, j = 0; 0 <= (j = elemString.indexOf(end, i)); i = j
- + end.length()) {
+ + endLenght) {
sb.insert(pos + j, escapeString);
pos += escapeString.length();
}
@@ -944,7 +948,7 @@ public class CompoundName implements Nam
pos += escapeString.length();
}
// if not quoted, escape all separator string and all escape string
- for (int i = 0; i < elemString.length();) {
+ for (int i = 0; i < elemStringLength;) {
if (startsWithFromPos(elemString, i, separatorString)) {
sb.insert(pos + i, escapeString);
pos += escapeString.length();
@@ -969,8 +973,8 @@ public class CompoundName implements Nam
* Check if the supplied object <code>o</code> is equal to this
* <code>CompoundName</code>.
* <p>
- * The supplied <code>Object o</code> may be null but that will cause
- * false to be returned.
+ * The supplied <code>Object o</code> may be null but that will cause false
+ * to be returned.
* </p>
* <p>
* The supplied <code>Object o</code> may be something other than a
@@ -979,9 +983,8 @@ public class CompoundName implements Nam
* <p>
* To be equal the supplied <code>CompoundName</code> must have the same
* number of elements and each element must match the corresponding element
- * of this <code>CompoundName</code>. The properties
- * jndi.syntax.ignorecase and jndi.syntax.trimblanks need to be considered
- * if they have been set.
+ * of this <code>CompoundName</code>. The properties jndi.syntax.ignorecase
+ * and jndi.syntax.trimblanks need to be considered if they have been set.
* </p>
* <p>
* The properties associated with the <code>CompoundName</code> must be
@@ -1001,41 +1004,36 @@ public class CompoundName implements Nam
return false;
}
- // compare size
CompoundName otherName = (CompoundName) o;
- final int size = otherName.size();
- if (size != this.size()) {
+ int otherSize = otherName.size();
+ if (otherSize != this.size()) {
return false;
}
// compare every element
- return equals(otherName, 0, size);
+ return equals(otherName, 0, otherSize);
}
/**
* compare this name to the supplied <code>name</code> from position
- * <code>start</code> to position <code>start</code>+
- * <code>length</code>-1
+ * <code>start</code> to position <code>start</code>+ <code>length</code>-1
*/
- private boolean equals(Name name, int start, int length) {
+ private boolean equals(Name name, int offset, int length) {
if (length > this.size()) {
return false;
}
CompoundName otherName = (CompoundName) name;
Enumeration<String> otherEnum = otherName.getAll();
- String thisElement;
- String otherElement;
+ String thisElement, otherElement;
for (int i = 0; i < length; i++) {
- thisElement = preProcess(elem.get(i + start), ignoreCase,
+ thisElement = preProcess(elems.get(i + offset), ignoreCase,
trimBlanks);
otherElement = preProcess(otherEnum.nextElement(), ignoreCase,
trimBlanks);
- if (!(null == thisElement ? null == otherElement : thisElement
- .equals(otherElement))) {
+ if (!thisElement.equals(otherElement)) {
return false;
}
}
return true;
}
-
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/Reference.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/Reference.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/Reference.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/main/java/javax/naming/Reference.java Thu Jun 24 21:55:52 2010
@@ -282,9 +282,9 @@ public class Reference implements Clonea
@Override
public Object clone() {
try {
- Reference r = (Reference) super.clone();
- r.addrs = (Vector<RefAddr>) this.addrs.clone();
- return r;
+ Reference reference = (Reference) super.clone();
+ reference.addrs = (Vector<RefAddr>) this.addrs.clone();
+ return reference;
} catch (CloneNotSupportedException e) {
// jndi.03=Failed to clone object of Reference class.
throw new AssertionError(Messages.getString("jndi.03")); //$NON-NLS-1$
@@ -305,12 +305,16 @@ public class Reference implements Clonea
*/
@Override
public boolean equals(Object o) {
- if (o instanceof Reference) {
- Reference r = (Reference) o;
- return r.className.equals(this.className)
- && r.addrs.equals(this.addrs);
+ if (o == this) {
+ return true;
}
- return false;
+ if (!(o instanceof Reference)) {
+ return false;
+ }
+ Reference ref = (Reference) o;
+ return ref.className.equals(this.className)
+ && ref.addrs.size() == this.addrs.size()
+ && ref.addrs.equals(this.addrs);
}
/**
@@ -322,13 +326,12 @@ public class Reference implements Clonea
*/
@Override
public int hashCode() {
- int i = this.className.hashCode();
+ int hashCode = this.className.hashCode();
Enumeration<RefAddr> e = this.addrs.elements();
-
while (e.hasMoreElements()) {
- i += e.nextElement().hashCode();
+ hashCode += e.nextElement().hashCode();
}
- return i;
+ return hashCode;
}
/**
@@ -337,18 +340,16 @@ public class Reference implements Clonea
*
* @return the string representation of this object
*/
- @SuppressWarnings("nls")
@Override
public String toString() {
- StringBuilder s = new StringBuilder("Reference Class Name: ");
- s.append(className);
- s.append("\n");
-
- Enumeration<RefAddr> e = this.addrs.elements();
- while (e.hasMoreElements()) {
- s.append(e.nextElement());
+ StringBuilder sb = new StringBuilder("Reference Class Name: "); //$NON-NLS-1$
+ sb.append(this.className).append('\n');
+ if (addrs.size() > 0) {
+ Enumeration<RefAddr> elements = this.addrs.elements();
+ while (elements.hasMoreElements()) {
+ sb.append(elements.nextElement().toString());
+ }
}
- return s.toString();
+ return sb.toString();
}
-
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompositeNameTest.java Thu Jun 24 21:55:52 2010
@@ -22,6 +22,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Enumeration;
import java.util.Properties;
+import java.util.Vector;
import javax.naming.CompositeName;
import javax.naming.CompoundName;
@@ -29,6 +30,7 @@ import javax.naming.InvalidNameException
import javax.naming.Name;
import junit.framework.TestCase;
+
import org.apache.harmony.jndi.tests.javax.naming.util.Log;
/**
@@ -721,11 +723,107 @@ public class CompositeNameTest extends T
}
// mock class to test protected methods
- public class MockCompositeName extends CompositeName {
+ public static class MockCompositeName extends CompositeName {
private static final long serialVersionUID = 1L;
+ public MockCompositeName(String name) throws InvalidNameException {
+ super(name);
+ }
+
public MockCompositeName(Enumeration<String> enumeration) {
super(enumeration);
}
}
+
+ private static MockCompositeName nullName;
+
+ private static MockCompositeName nullName2;
+
+ private static MockCompositeName sampleName;
+
+ static {
+ Vector<String> elems = new Vector<String>();
+ elems.add(null);
+ nullName = new MockCompositeName(elems.elements());
+ elems.add(null);
+ nullName2 = new MockCompositeName(elems.elements());
+ try {
+ sampleName = new MockCompositeName("sample");
+ } catch (InvalidNameException e) {
+ // Ignored
+ }
+ }
+
+ public void testEquals_NPE() throws InvalidNameException {
+ try {
+ nullName.equals(nullName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(nullName.equals(nullName2));
+ assertFalse(nullName2.equals(nullName));
+
+ try {
+ nullName.equals(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.equals(nullName));
+ }
+
+ public void testCompareTo_NPE() throws InvalidNameException {
+ assertEquals(0, nullName.compareTo(nullName));
+ try {
+ nullName.compareTo(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ try {
+ sampleName.compareTo(nullName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testToString_NPE() {
+ try {
+ nullName.toString();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testHashCode_NPE() {
+ try {
+ nullName.hashCode();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testStartsWith_NPE() {
+ try {
+ nullName.startsWith(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.startsWith(nullName));
+ }
+
+ public void testEndsWith_NPE() {
+ try {
+ nullName.endsWith(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.endsWith(nullName));
+ }
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/CompoundNameTest.java Thu Jun 24 21:55:52 2010
@@ -22,6 +22,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Enumeration;
import java.util.Properties;
+import java.util.Vector;
import javax.naming.CompositeName;
import javax.naming.CompoundName;
@@ -1815,4 +1816,174 @@ public class CompoundNameTest extends Te
throw new UnsupportedOperationException();
}
}
+
+ public static class MockCompoundName extends CompoundName {
+
+ private static final long serialVersionUID = -5947330494555498760L;
+
+ public MockCompoundName(String s) throws InvalidNameException {
+ super(s, new Properties());
+ }
+
+ public MockCompoundName(Enumeration<String> elements, Properties props) {
+ super(elements, props);
+ }
+ }
+
+ private static CompoundName nullName;
+
+ private static CompoundName nullName2;
+
+ private static CompoundName sampleName;
+
+ static {
+ Vector<String> elems = new Vector<String>();
+ elems.add(null);
+ nullName = new MockCompoundName(elems.elements(), new Properties());
+ elems.add(null);
+ nullName2 = new MockCompoundName(elems.elements(), new Properties());
+ try {
+ sampleName = new MockCompoundName("sample");
+ } catch (InvalidNameException e) {
+ // Ignored
+ }
+ }
+
+ public void testConstructor_NPE() {
+ try {
+ new MockCompoundName(null, new Properties());
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testEquals_NPE() {
+ try {
+ nullName.equals(nullName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(nullName.equals(nullName2));
+ assertFalse(nullName2.equals(nullName));
+
+ try {
+ nullName.equals(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.equals(nullName));
+ }
+
+ public void testCompareTo_NPE() {
+ assertEquals(0, nullName.compareTo(nullName));
+ try {
+ nullName.compareTo(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ try {
+ sampleName.compareTo(nullName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testHashCode_NPE() {
+ try {
+ nullName.hashCode();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testToString_NPE() {
+ try {
+ nullName.toString();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void testStartsWith_NPE() {
+ try {
+ nullName.startsWith(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.startsWith(nullName));
+ }
+
+ public void testEndsWith_NPE() {
+ try {
+ nullName.endsWith(sampleName);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ assertFalse(sampleName.endsWith(nullName));
+ }
+
+ public void testIgnoreCase() throws InvalidNameException {
+ String key = "jndi.syntax.ignorecase";
+ Properties properties = new Properties();
+ properties.setProperty(key, "true");
+ // true-true
+ CompoundName cName1 = new CompoundName("cName", properties);
+ CompoundName cName2 = new CompoundName("CName", properties);
+ assertTrue(cName1.equals(cName2));
+ assertTrue(cName2.equals(cName1));
+ assertEquals(0, cName1.compareTo(cName2));
+ assertEquals(0, cName2.compareTo(cName1));
+
+ // true-false
+ properties.setProperty(key, "false");
+ cName2 = new CompoundName("CName", properties);
+ assertTrue(cName1.equals(cName2));
+ assertFalse(cName2.equals(cName1));
+ assertEquals(0, cName1.compareTo(cName2));
+ assertTrue(cName2.compareTo(cName1) < 0);
+
+ // false-false
+ cName1 = new CompoundName("cName", properties);
+ assertFalse(cName1.equals(cName2));
+ assertFalse(cName2.equals(cName1));
+ assertTrue(cName1.compareTo(cName2) > 0);
+ assertTrue(cName2.compareTo(cName1) < 0);
+ }
+
+ public void testTrimBlank() throws InvalidNameException {
+ String key = "jndi.syntax.trimblanks";
+ Properties properties = new Properties();
+ properties.setProperty(key, "true");
+ // true-true
+ CompoundName cName1 = new CompoundName(" cName", properties);
+ CompoundName cName2 = new CompoundName(" cName ", properties);
+ assertTrue(cName1.equals(cName2));
+ assertTrue(cName2.equals(cName1));
+ assertEquals(0, cName1.compareTo(cName2));
+ assertEquals(0, cName2.compareTo(cName1));
+
+ // true-false
+ properties.setProperty(key, "false");
+ cName2 = new CompoundName(" cName ", properties);
+ assertTrue(cName1.equals(cName2));
+ assertFalse(cName2.equals(cName1));
+ assertEquals(0, cName1.compareTo(cName2));
+ assertTrue(cName2.compareTo(cName1) > 0);
+
+ // false-false
+ cName1 = new CompoundName(" cName", properties);
+ assertFalse(cName1.equals(cName2));
+ assertFalse(cName2.equals(cName1));
+ assertTrue(cName1.compareTo(cName2) < 0);
+ assertTrue(cName2.compareTo(cName1) > 0);
+ }
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ReferenceTest.java Thu Jun 24 21:55:52 2010
@@ -83,15 +83,35 @@ public class ReferenceTest extends TestC
assertEquals(1, reference.size());
}
- public void testConstructor_ByRefAddrNull() {
- Reference reference = new Reference(null, null);
-
- assertNull(reference.getClassName());
- assertNull(reference.getFactoryClassName());
- assertNull(reference.getFactoryClassLocation());
- assertNull(reference.get(0));
- assertEquals(1, reference.size());
- }
+ public void testConstructor_ByRefAddrNull() {
+ Reference reference = new Reference(null, null);
+ assertNull(reference.getClassName());
+ assertNull(reference.getFactoryClassName());
+ assertNull(reference.getFactoryClassLocation());
+ assertNull(reference.get(0));
+ assertEquals(1, reference.size());
+
+ try {
+ reference.get("type");
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+
+ try {
+ reference.toString();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+
+ try {
+ reference.hashCode();
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
public void testConstructor_ByFactory() {
String className = "java.util.Hashtable";
@@ -194,24 +214,25 @@ public class ReferenceTest extends TestC
assertEquals(refAddr2, ref.get(1));
}
- public void testAdd_ByIndexInvalidGreat() {
- String type = "Binary";
- BinaryRefAddr refAddr = new BinaryRefAddr(type, buffer);
- try {
- ref.add(1, refAddr);
- fail("This should throw a ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
+ public void testAdd_ByIndexInvalidGreat() {
+ BinaryRefAddr refAddr = new BinaryRefAddr("Binary", buffer);
+ try {
+ ref.add(1, refAddr);
+ fail("should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Expected
+ }
+ }
public void testAdd_ByIndexInvalidLess() {
String type = "Binary";
BinaryRefAddr refAddr = new BinaryRefAddr(type, buffer);
try {
ref.add(-1, refAddr);
- fail("This should throw a ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
+ fail("should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Expected
+ }
}
public void testGet_SimpleInvalidGreat() {
@@ -221,9 +242,10 @@ public class ReferenceTest extends TestC
try {
ref.get(ref.size());
- fail("This should throw a ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
+ fail("should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Expected
+ }
}
public void testGet_SimpleInvalidLess() {
@@ -233,9 +255,10 @@ public class ReferenceTest extends TestC
try {
ref.get(-1);
- fail("This should throw a ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
+ fail("should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Expected
+ }
}
public void testGet_ByType() {
@@ -269,8 +292,9 @@ public class ReferenceTest extends TestC
ref.add(refAddr);
try {
ref.get(null);
- fail("Should throw NullPointerException.");
+ fail("Should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
}
@@ -304,9 +328,10 @@ public class ReferenceTest extends TestC
public void testRemove_Invalid() {
try {
ref.remove(0);
- fail("This should throw a ArrayIndexOutOfBoundsException");
- } catch (ArrayIndexOutOfBoundsException e) {
- }
+ fail("should throw ArrayIndexOutOfBoundsException");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Expected
+ }
}
public void testClear_Simple() {
@@ -425,8 +450,9 @@ public class ReferenceTest extends TestC
try {
reference0.equals(reference1);
- fail("Should throw NullPointerException.");
+ fail("Should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
}
@@ -437,12 +463,7 @@ public class ReferenceTest extends TestC
Reference reference0 = new Reference(null, classFactory, location);
Reference reference2 = new Reference(className, classFactory, location);
-
- // try {
assertFalse(reference0.equals(reference2));
- // fail("Should throw NullPointerException.");
- // } catch (NullPointerException e) {
- // }
}
public void testEquals_NullClassName3() {
@@ -455,8 +476,9 @@ public class ReferenceTest extends TestC
try {
reference2.equals(reference0);
- fail("Should throw NullPointerException.");
+ fail("Should throw NullPointerException");
} catch (NullPointerException e) {
+ // Expected
}
}
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java Thu Jun 24 21:55:52 2010
@@ -493,7 +493,7 @@ public class HttpURLConnectionImpl exten
}
if (limit >= 0) {
- if (count > limit) {
+ if (count > limit && fixedMod) {
throw new IOException(Messages.getString("luni.26")); //$NON-NLS-1$
}
limit -= count;
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java Thu Jun 24 21:55:52 2010
@@ -1001,6 +1001,34 @@ public class RandomAccessFileTest extend
raf.close();
}
+ // Regression test for HARMONY-6542
+ public void testRandomAccessFile_seekMoreThan2gb() throws IOException {
+ if (File.separator != "/") {
+ // skip windows until a test can be implemented that doesn't
+ // require 2GB of free disk space
+ return;
+ }
+ // (all?) unix platforms support sparse files so this should not
+ // need to have 2GB free disk space to pass
+ RandomAccessFile raf = new RandomAccessFile(f, "rw");
+ // write a few bytes so we get more helpful error messages
+ // if we land in the wrong places
+ raf.write(1);
+ raf.write(2);
+ raf.seek(2147483647);
+ raf.write(3);
+ raf.write(4);
+ raf.write(5);
+ raf.write(6);
+ raf.seek(0);
+ assertEquals("seek 0", 1, raf.read());
+ raf.seek(2147483649L);
+ assertEquals("seek >2gb", 5, raf.read());
+ raf.seek(0);
+ assertEquals("seek back to 0", 1, raf.read());
+ raf.close();
+ }
+
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
Modified: harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java (original)
+++ harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpURLConnectionTest.java Thu Jun 24 21:55:52 2010
@@ -337,13 +337,29 @@ public class HttpURLConnectionTest exten
OutputStream out = conn.getOutputStream();
out.write(posted.getBytes());
+ //should not throw IOExeption
+ out.close();
+ }
+
+ /**
+ * When write bytes to HttpOutputSteam, only if fixed mode is true and the write number of bytes is
+ * greater than the limit of HttpOutputStream, the write method will throw IOException
+ * @throws IOException
+ */
+ public void test_writeWithFixedLengthDisableMode() throws IOException {
+ String bigString = "big String:/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java b/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java";
+ System.out.println(bigString.length());
- try {
- out.close();
- // expected
- } catch (IOException e) {
- fail("should not throw IOException");
- }
+ java.net.HttpURLConnection httpURLConnection = (HttpURLConnection) url
+ .openConnection();
+
+ httpURLConnection.setDoOutput(true);
+ httpURLConnection.setRequestMethod("POST");
+ httpURLConnection.setRequestProperty("Content-Length", "" + (168));
+
+ OutputStream out = httpURLConnection.getOutputStream();
+ //should not throw IOExeption
+ out.write(bigString.getBytes());
}
/**
Propchange: harmony/enhanced/java/branches/java6/common_resources/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,4 +1,4 @@
/harmony/enhanced/java/branches/mrh/common_resources:935751-941490
-/harmony/enhanced/java/trunk/common_resources:929253-956455
+/harmony/enhanced/java/trunk/common_resources:929253-957725
/harmony/enhanced/trunk/common_resources:476395-929252
/incubator/harmony/enhanced/trunk/common_resources:292550-476394
Modified: harmony/enhanced/java/branches/java6/common_resources/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/common_resources/make/depends.properties?rev=957726&r1=957725&r2=957726&view=diff
==============================================================================
--- harmony/enhanced/java/branches/java6/common_resources/make/depends.properties (original)
+++ harmony/enhanced/java/branches/java6/common_resources/make/depends.properties Thu Jun 24 21:55:52 2010
@@ -77,10 +77,10 @@ xalan.jar=${xalan.dir}/xalan.jar
xalan.url=${maven2.base}/xalan/xalan/2.7.0/xalan-2.7.0.jar
xalan.md5=a018d032c21a873225e702b36b171a10
-xerces.dir=${depends.jars}/xerces_2.9.1
+xerces.dir=${depends.jars}/xerces_2.10.0
xerces.zip=${xerces.dir}/xerces.zip
-xerces.url=http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.9.1.zip
-xerces.md5=a0e07ede1c3bd5231fe15eae24032b2e
+xerces.url=http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.10.0.zip
+xerces.md5=8da14a7b2848eff131b7cc10668887e8
bcprov.ver=bcprov-jdk15-138
bcprov.dir=${depends.jars}/${bcprov.ver}
Propchange: harmony/enhanced/java/branches/java6/drlvm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,5 +1,5 @@
/harmony/enhanced/java/branches/mrh/drlvm:935751-941490
-/harmony/enhanced/java/trunk/drlvm:929253-956455
+/harmony/enhanced/java/trunk/drlvm:929253-957725
/harmony/enhanced/trunk/drlvm:476395-929252
/harmony/enhanced/trunk/working_vm:476396-920147
/incubator/harmony/enhanced/trunk/working_vm:423974-476394
Propchange: harmony/enhanced/java/branches/java6/jdktools/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 24 21:55:52 2010
@@ -1,4 +1,4 @@
-/harmony/enhanced/java/trunk/jdktools:929253-956455
+/harmony/enhanced/java/trunk/jdktools:929253-957725
/harmony/enhanced/jdktools/trunk:630107-925933
/harmony/enhanced/trunk/jdktools:476395-929252
/harmony/enhanced/trunk/working_jdktools:476396-920147