harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r572619 - in /harmony/enhanced/classlib/trunk/modules/luni: ./ src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/ src/test/api/common/tests/api/java/net/ src/test/resources/org/apache/harmony/luni/tests/
Date Tue, 04 Sep 2007 11:11:36 GMT
Author: tellison
Date: Tue Sep  4 04:11:35 2007
New Revision: 572619

URL: http://svn.apache.org/viewvc?rev=572619&view=rev
Log:
Tests for HARMONY-4699 ([classlib][luni] URLConnection.getContentType() works with files incorrectly)

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.doc
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.htx
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.rtf
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/build.xml
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/build.xml?rev=572619&r1=572618&r2=572619&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/build.xml Tue Sep  4 04:11:35 2007
@@ -56,7 +56,7 @@
                 <include name="iohelp.h" />
                 <include name="exceptions.h" />
                 <include name="libglob.h" />
-                <include name="strhelp.h" />            	
+                <include name="strhelp.h" />
                 <include name="fdlibm.h" />
                 <include name="hymagic.h" />
                 <include name="jsig.h" />
@@ -281,9 +281,9 @@
         <compile-tests description="JUnit Tests" destdir="${hy.luni.bin.test}">
             <javac-elements>
                 <src>
-		    <pathelement location="${hy.luni.src.test.api}/common"/>
-	            <pathelement location="${hy.luni.src.test.api.java.platform}"/>
-                <pathelement location="${hy.luni.src.test}/impl"/>
+                    <pathelement location="${hy.luni.src.test.api}/common" />
+                    <pathelement location="${hy.luni.src.test.api.java.platform}" />
+                    <pathelement location="${hy.luni.src.test}/impl" />
                 </src>
                 <include name="**/*.java" />
             </javac-elements>
@@ -291,7 +291,7 @@
     </target>
 
     <target name="prepare-exclude">
-       <prepare-exclude-list moduleName="luni" dir="./make"
+        <prepare-exclude-list moduleName="luni" dir="./make"
                              result="${luni.exclude.file}"/>
     </target>
 
@@ -302,9 +302,9 @@
                     <pathelement path="${hy.luni.bin.test}"/>
                     <pathelement path="${hy.luni.src.test.resources}"/>
                     <pathelement path="../../build/tests"/>
-		    <fileset dir="${hy.hdk}/build/test/">
-		        <include name="*.jar" />
-		    </fileset>
+                    <fileset dir="${hy.hdk}/build/test/">
+                        <include name="*.jar" />
+                    </fileset>
                 </classpath>
                 <!-- Required by various tests that set security manager etc -->
                 <jvmarg value="-Djava.security.policy=../../support/src/test/resources/config/testing.policy"
/>
@@ -359,9 +359,7 @@
     <target name="copy-test-resources">
         <mkdir dir="${hy.luni.bin.test}" />
         <copy todir="${hy.luni.bin.test}" includeemptydirs="false">
-            <fileset dir="${hy.luni.src.test.resources}">
-                <exclude name="**/*.java" />
-            </fileset>
+            <fileset dir="${hy.luni.src.test.resources}" />
         </copy>
     </target>
 

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java?rev=572619&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
Tue Sep  4 04:11:35 2007
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.luni.tests.internal.net.www.protocol.file;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.harmony.luni.internal.net.www.protocol.file.FileURLConnection;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests for <code>FileURLConnection</code> class constructors and methods.
+ */
+public class FileURLConnectionTest extends TestCase {
+
+    static String getContentType(String fileName) throws IOException {
+        String resourceName = "org/apache/harmony/luni/tests/" + fileName;
+        URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
+        assertNotNull("Cannot find test resource " + resourceName, url);
+        return new FileURLConnection(url).getContentType();
+    }
+
+    public void testGetContentType() throws Exception {
+        // Regression for HARMONY-4699
+        assertEquals(getContentType("test.rtf"), "application/rtf");
+        assertEquals(getContentType("test.java"), "text/plain");
+        assertEquals(getContentType("test.doc"), "application/msword"); // RI would return
"content/unknown"
+        assertEquals(getContentType("test.htx"), "text/html");
+        assertEquals(getContentType("test.xml"), "application/xml");
+        assertEquals(getContentType("."), "text/plain");
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/file/FileURLConnectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java?rev=572619&r1=572618&r2=572619&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/net/URLConnectionTest.java
Tue Sep  4 04:11:35 2007
@@ -160,6 +160,26 @@
 		}
 	}
 
+        static String getContentType(String fileName) throws IOException {
+            String resourceName = "org/apache/harmony/luni/tests/" + fileName;
+            URL url = ClassLoader.getSystemClassLoader().getResource(resourceName);
+            assertNotNull("Cannot find test resource " + resourceName, url);
+            return url.openConnection().getContentType();
+        }
+
+        /**
+         * @tests java.net.URLConnection#getContentType()
+         */
+        public void test_getContentType_regression() throws IOException {
+            // Regression for HARMONY-4699
+            assertEquals(getContentType("test.rtf"), "application/rtf");
+            assertEquals(getContentType("test.java"), "text/plain");
+            assertEquals(getContentType("test.doc"), "application/msword"); // RI would return
"content/unknown"
+            assertEquals(getContentType("test.htx"), "text/html");
+            assertEquals(getContentType("test.xml"), "application/xml");
+            assertEquals(getContentType("."), "text/plain");
+        }
+
 	/**
 	 * @tests java.net.URLConnection#getDate()
 	 */

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.doc
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.doc?rev=572619&view=auto
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.doc
------------------------------------------------------------------------------
    svn:mime-type = application/msword

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.htx
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.htx?rev=572619&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.htx
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.htx
Tue Sep  4 04:11:35 2007
@@ -0,0 +1,22 @@
+<html>
+
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/* A bogus html file used to see if we can detect
+ * file type based on its file extension / content.
+ */
\ No newline at end of file

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java?rev=572619&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java
Tue Sep  4 04:11:35 2007
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/* A bogus java file used to see if we can detect
+ * file type based on its file extension.
+ */
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.rtf
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.rtf?rev=572619&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.rtf
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.rtf
Tue Sep  4 04:11:35 2007
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/* A bogus RTF file used to see if we can detect
+ * file type based on its file extension.
+ */
\ No newline at end of file

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml?rev=572619&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml
Tue Sep  4 04:11:35 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- A bogus XML file used to see if we can detect
+     file type based on its file extension / content.
+-->
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/org/apache/harmony/luni/tests/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message