[jboss-svn-commits] JBoss Common SVN: r4912 - in common-core/branches/2.2.18.GA_JBPAPP-8068: src/test/java/org/jboss/test and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Mar 6 20:12:02 EST 2012


Author: bmaxwell
Date: 2012-03-06 20:12:01 -0500 (Tue, 06 Mar 2012)
New Revision: 4912

Added:
   common-core/branches/2.2.18.GA_JBPAPP-8068/src/test/java/org/jboss/test/jbpapp8065/
   common-core/branches/2.2.18.GA_JBPAPP-8068/src/test/java/org/jboss/test/jbpapp8065/JBPAPP8065UnitTestCase.java
Modified:
   common-core/branches/2.2.18.GA_JBPAPP-8068/pom.xml
Log:
[JBPAPP-8068] adding testcase

Modified: common-core/branches/2.2.18.GA_JBPAPP-8068/pom.xml
===================================================================
--- common-core/branches/2.2.18.GA_JBPAPP-8068/pom.xml	2012-03-06 19:26:44 UTC (rev 4911)
+++ common-core/branches/2.2.18.GA_JBPAPP-8068/pom.xml	2012-03-07 01:12:01 UTC (rev 4912)
@@ -61,6 +61,7 @@
           <includes>
             <include>**/*TestCase.java</include>
           </includes>
+          <forkMode>always</forkMode>
         </configuration>
       </plugin>
       <plugin>

Added: common-core/branches/2.2.18.GA_JBPAPP-8068/src/test/java/org/jboss/test/jbpapp8065/JBPAPP8065UnitTestCase.java
===================================================================
--- common-core/branches/2.2.18.GA_JBPAPP-8068/src/test/java/org/jboss/test/jbpapp8065/JBPAPP8065UnitTestCase.java	                        (rev 0)
+++ common-core/branches/2.2.18.GA_JBPAPP-8068/src/test/java/org/jboss/test/jbpapp8065/JBPAPP8065UnitTestCase.java	2012-03-07 01:12:01 UTC (rev 4912)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jbpapp8065;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
+
+import org.jboss.net.protocol.file.FileURLConnection;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for JBPAPP-8065
+ *
+ * @see https://issues.jboss.org/browse/JBPAPP-8065
+ * 
+ * @author bmaxwell
+ */
+public class JBPAPP8065UnitTestCase extends TestCase
+{
+   public JBPAPP8065UnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testJBPAPP806_UseURI_False()
+   {
+      System.setProperty("org.jboss.net.protocol.file.useURI", "false");
+      URL url = null;
+      try
+      {
+         url = new URL("file:non-exisitant-file-" + new Date().getTime());
+         try
+         {            
+            URLConnection urlConnection = new FileURLConnection(url); 
+            urlConnection.connect();
+         }
+         catch (IOException e)
+         {
+            // this will catch a FileNotFoundException
+            // This is the expected result when -Dorg.jboss.net.protocol.file.useURI=false
+            return;
+         }
+         catch(IllegalArgumentException iae)
+         {
+            iae.printStackTrace();
+            fail("URL: " + url + " should have thrown a FileNotFoundException when -Dorg.jboss.net.protocol.file.useURI=false see JBPAPP-8065");
+         }
+         fail("URL: " + url + " should have thrown a FileNotFoundException when -Dorg.jboss.net.protocol.file.useURI=false see JBPAPP-8065");
+      }
+      catch (MalformedURLException e)
+      {
+         e.printStackTrace();
+         fail("URL: " + url + " should not be malformed");
+      }
+   }
+   
+//   This is commented out because the system property is set in a static block in FileURLConnection and we maven makes it hard to run the tests in separate jvm 
+//   The testJBPAPP806_UseURI_False will ensure the old functionailty works org.jboss.net.protocol.file.useURI
+//   public void testJBPAPP806_UseURI_True()
+//   {
+//      System.setProperty("org.jboss.net.protocol.file.useURI", "true");
+//      URL url = null;
+//      try
+//      {
+//         url = new URL("file:non-exisitant-file-" + new Date().getTime());
+//         try
+//         {            
+//            URLConnection urlConnection = new FileURLConnection(url);
+//            urlConnection.connect();
+//         }
+//         catch (IOException e)
+//         {
+//            // this will catch a FileNotFoundException
+//            // This is NOT the expected result when -Dorg.jboss.net.protocol.file.useURI=true
+//            fail("URL: " + url + " should have thrown an IllegalArgumentException when -Dorg.jboss.net.protocol.file.useURI=true see JBPAPP-8065");
+//         }
+//         catch(IllegalArgumentException iae)
+//         {
+//            // This is the expected results the url.toURI() will throw given file:non... is not a valid URI
+//            return;   
+//         }
+//         fail("URL: " + url + " should have thrown an IllegalArgumentException when -Dorg.jboss.net.protocol.file.useURI=true see JBPAPP-8065");
+//      }
+//      catch (MalformedURLException e)
+//      {
+//         e.printStackTrace();
+//         fail("URL: " + url + " should not be malformed");
+//      }
+//   }
+}



More information about the jboss-svn-commits mailing list