Package org.agoncal.book.javaee7.chapter03

Examples of org.agoncal.book.javaee7.chapter03.Address


  public static void main(String[] args) {

    System.out.println("Invoking web service programmatically");

    CreditCard creditCard = new CreditCard();
    creditCard.setNumber("12341234");
    creditCard.setExpiryDate("10/12");
    creditCard.setType("VISA");
    creditCard.setControlNumber(1234);

    CardValidator cardValidator = new CardValidatorService().getCardValidatorPort();
    System.out.println(cardValidator.validate(creditCard));

    creditCard.setNumber("12341233");
    System.out.println(cardValidator.validate(creditCard));
  }
View Full Code Here


  public static void main(String[] args) {

    System.out.println("Invoking web service with injection");

    CreditCard creditCard = new CreditCard();
    creditCard.setNumber("12341234");
    creditCard.setExpiryDate("10/12");
    creditCard.setType("VISA");
    creditCard.setControlNumber(1234);

    CardValidator cardValidator = cardValidatorService.getCardValidatorPort();
    System.out.println(cardValidator.validate(creditCard));

    creditCard.setNumber("12341233");
    System.out.println(cardValidator.validate(creditCard));
  }
View Full Code Here

  // =           Public Methods           =
  // ======================================

  @GET
  public String getAsPlainText() {
    return new Customer11("John", "Smith", "jsmith@gmail.com", "1234565").toString();
  }
View Full Code Here

  // =              Unit tests            =
  // ======================================

  @Test
  public void shouldMarshallACustomer() throws JAXBException {
    Customer13 customer = new Customer13("John", "Smith", "jsmith@gmail.com", "1334565");
    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(Customer13.class);
    Marshaller m = context.createMarshaller();
    m.marshal(customer, writer);
  }
View Full Code Here

  }

  @Test
  public void shouldMarshallAListOfCustomers() throws JAXBException {
    Customers13 customers = new Customers13();
    customers.add(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"));
    customers.add(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"));
    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(Customers13.class);
    Marshaller m = context.createMarshaller();
    m.marshal(customers, writer);
  }
View Full Code Here

    assertEquals(404, response.getStatus());
  }

  @Test
  public void shouldCreateACustomerWithURIBuilderFromUri() {
    Response response = client.target("http://localhost:8282/13/customer/fromUri").request().post(Entity.entity(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"), MediaType.APPLICATION_XML));
    assertEquals(201, response.getStatus());
    assertEquals("http://localhost:8282/13/customer/1334", response.getLocation().toString());
  }
View Full Code Here

    assertEquals("http://localhost:8282/13/customer/1334", response.getLocation().toString());
  }

  @Test
  public void shouldCreateACustomerWithURIBuilderFromMethod() {
    Response response = client.target("http://localhost:8282/13/customer/fromMethod").request().post(Entity.entity(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"), MediaType.APPLICATION_XML));
    assertEquals(201, response.getStatus());
    assertEquals("fromMethod", response.getLocation().toString());
  }
View Full Code Here

    assertEquals("fromMethod", response.getLocation().toString());
  }

  @Test
  public void shouldCreateACustomerWithURIBuilderFromResource() {
    Response response = client.target("http://localhost:8282/13/customer/fromResource").request().post(Entity.entity(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"), MediaType.APPLICATION_XML));
    assertEquals(201, response.getStatus());
    assertEquals("/13/customer/1334", response.getLocation().toString());
  }
View Full Code Here

    assertEquals("/13/customer/1334", response.getLocation().toString());
  }

  @Test
  public void shouldUpdateCustomer() {
    Response response = client.target("http://localhost:8282/13/customer/cust1334").request().put(Entity.entity(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"), MediaType.APPLICATION_XML));
    assertEquals(200, response.getStatus());
  }
View Full Code Here

    m.marshal(customer, writer);
  }

  @Test
  public void shouldMarshallAListOfCustomers() throws JAXBException {
    Customers13 customers = new Customers13();
    customers.add(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"));
    customers.add(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"));
    StringWriter writer = new StringWriter();
    JAXBContext context = JAXBContext.newInstance(Customers13.class);
    Marshaller m = context.createMarshaller();
    m.marshal(customers, writer);
  }
View Full Code Here

TOP

Related Classes of org.agoncal.book.javaee7.chapter03.Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.