Examples of EmployeeImpl


Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

   
    protected void onTearDown() throws Exception {
    }
   
    public void testSaveWithCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Id null before adding:
        assertNull(emp.getId());
        // Save:
        this.template.save(emp);
        // Id not null after adding:
        assertNotNull(emp.getId());
        // Commit the transaction status:
        this.transactionManager.commit(status);
       
        // Verify that the employee has been actually saved:
        EmployeeImpl emp2 = (EmployeeImpl) this.template.get(Employee.class, emp.getId());
        assertNotNull(emp);
        assertEquals(emp, emp2);
    }
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

        assertNotNull(emp);
        assertEquals(emp, emp2);
    }
   
    public void testDoubleCommit() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save:
        this.template.save(emp);
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

            System.out.println(ex.getMessage());
        }
    }
   
    public void testSaveWithTimeout() throws InterruptedException {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

            System.out.println(ex.getMessage());
        }
    }
   
    public void testSaveWithRollback() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp);
        // Verify that the employee has been saved in the current transaction scope:
        EmployeeImpl emp2 = (EmployeeImpl) this.template.get(Employee.class, emp.getId());
        assertNotNull(emp);
        assertEquals(emp, emp2);
        // Manually roll back:
        this.transactionManager.rollback(status);
       
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

        emp = (EmployeeImpl) this.template.get(Employee.class, emp.getId());
        assertNull(emp);
    }
   
    public void testCorrectIdSequenceBetweenRollbackAndCommit() {
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.rollback(status);
       
        // First id
        id1 = emp1.getId();
       
        // Now, make a save with commit and verify that the id is the same as before,
        // because the new transaction must re-assign the id assigned in the previously
        // rolled back transaction:
       
        status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        this.template.save(emp2);
        this.transactionManager.commit(status);
       
        // Second id
        id2 = emp2.getId();
       
        assertEquals(id1, id2);
    }
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

       
        assertEquals(id1, id2);
    }
   
    public void testCorrectIdSequenceBetweenCommits() {
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.commit(status);
       
        // First id
        id1 = emp1.getId();
       
        // Now, make a save with commit and verify that the id is equal to the previous id plus one:
       
        status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        this.template.save(emp2);
        this.transactionManager.commit(status);
       
        // Second id
        id2 = emp2.getId();
       
        assertEquals(id1.longValue() +1, id2.longValue());
    }
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

    }
   
    public void testConcurrency() throws InterruptedException {
        Runnable r1 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a1");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
                assertNotNull(emp2);
                assertEquals("First: " + emp1.getMatriculationCode() + " - Second: "+ emp2.getMatriculationCode(), emp1, emp2);
            }
        };
       
        Runnable r2 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a2");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
                assertNotNull(emp2);
                assertEquals("First: " + emp1.getMatriculationCode() + " - Second: "+ emp2.getMatriculationCode(), emp1, emp2);
            }
        };
       
        Thread t1 = new Thread(r1);
        Thread t2 = new Thread(r2);
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

   
    public Object doInTransaction(PrevalentSystem system) {
        Iterator emps = system.get(Employee.class).iterator();
        List result = new LinkedList();
        while (emps.hasNext()) {
            EmployeeImpl e = (EmployeeImpl) emps.next();
            if (e.getMatriculationCode().equals("a1")) {
                e.setFirstname("Sergio");
                e.setSurname("Bossa");
               
                system.update(e);
                result.add(e);
            }
        }
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

    public NonSleepingPrevaylerCallback(Object entityId) {
        this.entityId = entityId;
    }
   
    public Object doInTransaction(PrevalentSystem system) {
        EmployeeImpl emp = (EmployeeImpl) system.get(Employee.class, this.entityId);
        System.out.println("Setting name to Robert!");
        System.out.println("Current name: " + emp.getFirstname());
        emp.setFirstname("Robert");
        emp = (EmployeeImpl) system.update(emp);
        System.out.println("Name set to Robert!");
        return emp;
    }
View Full Code Here

Examples of org.springmodules.prevayler.test.domain.EmployeeImpl

        this.prevalentSystem = new DefaultPrevalentSystem();
        this.prevalentSystem.setPrevalenceInfo(info);
    }

    public void testSave() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Id null before adding:
        assertNull(emp.getId());
       
        emp = (EmployeeImpl) this.prevalentSystem.save(emp);
       
        // Id not null after adding:
        assertNotNull(emp.getId());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.