public class

PortForwardingRule

extends Object
implements TestRule
java.lang.Object
   ↳ android.support.test.rule.PortForwardingRule

Class Overview

A TestRule to forward network traffic to a specific port. By default all traffic is forwarded to default address #DEFAULT_PROXY_HOST:#DEFAULT_PROXY_PORT unless otherwise specified

Note: Traffic forwarding will only apply to the current process under test.

This API is currently in beta.

Summary

Nested Classes
class PortForwardingRule.Builder  
Constants
int MAX_PORT
int MIN_PORT
Protected Constructors
PortForwardingRule(int proxyPort)
Public Methods
Statement apply(Statement base, Description description)
Protected Methods
void afterPortForwarding()
Override this method to execute any code that should run after port forwarding is set up, but before any test code is run including any method annotated with Before.
void afterRestoreForwarding()
Override this method to execute any code that should run after port forwarding is restored.
void beforePortForwarding()
Override this method to execute any code that should run before port forwarding.
void beforeRestoreForwarding()
Override this method to execute any code that should run before port forwarding is restored.
static int getDefaultPort()
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.junit.rules.TestRule

Constants

public static final int MAX_PORT

Constant Value: 65535 (0x0000ffff)

public static final int MIN_PORT

Constant Value: 1024 (0x00000400)

Protected Constructors

protected PortForwardingRule (int proxyPort)

Parameters
proxyPort int

Public Methods

public Statement apply (Statement base, Description description)

Parameters
base Statement
description Description
Returns
Statement

Protected Methods

protected void afterPortForwarding ()

Override this method to execute any code that should run after port forwarding is set up, but before any test code is run including any method annotated with Before.

protected void afterRestoreForwarding ()

Override this method to execute any code that should run after port forwarding is restored. This method is called after each test method, including any method annotated with After.

protected void beforePortForwarding ()

Override this method to execute any code that should run before port forwarding. This method is called before each test method, including any method annotated with Before.

protected void beforeRestoreForwarding ()

Override this method to execute any code that should run before port forwarding is restored. This method is called after each test method, including any method annotated with After.

protected static int getDefaultPort ()

Returns
int