Guest User

Untitled

a guest
May 16th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <apex:page controller="TestBatchFiringController">
  2. </apex:page>
  3.  
  4. public class TestBatchFiringController {
  5. public TestBatchFiringController() {
  6. // These statements successfully completed.
  7.  
  8. // Results in a valid AsyncApexJob id, but batch does not execute.
  9. // AsyncApexJob Id is not valid after method executes (but it is in test context!)
  10. System.debug('My job id is: ' + Database.executeBatch(new TestBatchFiringBatch(), 1));
  11.  
  12. // Results in a valid CronTrigger id, but schedulable does not execute.
  13. // CronTrigger Id is not valid after method executes (but it is in test context!)
  14. System.debug('My schedulable job id is ' + System.schedule('Test Job', '20 30 8 10 2 ?', new TestSchedulableFiring()));
  15.  
  16. // This would fail with a `LimitException` - DML is not allowed.
  17. // Account a = new Account(Name = 'Testy Test Test');
  18. // insert a;
  19. // System.debug('My Account's Id is ' + a.Id);
  20.  
  21. // Setting a savepoint is DML-equivalent - this also throws a `LimitException`
  22. // System.Savepoint sp = Database.setSavepoint();
  23.  
  24. }
  25. }
Add Comment
Please, Sign In to add comment