Apache JMeter

## org.apache.jmeter.protocol.http.control
Class CacheManager

    java.lang.Object
      org.apache.jmeter.testelement.AbstractTestElement
          org.apache.jmeter.config.ConfigTestElement
              org.apache.jmeter.protocol.http.control.CacheManager

All Implemented Interfaces:
  Serializable, Cloneable, ConfigElement, TestElement, TestListener

    public class CacheManager

extends ConfigTestElement
implements TestListener, Serializable

Handles HTTP Caching

See Also:
  Serialized Form

Field Summary
`static String` `CLEAR`
`static String` `USE_EXPIRES`

Fields inherited from class org.apache.jmeter.config.ConfigTestElement
`PASSWORD, USERNAME`

Fields inherited from interface org.apache.jmeter.testelement.TestElement
`COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

Constructor Summary
`CacheManager()`

Method Summary
`void` `clear()` Clear the TestElement of all data.
`boolean` `getClearEachIteration()`
`boolean` `getUseExpires()`
`boolean` `inCache(URL url)` Check the cache, if the entry has an expires header and the entry has not expired, return true
`void` `saveDetails(org.apache.commons.httpclient.HttpMethod method, SampleResult res)` Save the Last-Modified, Etag, and Expires headers if the result is cacheable.
`void` `saveDetails(URLConnection conn, SampleResult res)` Save the Last-Modified, Etag, and Expires headers if the result is cacheable.
`void` `setClearEachIteration(boolean clear)`
`void` `setHeaders(HttpURLConnection conn, URL url)` Check the cache, and if there is a match, set the headers: If-Modified-Since If-None-Match
`void` `setHeaders(URL url, org.apache.commons.httpclient.HttpMethod method)` Check the cache, and if there is a match, set the headers: If-Modified-Since If-None-Match
`void` `setUseExpires(boolean expires)`
`void` `testEnded()` Called once for all threads after the end of a test.
`void` `testEnded(String host)` Called once for all threads after the end of a test.
`void` `testIterationStart(LoopIterationEvent event)` Each time through a Thread Group's test script, an iteration event is fired for each thread.
`void` `testStarted()` Called just before the start of the test from the main engine thread.
`void` `testStarted(String host)` Called just before the start of the test from the main engine thread.

Methods inherited from class org.apache.jmeter.config.ConfigTestElement
`addConfigElement, addTestElement, expectsModification`

Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

`addProperty, canRemove, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.jmeter.config.ConfigElement
`clone`

Field Detail

### CLEAR

    public static final String CLEAR

See Also:
  Constant Field Values

### USE_EXPIRES

    public static final String USE_EXPIRES

See Also:
  Constant Field Values

Constructor Detail

### CacheManager

    public CacheManager()

Method Detail

### saveDetails

    public void saveDetails(URLConnection conn,
                            SampleResult res)

  Save the Last-Modified, Etag, and Expires headers if the result is cacheable.

  Parameters:
    `conn` - connection
    `res` - result

### saveDetails

    public void saveDetails(org.apache.commons.httpclient.HttpMethod method,
                            SampleResult res)
                     throws org.apache.commons.httpclient.URIException

  Save the Last-Modified, Etag, and Expires headers if the result is cacheable.

  Parameters:
    `method` -
    `res` - result
  Throws:
    `org.apache.commons.httpclient.URIException`

### setHeaders

    public void setHeaders(URL url,
                           org.apache.commons.httpclient.HttpMethod method)

  Check the cache, and if there is a match, set the headers:
  If-Modified-Since
  If-None-Match

  Parameters:
    `url` - URL to look up in cache
    `method` - where to set the headers

### setHeaders

    public void setHeaders(HttpURLConnection conn,
                           URL url)

  Check the cache, and if there is a match, set the headers:
  If-Modified-Since
  If-None-Match

  Parameters:
    `url` - URL to look up in cache
    `conn` - where to set the headers

### inCache

    public boolean inCache(URL url)

  Check the cache, if the entry has an expires header and the entry has not expired, return true

  Parameters:
    `url` - URL to look up in cache

### getClearEachIteration

    public boolean getClearEachIteration()

### setClearEachIteration

    public void setClearEachIteration(boolean clear)

### getUseExpires

    public boolean getUseExpires()

### setUseExpires

    public void setUseExpires(boolean expires)

### clear

    public void clear()

  Description copied from class: `AbstractTestElement`
  Clear the TestElement of all data.

  Specified by:
    `clear` in interface `TestElement`
  Overrides:
    `clear` in class `AbstractTestElement`

### testStarted

    public void testStarted()

  Description copied from interface: `TestListener`

  Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

  N.B. testStarted() and testEnded() are called from different threads.

  Specified by:
    `testStarted` in interface `TestListener`
  See Also:
    `StandardJMeterEngine.run()`

### testEnded

    public void testEnded()

  Description copied from interface: `TestListener`

  Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

  N.B. testStarted() and testEnded() are called from different threads.

  Specified by:
    `testEnded` in interface `TestListener`
  See Also:
    `StandardJMeterEngine.stopTest()`

### testStarted

    public void testStarted(String host)

  Description copied from interface: `TestListener`

  Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

  N.B. testStarted() and testEnded() are called from different threads.

  Specified by:
    `testStarted` in interface `TestListener`
  Parameters:
    `host` - name of host
  See Also:
    `StandardJMeterEngine.run()`

### testEnded

    public void testEnded(String host)

  Description copied from interface: `TestListener`

  Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

  N.B. testStarted() and testEnded() are called from different threads.

  Specified by:
    `testEnded` in interface `TestListener`
  Parameters:
    `host` - name of host
  See Also:
    `StandardJMeterEngine.stopTest()`

### testIterationStart

    public void testIterationStart(LoopIterationEvent event)

  Description copied from interface: `TestListener`
  Each time through a Thread Group's test script, an iteration event is fired for each thread. This will be after the test elements have been cloned, so in general the instance will not be the same as the ones the start/end methods call.

  Specified by:
    `testIterationStart` in interface `TestListener`

Apache JMeter

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.