glassfish
  1. glassfish
  2. GLASSFISH-20088

[osgi/javaee-test] Use a better http client library than java.net supplied one

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b82_EE7MS7
    • Fix Version/s: 4.1
    • Component/s: OSGi-JavaEE
    • Labels:
      None

      Description

      Given the amount of time we have lately spent in analysing http connection related issues, I am seriously thinking of using something like Apache Http Commons library [1] instead of java.net.HttpUrlConnection in fighterfish.test.util. It will be good to find out the effort estimate for such a change.

      [1] http://hc.apache.org/httpclient-3.x/tutorial.html

        Activity

        Hide
        TangYong added a comment - - edited

        I will use HttpClient 4.2.4 rather than 3.x. HttpClient 4 was a complete rewrite and is not backward compatible. And It’s also now a top level Apache project and no longer part of Apache Commons.

        Show
        TangYong added a comment - - edited I will use HttpClient 4.2.4 rather than 3.x. HttpClient 4 was a complete rewrite and is not backward compatible. And It’s also now a top level Apache project and no longer part of Apache Commons.
        Hide
        TangYong added a comment -

        Now, improvement has been in final phrase, while using the new library to execute it tests, two test cases failed,

        Results :

        Failed tests:
        uas_sample_test:T1_SamplesTest.uas_sample_test:NativeContainer:org.apache.felix.framework.FrameworkFactory@2e0941(org.glassfish.fighterfish.test.it.T1_SamplesTest): Expected fragment to be not available
        testapp12:T2_Test.testapp12:NativeContainer:org.apache.felix.framework.FrameworkFactory@11550e2(org.glassfish.fighterfish.test.it.T2_Test): Expected fragment to be not available

        Tests run: 30, Failures: 2, Errors: 0, Skipped: 4

        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD FAILURE
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 2:12.071s
        [INFO] Finished at: Wed Apr 17 11:31:21 JST 2013
        [INFO] Final Memory: 14M/34M
        [INFO] ------------------------------------------------------------------------
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project test.it: There are test failures.
        [ERROR]
        [ERROR] Please refer to D:\20130125\fighterfish12\test\it\target\surefire-reports for the individual test results.
        [ERROR] -> [Help 1]
        [ERROR]
        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
        [ERROR]
        [ERROR] For more information about the errors and possible solutions, please read the following articles:
        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

        needing to investigate deeply.

        Show
        TangYong added a comment - Now, improvement has been in final phrase, while using the new library to execute it tests, two test cases failed, Results : Failed tests: uas_sample_test:T1_SamplesTest.uas_sample_test:NativeContainer:org.apache.felix.framework.FrameworkFactory@2e0941(org.glassfish.fighterfish.test.it.T1_SamplesTest): Expected fragment to be not available testapp12:T2_Test.testapp12:NativeContainer:org.apache.felix.framework.FrameworkFactory@11550e2(org.glassfish.fighterfish.test.it.T2_Test): Expected fragment to be not available Tests run: 30, Failures: 2, Errors: 0, Skipped: 4 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2:12.071s [INFO] Finished at: Wed Apr 17 11:31:21 JST 2013 [INFO] Final Memory: 14M/34M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.8:test (default-test) on project test.it: There are test failures. [ERROR] [ERROR] Please refer to D:\20130125\fighterfish12\test\it\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException needing to investigate deeply.
        Hide
        TangYong added a comment - - edited

        The two issues have been invested and known the reason, while using httpclient lib, and if having not found resources, the following liking response will be generated,

        HTTP/1.1 404 Not Found [X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7), Server: GlassFish Server Open Source Edition 4.0 , Content-Language: , Content-Type: text/html, Date: Wed, 17 Apr 2013 03:27:31 GMT, Content-Length: 1094]

        So, this will break original handling (originally, expecting an IOException happen), then, "java.lang.AssertionError: Expected fragment to be not available" happened.

        fixing way is to add a status code handling,

        HttpResponse response = httpClient.execute(httpRequest);

        if(response.getStatusLine().getStatusCode() == 404)

        { throw new FileNotFoundException("Request Resource is not available."); }

        Noting, here we must throw FileNotFoundException not IOException in order not to modify T2_Test.

        Show
        TangYong added a comment - - edited The two issues have been invested and known the reason, while using httpclient lib, and if having not found resources, the following liking response will be generated, HTTP/1.1 404 Not Found [X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7), Server: GlassFish Server Open Source Edition 4.0 , Content-Language: , Content-Type: text/html, Date: Wed, 17 Apr 2013 03:27:31 GMT, Content-Length: 1094] So, this will break original handling (originally, expecting an IOException happen), then, "java.lang.AssertionError: Expected fragment to be not available" happened. fixing way is to add a status code handling, HttpResponse response = httpClient.execute(httpRequest); if(response.getStatusLine().getStatusCode() == 404) { throw new FileNotFoundException("Request Resource is not available."); } Noting, here we must throw FileNotFoundException not IOException in order not to modify T2_Test.
        Hide
        TangYong added a comment -

        Now, it tests has all passed.

        at java.lang.Thread.run(Thread.java:722)
        [#|2013-04-17T12:53:09.238+0900|INFO|glassfish 4.0|javax.enterprise.system.core|_ThreadID=263;_ThreadName=FelixStartLevel;_TimeMillis=1366170789238;_LevelValue=800;_MessageID=NCLS-CORE-00013;ClassName=com.sun.enterprise.v3.server.AppServerStartup;MethodName=stop;|
        Shutdown procedure finished|#]

        Tests run: 26, Failures: 0, Errors: 0, Skipped: 4, Time elapsed: 156.509 sec

        Results :

        Tests run: 30, Failures: 0, Errors: 0, Skipped: 4

        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD SUCCESS
        [INFO] ------------------------------------------------------------------------
        [INFO] Total time: 3:23.164s
        [INFO] Finished at: Wed Apr 17 12:53:09 JST 2013
        [INFO] Final Memory: 14M/34M

        I will send patch to sahoo and do final review.

        Show
        TangYong added a comment - Now, it tests has all passed. at java.lang.Thread.run(Thread.java:722) [#|2013-04-17T12:53:09.238+0900|INFO|glassfish 4.0|javax.enterprise.system.core|_ThreadID=263;_ThreadName=FelixStartLevel;_TimeMillis=1366170789238;_LevelValue=800;_MessageID=NCLS-CORE-00013;ClassName=com.sun.enterprise.v3.server.AppServerStartup;MethodName=stop;| Shutdown procedure finished|#] Tests run: 26, Failures: 0, Errors: 0, Skipped: 4, Time elapsed: 156.509 sec Results : Tests run: 30, Failures: 0, Errors: 0, Skipped: 4 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3:23.164s [INFO] Finished at: Wed Apr 17 12:53:09 JST 2013 [INFO] Final Memory: 14M/34M I will send patch to sahoo and do final review.
        Hide
        TangYong added a comment -

        Have checked in sources.

        revision: 61743

        Show
        TangYong added a comment - Have checked in sources. revision: 61743
        Hide
        Sanjeeb Sahoo added a comment -

        Released test.util:1.1.6.

        Integrated the same with ff test/it/pom.xml in svn #62052.

        Show
        Sanjeeb Sahoo added a comment - Released test.util:1.1.6. Integrated the same with ff test/it/pom.xml in svn #62052.

          People

          • Assignee:
            TangYong
            Reporter:
            Sanjeeb Sahoo
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: