cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException for Testcase

tomi87
Champ in-the-making
Champ in-the-making
I need some help to solve my problem with the correct way of writing for the following test. Because he give me the error code:
java.lang.NullPointerException
   at org.activiti.designer.test.TestProcess1.testXorFunctionality(TestProcess1.java:37)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

How can I write it in the right way ?

public class TestProcess1{

   @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg.xml");

   @Test
   @Deployment(resources = { "XOR.bpmn20.xml" })
   
      public void testXorFunctionality(){
      
         Map<String, Object> variables = new HashMap<String, Object>();
         variables.put("choose", 2);
   
         TaskService taskService = activitiRule.getTaskService();
         RuntimeService runtimeService = activitiRule.getRuntimeService();
         
         ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("xorTest", variables);
      // ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceById("xorTest", variables);
     
      Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
      assertEquals("Choose 2", task.getName());
      taskService.complete(task.getId());

      task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
         assertEquals("pepare 2", task.getName());
      }
   }
10 REPLIES 10

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Line 37 is?

tomi87
Champ in-the-making
Champ in-the-making
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("xorTest", variables);

frederikherema1
Star Contributor
Star Contributor
does the logging mention anything about the loading of the process-engine from the config file? Do you manually set the "processEngine" property on the rule? If so, the services are NOT initialized:


public void starting(FrameworkMethod method) {
    if (processEngine==null) {
      initializeProcessEngine();
      initializeServices();
    }

tomi87
Champ in-the-making
Champ in-the-making
does the logging mention anything about the loading of the process-engine from the config file?


Jan 21, 2013 1:57:27 PM org.activiti.engine.impl.ProcessEngineImpl <init>
INFO: ProcessEngine default created
Jan 21, 2013 1:57:27 PM org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource XOR.bpmn20.xml

frederikherema1
Star Contributor
Star Contributor
Do you have the sources of activiti locally? Can you debug in the "initializeEngine" method of the ActivitiRule to see what goes wrong. From the code I see, there is little that can go wrong, here…

tomi87
Champ in-the-making
Champ in-the-making
I don't know how I can do it.
I'm new and I don't know so much about this.

frederikherema1
Star Contributor
Star Contributor
How do you run the unit-test? Using eclipse or maven?

tomi87
Champ in-the-making
Champ in-the-making
eclipse.

tomi87
Champ in-the-making
Champ in-the-making
Can you help me further please ?