Package org.apache.camel.examples

Examples of org.apache.camel.examples.Customer


    @Test
    public void consumeEntity() throws Exception {
        setUp("jpa://" + Customer.class.getName() + "?usePersist=" + (usePersist() ? "true" : "false"));
   
        final Customer customer = createDefaultCustomer();
        save(customer);
       
        final CountDownLatch latch = new CountDownLatch(1);
       
        consumer = endpoint.createConsumer(new Processor() {
            public void process(Exchange e) {
                receivedExchange = e;
                assertNotNull(e.getIn().getHeader(JpaConstants.JPA_TEMPLATE, JpaTemplate.class));
                latch.countDown();
            }
        });
        consumer.start();
       
        boolean received = latch.await(50, TimeUnit.SECONDS);
       
        assertTrue(received);
        assertNotNull(receivedExchange);
        Customer receivedCustomer = receivedExchange.getIn().getBody(Customer.class);
        assertEquals(customer.getName(), receivedCustomer.getName());
        assertEquals(customer.getId(), receivedCustomer.getId());
        assertEquals(customer.getAddress().getAddressLine1(), receivedCustomer.getAddress().getAddressLine1());
        assertEquals(customer.getAddress().getAddressLine2(), receivedCustomer.getAddress().getAddressLine2());
        assertEquals(customer.getAddress().getId(), receivedCustomer.getAddress().getId());
       
        // give a bit tiem for consumer to delete after done
        Thread.sleep(1000);
       
        assertEntitiesInDatabase(0, Customer.class.getName());
View Full Code Here


        List results = jpaTemplate.find("select o from " + entity + " o");
        assertEquals(count, results.size());
    }

    protected Customer createDefaultCustomer() {
        Customer customer = new Customer();
        customer.setName("Christian Mueller");
        Address address = new Address();
        address.setAddressLine1("Hahnstr. 1");
        address.setAddressLine2("60313 Frankfurt am Main");
        customer.setAddress(address);
        return customer;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.examples.Customer

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.