Java Reference
In-Depth Information
The
@PATCH
annotation is used on the
patchCustomer()
method. The implementation of this
method simply delegates to the original
updateCustomer()
method.
The Client Code
The client code for
ex04_1
is pretty straightforward and similar to
ex03_1
. Let's look at some
initial minor changes we've made:
src/test/java/com/restfully/shop/test/PatchTest.java
package
package
com
.
restfully
.
shop
.
test
;
import
import
org.junit.AfterClass
org.junit.AfterClass
;
import
import
org.junit.BeforeClass
org.junit.BeforeClass
;
import
import
org.junit.Test
org.junit.Test
;
import
import
javax.ws.rs.client.Client
javax.ws.rs.client.Client
;
import
import
javax.ws.rs.client.ClientBuilder
javax.ws.rs.client.ClientBuilder
;
import
import
javax.ws.rs.client.Entity
javax.ws.rs.client.Entity
;
import
import
javax.ws.rs.core.Response
javax.ws.rs.core.Response
;
/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public
public class
class
PatchTest
PatchTest
{
private
private static
static
Client client
;
@BeforeClass
public
public static
static
void
void
initClient
()
{
client
=
ClientBuilder
.
newClient
();
}
@AfterClass
public
public static
static
void
void
closeClient
()
{
client
.
close
();
}
First, we initialize our
Client
object within a JUNit
@BeforeClass
block. Any static meth-
od you annotate with
@BeforeClass
in JUnit will be executed once before all
@Test
meth-
ods are executed. So, in the
initClient()
method we initialize an instance of
Client
. Stat-