Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testRollbackTransactionOnActivitiException()
        public virtual void testRollbackTransactionOnActivitiException()
        {
            // Create a table that the userBean is supposed to fill with some data
            JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

            jdbcTemplate.execute("create table MY_TABLE (MY_TEXT varchar);");

            // The hello() method will start the process. The process will wait in a user task
            userBean.hello();
            int results = jdbcTemplate.queryForObject("select count(*) from MY_TABLE", typeof(Integer));

            assertEquals(0, results);

            // The completeTask() method will write a record to the 'MY_TABLE' table and complete the user task
            try
            {
                userBean.completeTask(taskService.createTaskQuery().singleResult().Id);
                fail();
            }
            catch (Exception)
            {
            }

            // Since the service task after the user tasks throws an exception, both
            // the record and the process must be rolled back !
            assertEquals("My Task", taskService.createTaskQuery().singleResult().Name);
            results = jdbcTemplate.queryForObject("select count(*) from MY_TABLE", typeof(Integer));
            assertEquals(0, results);

            // Cleanup
            jdbcTemplate.execute("drop table MY_TABLE if exists;");
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Transactional public void completeTask(String taskId)
        public virtual void completeTask(string taskId)
        {
            // First insert a record in the MY_TABLE table
            JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
            int          nrOfRows     = jdbcTemplate.update("insert into MY_TABLE values ('test');");

            if (nrOfRows != 1)
            {
                throw new Exception("Insert into MY_TABLE failed");
            }

            taskService.complete(taskId);
        }