2014-06-11 2 views
0

Java 웹 서비스 세계 로의 첫 번째 여행. 게시물 요청에 대한 테스트를 작성하려고합니다. 내가 시도했습니다저지 테스트 컬 (curl) 요청에 해당

url -v -X POST -H 'Content-Type: application/json' -d '{"transaction_zips": ["78732"],"condition": "good"}' http://localhost:8080/PricingService/vin/1GTEC19J37E152026/usedValues 

: 포스트는 컬이 보이는

이 결과
@Test 
public void testVinPricing200() { 
    int status = target.path("PricingService/vin/1GTEC19J37E152026/usedValues").request(MediaType.APPLICATION_JSON_TYPE). 
      post(Entity.entity("{\"transaction_zips\": [\"78732\"],\"condition\": \"good\"}", MediaType.APPLICATION_JSON)).getStatus(); 
    assertEquals(200, status); 
} 

:

Failed tests: testVinPricing200(com.comp.platform.PricingServiceTest): expected:<200> but was:<406> 

그래서 질문은 간단하다, 나는 분명 해요 게시하지 올바르게, 내가 뭘 잘못하고 있니?

+0

내가 뉴저지 매우 자세한 아니라는 것을 알고 있지만 어떤 오류 메시지가 모두 추가거야? – Fabian

+0

컬이 예상 한 응답을 반환합니까? –

+0

curl이 예상 응답을 리턴합니다. 짧은 반환은 세 번째 코드 블록의 질문에 나열되어 있습니다. – nick

답변

1

당신의 curl 요청하고이 junit test 당신이 유형 MediaType.APPLICATION_JSON_TYPE의 응답을 요청하는 귀하의 junit 시험의 차이는 있지만 webserviceJSON를 통해 responding 할 수 없습니다.

의 HTTP 상태 코드 : 406

The resource identified by the request is only capable of generating response entities 
which have content characteristics not acceptable according to the accept headers sent in 
the request. 
+0

이것은 실제로 문제가되었습니다. JSON을 서비스의 생산 유형으로 설정 한 것으로 알고 소비를 올바르게 설정했지만 생산을 올바르게 설정하지 않았습니다. 고마워요 사얀. – nick

관련 문제