DO NOT REPLY [Bug 48163] New: JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

View: New views
17 Messages — Rating Filter:   Alert me  

DO NOT REPLY [Bug 48163] New: JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

           Summary: JMeterTestCase for
                    org.apache.jmeter.protocol.http.control.CacheManager
           Product: JMeter
           Version: unspecified
          Platform: PC
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HTTP
        AssignedTo: jmeter-dev@...
        ReportedBy: john.samford@...


Seeing CacheManager had no JMeterTestCase and wanting to learn how the cache
manager worked, I developed the attached JMeterTestCase for it which I'd like
to share.

It does require that CacheManager's inner class CacheEntry be promoted from
private to package protected.

Take it for what it's worth...

John Samford

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Sebb <sebb@...> 2009-11-13 09:15:37 UTC ---
There's no attachment...

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

--- Comment #2 from John Samford <john.samford@...> 2009-11-13 10:07:46 UTC ---
Created an attachment (id=24530)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24530)
JMeterTestCase for CacheManager

My apologies for not attaching the file. Here 'tis!

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24530|application/octet-stream    |text/plain
          mime type|                            |

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

John Samford <john.samford@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #3 from Sebb <sebb@...> 2009-11-13 10:46:31 UTC ---
The test fails with the following error:

junit.framework.AssertionFailedError: No property entry found for property
If-None-Match
    at junit.framework.Assert.fail(Assert.java:47)
    at junit.framework.Assert.assertTrue(Assert.java:20)
    at junit.framework.Assert.assertNotNull(Assert.java:214)
    at
org.apache.jmeter.protocol.http.control.TestCacheManager.checkProperty(TestCacheManager.java:174)
    at
org.apache.jmeter.protocol.http.control.TestCacheManager.testSetHeadersHttpURLConnectionWithSampleResultWithResponseCode200GivesCacheEntry(TestCacheManager.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:592)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


Any idea what causes that?

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

John Samford <john.samford@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #4 from John Samford <john.samford@...> 2009-11-13 12:52:14 UTC ---
I do not understand why this test is failing for you.

As you can see, it's supposed to check that the entry in the CacheManager
created by a call to saveDetails is used to set the connection's property list:
the "If-None-Match" set to the etag value and the "If-Modified-Since" set to
the current time.

"It runs on my machine!" with a fresh copy of the CacheManager downloaded a few
moments ago, only changing the visibility of the CacheEntry inner class.

Clearly the CacheEntry found in setHeaders has no etag. Therefore, the
CacheEntry whose etag is set earlier in the test through reflection must not be
the same CacheEntry used by setHeaders, despite the fact that they are indexed
by the URL.

If I could duplicate the problem, I could debug it. I wouldn't ask you to do my
work and step through the test to see where it gets off the track but I cannot
see how to proceed otherwise. I'd be curious whether the CacheEntry manipulated
in the test's initialization is the same object as that used by setHeaders and
since it probably is not, how the heck another got there.

Thoughts?

John Samford

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

--- Comment #5 from Sebb <sebb@...> 2009-11-13 13:53:05 UTC ---
(In reply to comment #4)
> I do not understand why this test is failing for you.
>
> As you can see, it's supposed to check that the entry in the CacheManager
> created by a call to saveDetails is used to set the connection's property list:
> the "If-None-Match" set to the etag value and the "If-Modified-Since" set to
> the current time.
>
> "It runs on my machine!" with a fresh copy of the CacheManager downloaded a few
> moments ago, only changing the visibility of the CacheEntry inner class.

That should not be necessary, as I've already fixed that, so maybe you have not
downloaded the current code.

> Clearly the CacheEntry found in setHeaders has no etag.

Not according to the way I read the code - it is checking the properties which
are obtained from this.httpUrlConnection.getRequestProperties();

> Therefore, the
> CacheEntry whose etag is set earlier in the test through reflection must not be
> the same CacheEntry used by setHeaders, despite the fact that they are indexed
> by the URL.
>
> If I could duplicate the problem, I could debug it. I wouldn't ask you to do my
> work and step through the test to see where it gets off the track but I cannot
> see how to proceed otherwise. I'd be curious whether the CacheEntry manipulated
> in the test's initialization is the same object as that used by setHeaders and
> since it probably is not, how the heck another got there.
>
> Thoughts?

See above; can you try downloading the current code from trunk?

> John Samford

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

--- Comment #6 from Sebb <sebb@...> 2009-11-13 13:58:34 UTC ---
One other point - it would be better if the CacheManager could be tested
without requiring internet access.

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

John Samford <john.samford@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24530|0                           |1
        is obsolete|                            |

--- Comment #7 from John Samford <john.samford@...> 2009-11-16 06:08:12 UTC ---
Created an attachment (id=24541)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24541)
Revised version which uses localhost rather than internet connection.

