Search in sources :

Example 1 with Created

use of org.javaee7.jca.filewatch.event.Created in project javaee7-samples by javaee-samples.

the class BatchCSVDatabaseTest method createDeployment.

/**
     * We're just going to deploy the application as a +web archive+. Note the inclusion of the following files:
     *
     * [source,file]
     * ----
     * /META-INF/batch-jobs/myJob.xml
     * /META-INF/persistence.xml
     * /META-INF/create.sql
     * /META-INF/drop.sql
     * /META-INF/mydata.csv
     * ----
     *
     * * The +myJob.xml+ file is needed for running the batch definition.
     * * The +persistence.xml+ file is needed for JPA configuration, create schema, load-data and drop schema.
     * * The +create.sql+ file has the necessary database schema for the data.
     * * The +drop.sql+ file has the required commands to drop the database schema created.
     * * The +mydata.csv+ file has the data to load into the database.
     */
@Deployment
public static WebArchive createDeployment() {
    WebArchive war = ShrinkWrap.create(WebArchive.class).addClass(BatchTestHelper.class).addPackage("org.javaee7.batch.chunk.csv.database").addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")).addAsResource("META-INF/batch-jobs/myJob.xml").addAsResource("META-INF/persistence.xml").addAsResource("META-INF/create.sql").addAsResource("META-INF/drop.sql").addAsResource("META-INF/mydata.csv");
    System.out.println(war.toString(true));
    return war;
}
Also used : WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) BatchTestHelper(org.javaee7.util.BatchTestHelper) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 2 with Created

use of org.javaee7.jca.filewatch.event.Created in project javaee7-samples by javaee-samples.

the class DynamicNamedQueryTest method testDynamicNamedCriteriaQueries.

@Test
public void testDynamicNamedCriteriaQueries() throws IOException, SAXException {
    // Nothing inserted yet, data base should not contain any entities 
    // (this tests that a simple query without parameters works as named query created by Criteria)
    assertTrue(testService.getAll().size() == 0);
    // Insert one entity
    TestEntity testEntity = new TestEntity();
    testEntity.setValue("myValue");
    testService.save(testEntity);
    // The total amount of entities should be 1
    assertTrue(testService.getAll().size() == 1);
    // The entity with "myValue" should be found
    // (this tests that a query with a parameter works as named query created by Criteria)
    assertTrue(testService.getByValue("myValue").size() == 1);
}
Also used : TestEntity(org.javaee7.jpa.dynamicnamedquery.entity.TestEntity) Test(org.junit.Test)

Aggregations

TestEntity (org.javaee7.jpa.dynamicnamedquery.entity.TestEntity)1 BatchTestHelper (org.javaee7.util.BatchTestHelper)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)1 Test (org.junit.Test)1