title: Junit throwing java.lang.AbstractMethodError: javax.ws.rs.core.Response$ResponseBuilder.status
body: <p>Currently am writing Junit for our webservice code.</p>
  
  <p>WebService Code and Junit code is written in the code section</p>
  
  <p>When I run the Junit am getting the below error</p>
  
  <pre><code>java.lang.AbstractMethodError: javax.ws.rs.core.Response$ResponseBuilder.status(ILjava/lang/String;)Ljavax/ws/rs/core/Response$ResponseBuilder;
  at javax.ws.rs.core.Response$ResponseBuilder.status(Response.java:921)
  at javax.ws.rs.core.Response.status(Response.java:592)
  at javax.ws.rs.core.Response.status(Response.java:603)
  at javax.ws.rs.core.Response.ok(Response.java:638)
  at javax.ws.rs.core.Response.ok(Response.java:650)
  at com.renault.rntbci.stl.service.demande.impl.ListDemandServiceImpl.getDemandeListCount(ListDemandServiceImpl.java:281)
  at com.renault.rntbci.stl.service.demande.impl.ListDemandeTest.testGetDemandeListCount(ListDemandeTest.java:51)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  </code></pre>
  
  <p>One of my friend advised me to change the scope to test in pom.xml for jax rs version as below.</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.resteasy&lt;/groupId&gt;
          &lt;artifactId&gt;jaxrs-api&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
          &lt;version&gt;2.3.7.Final&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>But still the same error is persisting. Kindly anyone please help me with a solution.</p>
  
  <p>Thanks a lot in advance.</p>
  
  <p>Note:
  This is an existing application and I am new to this project which is with Java 1.7</p>
  
  <pre class="lang-java prettyprint-override"><code>public Response someMethod(String stringValue){
  
      Map&lt;String, Long&gt; outputMap = new TreeMap&lt;String, Long&gt;();
  
      try {
          Long outputValue = service.getCount(stringValue);
          //this call goes to a service and gets the db count for a table
          outputMap.put("listCount", outputValue);
  
      } catch (Exception e) {
          logger.info(e.getMessage(), e); 
      }
      return Response.ok(outputMap).build();
  }
  </code></pre>
  
  <p>And Junit code is </p>
  
  <pre class="lang-java prettyprint-override"><code>@Mock
  Service service;
  
  @Mock
  Response res;
  @Test
  public void testSomeMethod() throws SQLException {
      String stringValue="12";
      Long returnValue=10L;
  
      when(service.getCount(stringValue)).thenReturn(returnValue);
      res=obj.someMethod(stringValue);
      Assert.assertNotNull(res);
  }
  </code></pre>