Per suggestion, I've modified the test not to require connection to the
internet but rather to use localhost and a stub version of URLConnection

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

--- Comment #8 from John Samford <john.samford@...> 2009-11-16 06:09:49 UTC ---
Thanks for taking so much time with me. This is my first foray into trying to
add something to an Apache open source project.

What I did to get the source I was using was to go to the JMeter downloads
page:
http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
where it says one can get source. I just checked the CacheManager there against
what I've been using and they are identical. Is that "trunk"?

Here's the version of setHeaders() which I've got which is called by the
failing test:

    public void setHeaders(HttpURLConnection conn, URL url) {
        CacheEntry entry = (CacheEntry) getCache().get(url.toString());
        if (log.isDebugEnabled()){
            log.debug(conn.getRequestMethod()+"(Java) "+url.toString()+"
"+entry);
        }
        if (entry != null){
            final String lastModified = entry.getLastModified();
            if (lastModified != null){
               
conn.addRequestProperty(HTTPConstantsInterface.IF_MODIFIED_SINCE,
lastModified);
            }
            final String etag = entry.getEtag();
            if (etag != null){
                conn.addRequestProperty(HTTPConstantsInterface.IF_NONE_MATCH,
etag);
            }
        }

It gets its CacheEntry using the URL's toString as an index into the
threadCache map.

You're correct: it WOULD be better not to have to be connected to the internet
to run the test!

I've submitted a newer version of the test class which uses localhost (and a
stub version of URLConnection to allow controlling what getHeaderField()
returns for Last-Modified & Etag).

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

--- Comment #9 from Sebb <sebb@...> 2009-11-16 08:03:14 UTC ---
(In reply to comment #8)
> Thanks for taking so much time with me. This is my first foray into trying to
> add something to an Apache open source project.
>
> What I did to get the source I was using was to go to the JMeter downloads
> page:
> http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi
> where it says one can get source. I just checked the CacheManager there against
> what I've been using and they are identical. Is that "trunk"?

Not any more - trunk has moved on since 2.3.4 was released, you can get it at:

http://svn.apache.org/repos/asf/jakarta/jmeter/trunk/

or as an archive at:

http://svn.apache.org/snapshots/jakarta-jmeter/

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #10 from Sebb <sebb@...> 2009-11-16 09:15:12 UTC ---
Thanks for the newer version.

However it still fails at line 173

172: Map<String, List<String>> properties =
this.httpUrlConnection.getRequestProperties();
173: checkProperty(properties, HTTPConstantsInterface.IF_NONE_MATCH,
EXPECTED_ETAG);

The problem is that the properties Map returned at line 172 is empty.

What version of Java are you using?

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

John Samford <john.samford@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24541|0                           |1
        is obsolete|                            |

--- Comment #11 from John Samford <john.samford@...> 2009-11-16 12:44:23 UTC ---
Created an attachment (id=24544)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24544)
Revised version which uses stub classes for HttpURLConnection, UrlConnection &
HttpMethod

I've extended the use of test objects, now simulating UrlConnection, HttpMethod
& HttpURLConnection, eliminating the use of reflection to set fields in the
CacheManager's CacheEntry objects.

The HttpURLConnectionStub should now properly return request properties set in
it, avoiding earlier empty property lists.

This code was developed using Java Version: 1.6.0_15 from Apple, Inc.

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #24544|application/octet-stream    |text/plain
          mime type|                            |

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

John Samford <john.samford@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...


DO NOT REPLY [Bug 48163] JMeterTestCase for org.apache.jmeter.protocol.http.control.CacheManager

by Bugzilla from bugzilla@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://issues.apache.org/bugzilla/show_bug.cgi?id=48163

Sebb <sebb@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #12 from Sebb <sebb@...> 2009-11-16 14:26:51 UTC ---
This latest version has fixed the problem.

I also discovered that the previous failure only occurs on Java 1.5 - works for
me with Java 1.6 (Sun, Windows). But the latest incarnation is better.

Thanks for the test cases.

--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@...
For additional commands, e-mail: jmeter-dev-help@...