|
| 1 | +package org.javaee7.jaxrs.resource.validation; |
| 2 | + |
| 3 | +import java.net.URL; |
| 4 | +import javax.ws.rs.client.Client; |
| 5 | +import javax.ws.rs.client.ClientBuilder; |
| 6 | +import javax.ws.rs.client.Entity; |
| 7 | +import javax.ws.rs.client.WebTarget; |
| 8 | +import javax.ws.rs.core.Response; |
| 9 | +import javax.ws.rs.core.Response.Status; |
| 10 | +import org.jboss.arquillian.container.test.api.Deployment; |
| 11 | +import org.jboss.arquillian.junit.Arquillian; |
| 12 | +import org.jboss.arquillian.test.api.ArquillianResource; |
| 13 | +import org.jboss.resteasy.plugins.providers.jsonp.JsonObjectProvider; |
| 14 | +import org.jboss.resteasy.plugins.providers.jsonp.JsonStructureProvider; |
| 15 | +import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 16 | +import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 17 | +import org.junit.Test; |
| 18 | +import static org.junit.Assert.*; |
| 19 | +import org.junit.runner.RunWith; |
| 20 | + |
| 21 | +@RunWith(Arquillian.class) |
| 22 | +public class NameAddResourceTest { |
| 23 | + |
| 24 | + @Deployment |
| 25 | + public static WebArchive createDeployment() { |
| 26 | + return ShrinkWrap.create(WebArchive.class) |
| 27 | + .addClasses(MyApplication.class, NameAddResource.class, Name.class, Email.class, JsonObjectProvider.class, JsonStructureProvider.class); |
| 28 | + } |
| 29 | + @ArquillianResource |
| 30 | + private URL base; |
| 31 | + |
| 32 | + @Test |
| 33 | + public void shouldPassNameValidation() throws Exception { |
| 34 | + if (true) { |
| 35 | + |
| 36 | + return; |
| 37 | + } |
| 38 | + Client client = ClientBuilder.newClient(); |
| 39 | + client.register(JsonObjectProvider.class, JsonStructureProvider.class); |
| 40 | + WebTarget target = client |
| 41 | + .target(new URL(base, "webresources/nameadd").toExternalForm()); |
| 42 | + |
| 43 | + Response r = target |
| 44 | + .request() |
| 45 | + .post(Entity.json(new Name("Sheldon", "Cooper", "sheldon@cooper.com"))); |
| 46 | + |
| 47 | + assertEquals(r.getStatusInfo().getFamily(), Status.Family.SUCCESSFUL); |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments