Package com.meterware.pseudoserver

# Class PseudoServer

java.lang.Object
com.meterware.pseudoserver.PseudoServer

public class PseudoServer extends Object
A basic simulated web-server for testing user agents without a web server.

## Constructor Summary

Constructors
Constructor
Description
`PseudoServer()`
`PseudoServer(int socketTimeout)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addResourceHeader(String name, String header)`
Adds a header to a defined resource.
`int`
`getConnectedPort()`
Returns the port on which this server is listening.
`static int`
`getSocketReleaseWaitTime()`
Returns the amount of time the pseudo server will wait for a server socket to be released (in msec) before allocating a new one.
`static int`
`getWaitThreshhold()`
Returns the number of server sockets that must have been allocated and not returned before waiting for one to be returned.
`void`
`mapToClasspath(String directory)`
`void`
`setCharacterSet(String name, String characterSet)`
Specifies the character set encoding for a resource.
`void`
`setDebug(boolean debug)`
`void`
`setErrorResource(String name, int errorCode, String errorMessage)`
Defines a resource which will result in an error message.
`void`
`setMaxProtocolLevel(int majorLevel, int minorLevel)`
`void`
`setResource(String name, byte[] value, String contentType)`
Defines the contents of an expected resource.
`void`
`setResource(String name, PseudoServlet servlet)`
Defines the contents of an expected resource.
`void`
`setResource(String name, String value)`
Defines the contents of an expected resource.
`void`
`setResource(String name, String value, String contentType)`
Defines the contents of an expected resource.
`void`
`setSendCharacterSet(String name, boolean enabled)`
Enables the sending of the character set in the content-type header.
`static void`
`setSocketReleaseWaitTime(int socketReleaseWaitTime)`
Returns the amount of time the pseudo server will wait for a server socket to be released (in msec) before allocating a new one.
`static void`
`setWaitThreshhold(int waitThreshhold)`
Specifies the number of server sockets that must have been allocated and not returned before waiting for one to be returned.
`void`
`shutDown()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PseudoServer

public PseudoServer()

### PseudoServer

public PseudoServer(int socketTimeout)

## Method Details

### getSocketReleaseWaitTime

public static int getSocketReleaseWaitTime()
Returns the amount of time the pseudo server will wait for a server socket to be released (in msec) before allocating a new one. See also `getWaitThreshhold`.

### setSocketReleaseWaitTime

public static void setSocketReleaseWaitTime(int socketReleaseWaitTime)
Returns the amount of time the pseudo server will wait for a server socket to be released (in msec) before allocating a new one. See also `getWaitThreshhold`.

### getWaitThreshhold

public static int getWaitThreshhold()
Returns the number of server sockets that must have been allocated and not returned before waiting for one to be returned.

### setWaitThreshhold

public static void setWaitThreshhold(int waitThreshhold)
Specifies the number of server sockets that must have been allocated and not returned before waiting for one to be returned.

### shutDown

public void shutDown()

### setMaxProtocolLevel

public void setMaxProtocolLevel(int majorLevel, int minorLevel)

### getConnectedPort

public int getConnectedPort() throws IOException
Returns the port on which this server is listening.

Throws:
  `IOException`

### setResource

public void setResource(String name, String value)
Defines the contents of an expected resource.

### setResource

public void setResource(String name, PseudoServlet servlet)
Defines the contents of an expected resource.

### setResource

public void setResource(String name, String value, String contentType)
Defines the contents of an expected resource.

### setResource

public void setResource(String name, byte[] value, String contentType)
Defines the contents of an expected resource.

### setErrorResource

public void setErrorResource(String name, int errorCode, String errorMessage)
Defines a resource which will result in an error message.

### setSendCharacterSet

public void setSendCharacterSet(String name, boolean enabled)
Enables the sending of the character set in the content-type header.

### setCharacterSet

public void setCharacterSet(String name, String characterSet)
Specifies the character set encoding for a resource.

### addResourceHeader

public void addResourceHeader(String name, String header)
Adds a header to a defined resource.

### mapToClasspath

public void mapToClasspath(String directory)

### setDebug

public void setDebug(boolean debug)