You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by qi...@apache.org on 2009/04/19 13:15:34 UTC
svn commit: r766448 [1/4] - in /harmony/enhanced/classlib/branches/java6: ./
depends/files/ depends/jars/icu4j_3.8/ depends/jars/icu4j_4.0/
depends/manifests/icu4j_3.8/META-INF/ depends/manifests/icu4j_4.0/
depends/manifests/icu4j_4.0/META-INF/ make/ m...
Author: qiuxx
Date: Sun Apr 19 11:15:28 2009
New Revision: 766448
URL: http://svn.apache.org/viewvc?rev=766448&view=rev
Log:
Merge updates from classlib trunk@765922 since r761593
Added:
harmony/enhanced/classlib/branches/java6/depends/jars/icu4j_4.0/
- copied from r766264, harmony/enhanced/classlib/trunk/depends/jars/icu4j_4.0/
harmony/enhanced/classlib/branches/java6/depends/jars/icu4j_4.0/icu4j-4_0.jar
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/depends/jars/icu4j_4.0/icu4j-4_0.jar
harmony/enhanced/classlib/branches/java6/depends/jars/icu4j_4.0/icu4j-charsets-4_0.jar
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/depends/jars/icu4j_4.0/icu4j-charsets-4_0.jar
harmony/enhanced/classlib/branches/java6/depends/manifests/icu4j_4.0/
- copied from r766264, harmony/enhanced/classlib/trunk/depends/manifests/icu4j_4.0/
harmony/enhanced/classlib/branches/java6/depends/manifests/icu4j_4.0/META-INF/
- copied from r766264, harmony/enhanced/classlib/trunk/depends/manifests/icu4j_4.0/META-INF/
harmony/enhanced/classlib/branches/java6/depends/manifests/icu4j_4.0/META-INF/MANIFEST.MF
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/depends/manifests/icu4j_4.0/META-INF/MANIFEST.MF
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jars/
- copied from r766264, harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jars/
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jars/ant.jar
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/jars/ant.jar
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/largeClassUnpacked.jar
- copied unchanged from r766264, harmony/enhanced/classlib/trunk/modules/pack200/src/test/resources/org/apache/harmony/pack200/tests/largeClassUnpacked.jar
Removed:
harmony/enhanced/classlib/branches/java6/depends/jars/icu4j_3.8/icu4j-3_8.jar
harmony/enhanced/classlib/branches/java6/depends/jars/icu4j_3.8/icu4j-charsets-3_8.jar
harmony/enhanced/classlib/branches/java6/depends/manifests/icu4j_3.8/META-INF/MANIFEST.MF
Modified:
harmony/enhanced/classlib/branches/java6/NOTICE
harmony/enhanced/classlib/branches/java6/depends/files/bootclasspath.properties
harmony/enhanced/classlib/branches/java6/depends/files/java.security
harmony/enhanced/classlib/branches/java6/make/build-java.xml
harmony/enhanced/classlib/branches/java6/make/depends.properties
harmony/enhanced/classlib/branches/java6/make/properties.xml
harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/extras/TestRdnParser.java
harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/BufferedReader.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Scanner.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/ObjectInputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedWriterTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/CharacterTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ModifierTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/Collections2Test.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/CurrencyTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LinkedListTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/LocaleTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/TimeZoneTest.java
harmony/enhanced/classlib/branches/java6/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
harmony/enhanced/classlib/branches/java6/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
harmony/enhanced/classlib/branches/java6/modules/nio_char/src/main/java/java/nio/charset/Charset.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Archive.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/AttributeDefinitionBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BHSDCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BandSet.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/BcBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/ClassBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CodecEncoding.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/CpBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/FileBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/IcBands.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/MetadataBandGroup.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/PopulationCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/RunCodec.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/Segment.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/pack200/SegmentHeader.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java/org/apache/harmony/unpack200/BandSet.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/main/java5/org/apache/harmony/unpack200/Pack200PackerAdapter.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/ArchiveTest.java
harmony/enhanced/classlib/branches/java6/modules/pack200/src/test/java/org/apache/harmony/pack200/tests/CodecEncodingTest.java
harmony/enhanced/classlib/branches/java6/modules/portlib/src/test/native/hyfile/shared/hyfile.c
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
harmony/enhanced/classlib/branches/java6/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1StringType.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/asn1/ASN1UTCTime.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/provider/cert/X509CertFactoryImpl.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x501/AttributeTypeAndValue.java
harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Identity2Test.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStore3Test.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyStorePrivateKeyEntryTest.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/CertificateFactory4Test.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java.injected/java/security/cert/X509CertificateTest.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/impl/java/org/apache/harmony/security/tests/provider/cert/X509CertFactoryPerfTest.java
harmony/enhanced/classlib/branches/java6/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/TestUtils.java
Modified: harmony/enhanced/classlib/branches/java6/NOTICE
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/NOTICE?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/NOTICE (original)
+++ harmony/enhanced/classlib/branches/java6/NOTICE Sun Apr 19 11:15:28 2009
@@ -1,11 +1,5 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the Apache Harmony distribution. ==
- =========================================================================
-
Apache Harmony
-Copyright 2006, 2007 The Apache Software Foundation
+Copyright 2006, 2009 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Modified: harmony/enhanced/classlib/branches/java6/depends/files/bootclasspath.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/depends/files/bootclasspath.properties?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/depends/files/bootclasspath.properties (original)
+++ harmony/enhanced/classlib/branches/java6/depends/files/bootclasspath.properties Sun Apr 19 11:15:28 2009
@@ -165,8 +165,8 @@
# ICU functionality for text/characters are provided by the ICU4J
# and ICU4J-charsets JAR files.
-bootclasspath.31=icu4j_3.8/icu4j-3_8.jar
-bootclasspath.32=icu4j_3.8/icu4j-charsets-3_8.jar
+bootclasspath.31=icu4j_4.0/icu4j-4_0.jar
+bootclasspath.32=icu4j_4.0/icu4j-charsets-4_0.jar
# The following JARs are from Xerces/Xalan
bootclasspath.34=xalan-j_2.7.0/xalan.jar
Modified: harmony/enhanced/classlib/branches/java6/depends/files/java.security
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/depends/files/java.security?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/depends/files/java.security (original)
+++ harmony/enhanced/classlib/branches/java6/depends/files/java.security Sun Apr 19 11:15:28 2009
@@ -56,8 +56,8 @@
# and an optional policy file in the user's home directory.
# It is possible to specify any number of policy files, via policy.url.n keys.
# See also: "JavaTM 2 Platform Security Architecture.", chapter 3. Permissions and Security Policy
-policy.url.1=file:/${java.home}/lib/security/java.policy
-policy.url.2=file:/${user.home}/.java.policy
+policy.url.1=file:${java.home}/lib/security/java.policy
+policy.url.2=file:${user.home}/.java.policy
# Flag to enable/disable properties expansion (${...}) in policy files.
Modified: harmony/enhanced/classlib/branches/java6/make/build-java.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/make/build-java.xml?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/make/build-java.xml (original)
+++ harmony/enhanced/classlib/branches/java6/make/build-java.xml Sun Apr 19 11:15:28 2009
@@ -203,7 +203,7 @@
<fileset dir="${depends.jars}">
<patternset includes="bcel-5.2/*.jar" />
<patternset includes="asm-3.1/*.jar" />
- <patternset includes="icu4j_3.8/*.jar" />
+ <patternset includes="icu4j_4.0/*.jar" />
<patternset includes="mx4j_3.0.2/*.jar" />
<patternset includes="xalan-j_2.7.0/*.jar" />
<patternset includes="xerces_2.9.1/*.jar" />
Modified: harmony/enhanced/classlib/branches/java6/make/depends.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/make/depends.properties?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/make/depends.properties (original)
+++ harmony/enhanced/classlib/branches/java6/make/depends.properties Sun Apr 19 11:15:28 2009
@@ -128,7 +128,7 @@
dejavu-fonts.dir=${depends.dir}/dejavu-fonts
dejavu-fonts.fonts.dir=${depends.dir}/dejavu-fonts/dejavu-ttf-2.18
dejavu-fonts.zip=${dejavu-fonts.dir}/dejavu-ttf-2.18-1.zip
-dejavu-fonts.url=http://dfn.dl.sourceforge.net/sourceforge/dejavu/dejavu-ttf-2.18-1.zip
+dejavu-fonts.url=${sf.base}/dejavu/dejavu-ttf-2.18-1.zip
dejavu-fonts.md5=72e0a87ec1f9c5c26c66eabcf1e2018e
derby.dir=${depends.jars}/derby-10.3.1.4
Modified: harmony/enhanced/classlib/branches/java6/make/properties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/make/properties.xml?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/make/properties.xml (original)
+++ harmony/enhanced/classlib/branches/java6/make/properties.xml Sun Apr 19 11:15:28 2009
@@ -444,6 +444,7 @@
</target>
<target name="test-jre-vm-info" depends="-get-test-vm-output">
+ <echo level="info" message="java -version${line.separator}${test.vm.info.tmp}" />
<!-- Add other runtime names here -->
<condition property="hy.test.vm.name" value="ri" >
<contains string="${test.vm.info.tmp}" substring="HotSpot"/>
@@ -453,8 +454,8 @@
</condition>
<!-- FIXME current behavior relies on the fact that J9 VM doesn't
support -version parameter -->
- <condition property="hy.test.vm.name" value="drl" else="ibm" >
- <contains string="${test.vm.info.tmp}" substring="harmony" />
+ <condition property="hy.test.vm.name" value="ibm" else="drl" >
+ <contains string="${test.vm.info.tmp}" substring="IBM" casesensitive="false" />
</condition>
<echo level="info" message="hy.test.vm.name = ${hy.test.vm.name}" />
</target>
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/main/java/java/beans/beancontext/BeanContextSupport.java Sun Apr 19 11:15:28 2009
@@ -288,10 +288,12 @@
// trigger hook
synchronized (child) {
+ addSerializable(childBCSC);
childJustAddedHook(child, childBCSC);
}
if (proxy != null) {
synchronized (proxy) {
+ addSerializable(proxyBCSC);
childJustAddedHook(proxy, proxyBCSC);
}
}
@@ -987,10 +989,12 @@
// trigger hook
synchronized (child) {
+ removeSerializable(childBCSC);
childJustRemovedHook(child, childBCSC);
}
if (peer != null) {
synchronized (peer) {
+ removeSerializable(peerBCSC);
childJustRemovedHook(peer, peerBCSC);
}
}
@@ -1243,19 +1247,6 @@
serializing = true;
try {
- // count serializable children
- synchronized (children) {
- serializable = 0;
- for (Iterator iter = children.values().iterator(); iter
- .hasNext();) {
- BCSChild bcsc = (BCSChild) iter.next();
- if (bcsc.child instanceof Serializable
- && (bcsc.proxyPeer == null || bcsc.proxyPeer instanceof Serializable)) {
- serializable++;
- }
- }
- }
-
oos.defaultWriteObject();
bcsPreSerializationHook(oos);
@@ -1309,6 +1300,29 @@
}
}
+ /*
+ * Increase variable serializable if child and proxyPeer fields of the given
+ * BCSChild object are serializable
+ */
+ private void addSerializable(BCSChild bcsc) {
+ if (bcsc.child instanceof Serializable
+ && (bcsc.proxyPeer == null || bcsc.proxyPeer instanceof Serializable)) {
+ serializable++;
+ }
+ }
+
+ /*
+ * Decrease variable serializable if child and proxyPeer fields of the given
+ * BCSChild object are serializable
+ */
+ private void removeSerializable(BCSChild bcsc) {
+ if (serializable > 0
+ && bcsc.child instanceof Serializable
+ && (bcsc.proxyPeer == null || bcsc.proxyPeer instanceof Serializable)) {
+ serializable--;
+ }
+ }
+
}
Modified: harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextSupportTest.java Sun Apr 19 11:15:28 2009
@@ -1422,6 +1422,43 @@
support.records.assertEndOfRecords();
}
+ public void test_readChildren_NPE_scenario1() throws Exception {
+ BeanContextSupport beanContextSupport = new BeanContextSupport();
+ beanContextSupport.add(beanContextSupport);
+ assertEquals(1, beanContextSupport.size());
+ assertFalse(beanContextSupport.isSerializing());
+ try {
+ beanContextSupport.readChildren((ObjectInputStream) null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ }
+
+ public void test_readChildren_NPE_scenario2() throws Exception {
+ BeanContextSupport beanContextSupport = new BeanContextSupport();
+ beanContextSupport.readChildren((ObjectInputStream) null);
+ }
+
+ public void test_readChildren_NPE_scenario3() throws Exception {
+ BeanContextSupport beanContextSupport = new BeanContextSupport();
+ beanContextSupport.add(new Object());
+ beanContextSupport.readChildren((ObjectInputStream) null);
+ }
+
+ public void test_readChildren_NPE_scenario4() throws Exception {
+ BeanContextSupport beanContextSupport = new BeanContextSupport();
+ beanContextSupport.add("Serializable");
+ try {
+ beanContextSupport.readChildren((ObjectInputStream) null);
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // Expected
+ }
+ beanContextSupport.remove("Serializable");
+ beanContextSupport.readChildren((ObjectInputStream) null);
+ }
+
public void testRemoveAll() {
MockBeanContextSupport support = new MockBeanContextSupport();
support.records.assertRecord("initialize", null);
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/extras/TestRdnParser.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/extras/TestRdnParser.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/extras/TestRdnParser.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/extras/TestRdnParser.java Sun Apr 19 11:15:28 2009
@@ -918,13 +918,13 @@
* <p>Test method to test if the null character in utf8 where is put when the types are not equals between them.</p>
*
*/
- public void testRDNNULL() {
+ public void testRDNNULL() throws Exception {
try {
String y="ca=nine+type="+Rdn.escapeValue("\\00");
Rdn x=new Rdn("ca=nine+type=\"liom,\"+type=\"\\00\"");
byte[] temp=new byte[]{99,97,61,110,105,110,101,43,116,121,112,101,61,0,43,116,121,112,101,61,108,105,111,109,92,44};
for(int i=0;i<26;i++){
- assertEquals(temp[i],x.toString().getBytes()[i]);
+ assertEquals(temp[i],x.toString().getBytes("UTF-8")[i]);
}
x=new Rdn("ca=nine+pe=\"liom,\"+type=\"\\00\"");
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common Sun Apr 19 11:15:28 2009
@@ -1,4 +1,3 @@
org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
org/apache/harmony/luni/tests/java/net/ExcludedProxyTest.java
org/apache/harmony/luni/tests/java/util/FormatterTest.java
-org/apache/harmony/luni/tests/java/util/ScannerTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/BufferedReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/BufferedReader.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/BufferedReader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/BufferedReader.java Sun Apr 19 11:15:28 2009
@@ -211,6 +211,7 @@
if (pos < count || fillbuf() != -1) {
return buf[pos++];
}
+ markpos = -1;
return -1;
}
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/File.java Sun Apr 19 11:15:28 2009
@@ -297,12 +297,8 @@
&& (newLength > (uncIndex + 1) || (newLength == 2 && newPath[0] != separatorChar))) {
newLength--;
}
- String tempPath = new String(newPath, 0, newLength);
- // If it's the same keep it identical for SecurityManager purposes
- if (!tempPath.equals(origPath)) {
- return tempPath;
- }
- return origPath;
+
+ return new String(newPath, 0, newLength);
}
/**
@@ -315,11 +311,15 @@
* @see java.lang.SecurityManager#checkRead(FileDescriptor)
*/
public boolean canRead() {
+ if (path.length() == 0) {
+ return false;
+ }
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
}
- return exists() && !isWriteOnlyImpl(properPath(true));
+ byte[] pp = properPath(true);
+ return existsImpl(pp) && !isWriteOnlyImpl(pp);
}
/**
@@ -1085,10 +1085,17 @@
if (security != null) {
security.checkRead(path);
}
- if (!isDirectory() || !canRead()) {
+
+ if (path.length() == 0) {
+ return null;
+ }
+
+ byte[] bs = properPath(true);
+ if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
return null;
}
- byte[][] implList = listImpl(properPath(true));
+
+ byte[][] implList = listImpl(bs);
if (implList == null) {
// empty list
return new String[0];
@@ -1178,10 +1185,17 @@
if (security != null) {
security.checkRead(path);
}
- if (!isDirectory() || !canRead()) {
+
+ if (path.length() == 0) {
+ return null;
+ }
+
+ byte[] bs = properPath(true);
+ if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
return null;
}
- byte[][] implList = listImpl(properPath(true));
+
+ byte[][] implList = listImpl(bs);
if (implList == null) {
return new File[0];
}
@@ -1218,24 +1232,30 @@
if (security != null) {
security.checkRead(path);
}
- if (!isDirectory() || !canRead()) {
+
+ if (path.length() == 0) {
+ return null;
+ }
+
+ byte[] bs = properPath(true);
+ if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
return null;
}
- byte[][] implList = listImpl(properPath(true));
+
+ byte[][] implList = listImpl(bs);
if (implList == null) {
// empty list
return new String[0];
}
- java.util.Vector<String> tempResult = new java.util.Vector<String>();
+ List<String> tempResult = new ArrayList<String>();
for (int index = 0; index < implList.length; index++) {
String aName = Util.toString(implList[index]);
if (filter == null || filter.accept(this, aName)) {
- tempResult.addElement(aName);
+ tempResult.add(aName);
}
}
- String[] result = new String[tempResult.size()];
- tempResult.copyInto(result);
- return result;
+
+ return tempResult.toArray(new String[tempResult.size()]);
}
private synchronized static native byte[][] listImpl(byte[] path);
@@ -1418,9 +1438,7 @@
} else {
userdir = System.getProperty("user.dir"); //$NON-NLS-1$
}
- if ((properPath = properPathImpl(pathBytes)) != null) {
- return properPath;
- }
+
if (path.length() == 0) {
return properPath = Util.getUTF8Bytes(userdir);
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/URLClassLoader.java Sun Apr 19 11:15:28 2009
@@ -302,20 +302,18 @@
}
class URLJarHandler extends URLHandler {
- JarFile jf;
- String prefixName;
- IndexFile index = null;
- Map<URL, URLHandler> subHandlers = new HashMap<URL, URLHandler>();
+ final JarFile jf;
+ final String prefixName;
+ final IndexFile index;
+ final Map<URL, URLHandler> subHandlers = new HashMap<URL, URLHandler>();
public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName) {
super(url);
this.jf = jf;
this.prefixName = prefixName;
this.codeSourceUrl = jarURL;
- JarEntry je = jf.getJarEntry("META-INF/INDEX.LIST"); //$NON-NLS-1$
- if (je != null) {
- index = IndexFile.readIndexFile(jf, je, url);
- }
+ final JarEntry je = jf.getJarEntry("META-INF/INDEX.LIST"); //$NON-NLS-1$
+ this.index = (je == null ? null : IndexFile.readIndexFile(jf, je, url));
}
public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName, IndexFile index) {
@@ -343,6 +341,7 @@
String indexedName = (pos > 0) ? name.substring(0, pos) : name;
ArrayList<URL> urls = index.get(indexedName);
if (urls != null) {
+ urls.remove(url);
for (URL url : urls) {
URLHandler h = getSubHandler(url);
if (h != null) {
@@ -378,6 +377,7 @@
urls = index.get(packageName);
}
if (urls != null) {
+ urls.remove(url);
for (URL url : urls) {
URLHandler h = getSubHandler(url);
if (h != null) {
@@ -458,6 +458,7 @@
String indexedName = (pos > 0) ? name.substring(0, pos) : name;
ArrayList<URL> urls = index.get(indexedName);
if (urls != null) {
+ urls.remove(url);
for (URL url : urls) {
URLHandler h = getSubHandler(url);
if (h != null) {
@@ -474,7 +475,7 @@
private synchronized URLHandler getSubHandler(URL url) {
URLHandler sub = subHandlers.get(url);
- if (url != null) {
+ if (sub != null) {
return sub;
}
String protocol = url.getProtocol();
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java Sun Apr 19 11:15:28 2009
@@ -1983,12 +1983,17 @@
*
* @throws IndexOutOfBoundsException
* if index1 or index2 is out of range of this list
+ * @since 1.4
*/
@SuppressWarnings("unchecked")
public static void swap(List<?> list, int index1, int index2) {
if (list == null) {
throw new NullPointerException();
}
+ final int size = list.size();
+ if (index1 < 0 || index1 >= size || index2 < 0 || index2 >= size) {
+ throw new IndexOutOfBoundsException();
+ }
if (index1 == index2) {
return;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/LinkedList.java Sun Apr 19 11:15:28 2009
@@ -340,6 +340,9 @@
if (adding == 0) {
return false;
}
+ Collection<? extends E> elements = (collection == this) ?
+ new ArrayList<E>(collection) : collection;
+
Link<E> previous = voidLink;
if (location < (size / 2)) {
for (int i = 0; i < location; i++) {
@@ -351,7 +354,7 @@
}
}
Link<E> next = previous.next;
- for (E e : collection) {
+ for (E e : elements) {
Link<E> newLink = new Link<E>(e, previous, null);
previous.next = newLink;
previous = newLink;
@@ -376,8 +379,11 @@
if (adding == 0) {
return false;
}
+ Collection<? extends E> elements = (collection == this) ?
+ new ArrayList<E>(collection) : collection;
+
Link<E> previous = voidLink.previous;
- for (E e : collection) {
+ for (E e : elements) {
Link<E> newLink = new Link<E>(e, previous, null);
previous.next = newLink;
previous = newLink;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Scanner.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Scanner.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Scanner.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Scanner.java Sun Apr 19 11:15:28 2009
@@ -818,9 +818,11 @@
boolean hasNextLine = false;
while (true) {
if (matcher.find()) {
- matchSuccessful = true;
- hasNextLine = true;
- break;
+ if (inputExhausted || matcher.end() != bufferLength) {
+ matchSuccessful = true;
+ hasNextLine = true;
+ break;
+ }
} else {
if (inputExhausted) {
matchSuccessful = false;
@@ -1392,10 +1394,13 @@
String result = null;
while (true) {
if (matcher.find()) {
- matchSuccessful = true;
- findStartIndex = matcher.end();
- result = matcher.group();
- break;
+ if (inputExhausted || matcher.end() != bufferLength
+ || bufferLength < buffer.capacity()) {
+ matchSuccessful = true;
+ findStartIndex = matcher.end();
+ result = matcher.group();
+ break;
+ }
} else {
if (inputExhausted) {
matchSuccessful = false;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/jar/JarURLConnection.java Sun Apr 19 11:15:28 2009
@@ -23,8 +23,6 @@
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
import java.net.ContentHandler;
import java.net.ContentHandlerFactory;
import java.net.MalformedURLException;
@@ -35,7 +33,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c Sun Apr 19 11:15:28 2009
@@ -36,7 +36,7 @@
#define PORT_LIB_OPTION "_org.apache.harmony.vmi.portlib"
-#define HY_COPYRIGHT_STRING "Apache Harmony Launcher : (c) Copyright 1991, 2008 The Apache Software Foundation or its licensors, as applicable."
+#define HY_COPYRIGHT_STRING "Apache Harmony Launcher : (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable."
/* Tools launchers will invoke HY_TOOLS_PACKAGE+"."+<execname>+"."+HY_TOOLS_MAIN_TYPE */
#define HY_TOOLS_PACKAGE "org.apache.harmony.tools"
@@ -58,7 +58,7 @@
PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle,
jint version, jboolean ignoreUnrecognized, char *mainClass,
UDATA classArg, char *propertiesFileName,
- int isStandaloneJar, char *vmdllsubdir));
+ int isStandaloneJar, char *vmdllsubdir, int versionFlag));
static int createVMArgs
PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv,
jint version, jboolean ignoreUnrecognized,
@@ -227,8 +227,9 @@
/* The arg is a JAR file to run */
isStandaloneJar = 1;
}
- if (0 == strcmp ("-version", argv[i])) {
- versionFlag = 1;
+ if (0 == strncmp ("-version", argv[i], 8)) {
+ /* Display version information */
+ versionFlag = i;
}
if (0 == strcmp ("-showversion", argv[i])) {
/* We are being asked to print our version and continue */
@@ -363,12 +364,6 @@
}
}
- if (versionFlag == 1) {
- /*
- * We are being asked to print our version, and quit
- */
- hyfile_printf (PORTLIB, HYPORT_TTY_OUT, HY_COPYRIGHT_STRING "\n");
- }
/* set up the properties file */
propertiesFileName = hymem_allocate_memory (strlen (vmiPath) + 12);
if (propertiesFileName == NULL)
@@ -392,7 +387,7 @@
/* main launcher processing in this function */
rc = invocation
(PORTLIB, argc, argv, handle, JNI_VERSION_1_4, JNI_TRUE, mainClass,
- classArg, propertiesFileName, isStandaloneJar, vmdllsubdir);
+ classArg, propertiesFileName, isStandaloneJar, vmdllsubdir, versionFlag);
if (rc)
{
/* Print an error message except in the case where an uncaught Exception
@@ -642,7 +637,7 @@
invocation (HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle,
jint version, jboolean ignoreUnrecognized, char *mainClass,
UDATA classArg, char *propertiesFileName,
- int isStandaloneJar, char *vmdllsubdir)
+ int isStandaloneJar, char *vmdllsubdir, int versionFlag)
{
JavaVMInitArgs vm_args;
JavaVM *jvm;
@@ -678,6 +673,27 @@
}
rc = 0;
+
+ if (versionFlag) {
+ jclass clazz;
+ jmethodID mID;
+ jstring jStrObject;
+
+ jStrObject = (*env)->NewStringUTF (env, argv[versionFlag]);
+ if (!jStrObject) return 3;
+
+ clazz = (*env)->FindClass (env, "org/apache/harmony/luni/util/Version");
+ if (!clazz) return 3;
+
+ mID = (*env)->GetStaticMethodID (env, clazz, "version",
+ "(Ljava/lang/String;)V");
+ if (!mID) return 3;
+
+ (*env)->CallStaticVoidMethod(env, clazz, mID, jStrObject);
+
+ return 0;
+ }
+
if (mainClass)
{
if (isStandaloneJar)
@@ -952,7 +968,8 @@
{
if ( (strcmp (argv[i], "-jar") != 0)
&& (strncmp (argv[i], "-vmdir:", 7) != 0)
- && (strncmp (argv[i], "-vm:", 4) != 0) )
+ && (strncmp (argv[i], "-vm:", 4) != 0)
+ && (strncmp (argv[i], "-version", 8) != 0))
{
/* special coding for -classpath and -cp */
/* they get passed to the vm as -Djava.class.path */
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java Sun Apr 19 11:15:28 2009
@@ -37,6 +37,8 @@
import java.util.List;
import java.util.Map;
+import tests.support.Support_Jetty;
+
import junit.framework.TestCase;
/**
@@ -249,7 +251,13 @@
}
}
- public void setUp() {
+ private int jettyPort = 0;
+
+ private String jettyURL;
+
+ public void setUp() throws Exception {
+ jettyPort = Support_Jetty.startDefaultHttpServer();
+ jettyURL = "http://localhost:" + jettyPort + "/servlet";
if (DEBUG) {
System.out.println("\n==============================");
System.out.println("===== Execution: " + getName());
@@ -300,7 +308,7 @@
* @tests HttpURLConnection.getHeaderFields
*/
public void test_getHeaderFields() throws Exception {
- URL url = new URL("http://www.apache.org");
+ URL url = new URL(jettyURL);
HttpURLConnection httpURLConnect = (HttpURLConnection) url
.openConnection();
assertEquals(200, httpURLConnect.getResponseCode());
@@ -361,7 +369,7 @@
* Test whether getOutputStream can work after connection
*/
public void test_getOutputStream_AfterConnect() throws Exception {
- URL url = new URL("http://www.apache.org");
+ URL url = new URL(jettyURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.connect();
@@ -421,15 +429,16 @@
*/
public void testUsingProxy2() throws Exception {
try {
- System.setProperty("http.proxyHost", "www.apache.org");
- URL url = new URL("http://www.apache.org");
+ System.setProperty("http.proxyHost", "localhost");
+ System.setProperty("http.proxyPort", jettyPort + "");
+ URL url = new URL(jettyURL);
HttpURLConnection urlConnect = (HttpURLConnection) url
.openConnection();
urlConnect.getInputStream();
assertTrue(urlConnect.usingProxy());
System.setProperty("http.proxyPort", "81");
- url = new URL("http://www.apache.org");
+ url = new URL(jettyURL);
urlConnect = (HttpURLConnection) url.openConnection();
urlConnect.getInputStream();
assertFalse(urlConnect.usingProxy());
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java Sun Apr 19 11:15:28 2009
@@ -26,9 +26,10 @@
import java.io.Reader;
import java.io.StringReader;
+import junit.framework.TestCase;
import tests.support.Support_StringReader;
-public class BufferedReaderTest extends junit.framework.TestCase {
+public class BufferedReaderTest extends TestCase {
BufferedReader br;
@@ -490,9 +491,37 @@
return;
}
-
}
+ public void test_reset_IOException() throws Exception {
+ int[] expected = new int[] { '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', -1 };
+ br = new BufferedReader(new Support_StringReader("1234567890"));
+ br.mark(10);
+ for (int i = 0; i < 11; i++) {
+ assertEquals(expected[i], br.read());
+ }
+ try {
+ br.reset();
+ fail("should throw IOException");
+ } catch (IOException e) {
+ // Expected
+ }
+ for (int i = 0; i < 11; i++) {
+ assertEquals(-1, br.read());
+ }
+
+ br = new BufferedReader(new Support_StringReader("1234567890"));
+ br.mark(10);
+ for (int i = 0; i < 10; i++) {
+ assertEquals(expected[i], br.read());
+ }
+ br.reset();
+ for (int i = 0; i < 11; i++) {
+ assertEquals(expected[i], br.read());
+ }
+ }
+
/**
* @tests java.io.BufferedReader#skip(long)
*/
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java Sun Apr 19 11:15:28 2009
@@ -152,6 +152,7 @@
// Expected
} finally {
in.close();
+ file.delete();
}
}
@@ -363,6 +364,40 @@
}
}
+ public void test_getChannel() throws Exception {
+ FileInputStream fis = new FileInputStream(fileName);
+ assertEquals(0, fis.getChannel().position());
+ int r;
+ int count = 1;
+ while((r = fis.read()) != -1) {
+ assertEquals(count++, fis.getChannel().position());
+ }
+ fis.close();
+
+ try {
+ fis.getChannel().position();
+ fail("should throw ClosedChannelException");
+ } catch(java.nio.channels.ClosedChannelException e){
+ // Expected
+ }
+
+ fis = new FileInputStream(fileName);
+ assertEquals(0, fis.getChannel().position());
+ byte[] bs = new byte[10];
+ r = fis.read(bs);
+ assertEquals(10, fis.getChannel().position());
+ fis.close();
+
+ fis = new FileInputStream(fileName);
+ assertEquals(0, fis.getChannel().position());
+ bs = new byte[10];
+ fis.skip(100);
+ assertEquals(100, fis.getChannel().position());
+ r = fis.read(bs);
+ assertEquals(110, fis.getChannel().position());
+ fis.close();
+ }
+
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java?rev=766448&r1=766447&r2=766448&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java Sun Apr 19 11:15:28 2009
@@ -39,6 +39,8 @@
public String fileString = "Test_All_Tests\nTest_java_io_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_lang_Cl
assNotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_
Object\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_Sock
etException\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
+ byte[] bytes;
+
/**
* @tests java.io.FileOutputStream#FileOutputStream(java.io.File)
*/
@@ -157,6 +159,9 @@
fail("Should throw NullPointerException");
} catch (NullPointerException e) {
// Expected
+ } finally {
+ out.close();
+ file.delete();
}
}
@@ -234,17 +239,118 @@
File tmpfile = File.createTempFile("FileOutputStream", "tmp");
tmpfile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tmpfile);
- byte[] b = new byte[10];
- for (int i = 0; i < b.length; i++) {
- b[i] = (byte) i;
- }
- fos.write(b);
+ fos.write(bytes);
fos.flush();
fos.close();
FileOutputStream f = new FileOutputStream(tmpfile, true);
assertEquals(10, f.getChannel().position());
}
+ public void test_getChannel_Append() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, true);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(20, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(30, fos.getChannel().position());
+ fos.close();
+
+ try {
+ fos.getChannel().position();
+ fail("should throw ClosedChannelException");
+ } catch (java.nio.channels.ClosedChannelException e){
+ // Expected
+ }
+ }
+
+ public void test_getChannel_UnAppend() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, false);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(20, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(30, fos.getChannel().position());
+ fos.close();
+
+ try {
+ fos.getChannel().position();
+ fail("should throw ClosedChannelException");
+ } catch (java.nio.channels.ClosedChannelException e){
+ // Expected
+ }
+ }
+
+ public void test_getChannel_Unappend_Unappend() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, false);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+
+ fos = new FileOutputStream(tmpfile, false);
+ assertEquals(0, fos.getChannel().position());
+ fos.close();
+ }
+
+ public void test_getChannel_Unappend_Append() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, false);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+
+ fos = new FileOutputStream(tmpfile, true);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+ }
+
+ public void test_getChannel_Append_Unappend() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, true);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+
+ fos = new FileOutputStream(tmpfile, false);
+ assertEquals(0, fos.getChannel().position());
+ fos.close();
+ }
+
+ public void test_getChanne_Append_Append() throws IOException {
+ File tmpfile = File.createTempFile("FileOutputStream", "tmp");
+ tmpfile.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmpfile, true);
+ assertEquals(0, fos.getChannel().position());
+ fos.write(bytes);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+
+ fos = new FileOutputStream(tmpfile, true);
+ assertEquals(10, fos.getChannel().position());
+ fos.close();
+ }
+
+ protected void setUp() {
+ bytes = new byte[10];
+ for (int i = 0; i < bytes.length; i++) {
+ bytes[i] = (byte) i;
+ }
+ }
+
/**
* Tears down the fixture, for example, close a network connection. This
* method is called after a test is executed.