Search in sources :

Example 76 with InSequence

use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.

the class ContactRegistrationIT method shouldCreateAndDeleteAContact.

@Test
@RunAsClient
@InSequence(6)
public void shouldCreateAndDeleteAContact(@ArquillianResource URL contextPath) throws JAXBException {
    Contact contact = createContactInstance("Jason", "Smith", "jason@mailinator.com", "2125551234", date);
    // POSTs a Contact
    Client client = ClientBuilder.newClient();
    URI uri = UriBuilder.fromUri(contextPath + REST_ROOT).port(8080).build();
    Response response = client.target(uri).request().post(Entity.entity(contact, MediaType.APPLICATION_JSON));
    assertEquals(Response.Status.CREATED, response.getStatusInfo());
    URI contactURI = response.getLocation();
    // With the location, GETs the Contact
    client.close();
    client = ClientBuilder.newClient();
    response = client.target(contactURI).request().get();
    contact = response.readEntity(Contact.class);
    assertEquals(Response.Status.OK, response.getStatusInfo());
    assertEquals("Jason", contact.getFirstName());
    // GETs the Contact ID and DELETEs it
    String contactID = contactURI.toString().split("/")[6];
    response = client.target(uri).path(contactID).request().delete();
    assertEquals(Response.Status.NO_CONTENT, response.getStatusInfo());
    // GETs the Contact and checks if it has been deleted
    client.close();
    client = ClientBuilder.newClient();
    response = client.target(uri).path(contactID).request().get();
    assertEquals(Response.Status.NOT_FOUND, response.getStatusInfo());
    client.close();
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) URI(java.net.URI) Contact(org.jboss.quickstarts.contact.Contact) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 77 with InSequence

use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.

the class ContactRegistrationIT method shouldNotCreateANullContact.

@Test
@RunAsClient
@InSequence(4)
public void shouldNotCreateANullContact(@ArquillianResource URL contextPath) throws JAXBException, URISyntaxException {
    // POSTs a null Contact
    Client client = ClientBuilder.newClient();
    URI uri = UriBuilder.fromUri(contextPath.toURI()).path(REST_ROOT).port(8080).build();
    Response response = client.target(uri).request().post(Entity.entity("{}", MediaType.APPLICATION_JSON));
    assertEquals(Response.Status.BAD_REQUEST, response.getStatusInfo());
    client.close();
}
Also used : Response(javax.ws.rs.core.Response) Client(javax.ws.rs.client.Client) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) URI(java.net.URI) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 78 with InSequence

use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.

the class TaskDaoIT method taskDao_should_remove_task_from_detachedUser.

@Test
@InSequence(5)
public void taskDao_should_remove_task_from_detachedUser() {
    // given
    Task task = new Task();
    task.setId(1L);
    task.setOwner(detachedUser);
    assertEquals(2, taskDao.getAll(detachedUser).size());
    // when
    taskDao.deleteTask(task);
    // then
    assertEquals(1, taskDao.getAll(detachedUser).size());
}
Also used : Task(org.jboss.as.quickstarts.tasksrs.model.Task) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 79 with InSequence

use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.

the class TaskDaoIT method user_should_be_created_with_one_task_attached.

@Test
@InSequence(1)
public void user_should_be_created_with_one_task_attached() throws Exception {
    // given
    User user = new User("New user");
    Task task = new Task("New task");
    // when
    em.persist(user);
    taskDao.createTask(user, task);
    List<Task> userTasks = em.createQuery("SELECT t FROM Task t WHERE t.owner = :owner", Task.class).setParameter("owner", user).getResultList();
    // then
    assertEquals(1, userTasks.size());
    assertEquals(task, userTasks.get(0));
}
Also used : Task(org.jboss.as.quickstarts.tasksrs.model.Task) User(org.jboss.as.quickstarts.tasksrs.model.User) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 80 with InSequence

use of org.jboss.arquillian.junit.InSequence in project javaee7-samples by javaee-samples.

the class ApplicationSingletonResourceTest method testDelete.

@Test
@InSequence(3)
public void testDelete() {
    target.path("kiwi").request().delete();
    String list = target.request().get(String.class);
    StringTokenizer tokens = new StringTokenizer(list, ",");
    assertEquals(3, tokens.countTokens());
}
Also used : StringTokenizer(java.util.StringTokenizer) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

InSequence (org.jboss.arquillian.junit.InSequence)157 Test (org.junit.Test)157 Faker (com.github.javafaker.Faker)21 Simple (org.apache.deltaspike.data.test.ee7.domain.Simple)18 ModelNode (org.jboss.dmr.ModelNode)14 URL (java.net.URL)13 HttpResponse (org.apache.http.HttpResponse)10 TakeOffer (io.bisq.api.model.TakeOffer)9 HttpGet (org.apache.http.client.methods.HttpGet)8 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)8 OfferToCreate (io.bisq.api.model.OfferToCreate)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 PartitionManager (org.picketlink.idm.PartitionManager)7 Response (javax.ws.rs.core.Response)6 IdentityManager (org.picketlink.idm.IdentityManager)6 StringTokenizer (java.util.StringTokenizer)5 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 House (org.apache.deltaspike.data.test.ee7.domain.House)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)5