@Test public void checkServiceIsSet() throws ClientProtocolException, IOException, ODataException { executeGetRequest(""); final ODataContext ctx = getService().getProcessor().getContext(); assertNotNull(ctx); assertNotNull(ctx.getService()); }
@Test public void checkBaseUriForServiceDocument() throws ClientProtocolException, IOException, ODataException { executeGetRequest(""); final ODataContext ctx = getService().getProcessor().getContext(); assertNotNull(ctx); assertEquals(getEndpoint().toString(), ctx.getPathInfo().getServiceRoot().toASCIIString()); }
@Test public void checkHttpMethod() throws ClientProtocolException, IOException, ODataException { final HttpGet get = new HttpGet(URI.create(getEndpoint().toString() + "/$metadata")); getHttpClient().execute(get); final ODataContext ctx = getService().getProcessor().getContext(); assertNotNull(ctx); final String httpMethod = ctx.getHttpMethod(); assertEquals("GET", httpMethod); }
@Test public void checkAcceptuablesLanguagesNoHeader() throws ODataException, ClientProtocolException, IOException { final HttpGet get = new HttpGet(URI.create(getEndpoint().toString() + "/$metadata")); getHttpClient().execute(get); final ODataContext ctx = getService().getProcessor().getContext(); assertNotNull(ctx); assertEquals("[*]", ctx.getAcceptableLanguages().toString()); }
@Test public void checkNewRequestHeader() throws ClientProtocolException, IOException, ODataException { final HttpGet get = new HttpGet(URI.create(getEndpoint().toString() + "/$metadata")); get.setHeader("ConTenT-laNguaGe", "de, en"); getHttpClient().execute(get); final ODataContext ctx = getService().getProcessor().getContext(); assertNotNull(ctx); assertEquals("de, en", ctx.getRequestHeader(HttpHeaders.CONTENT_LANGUAGE)); assertNull(ctx.getRequestHeader("nonsens")); }
@Test public void checkContextExists() throws ClientProtocolException, IOException, ODataException { assertNull(getService().getProcessor().getContext()); final HttpResponse response = executeGetRequest("$metadata"); final ODataContext context = getService().getProcessor().getContext(); assertNotNull(context); final ODataService service = context.getService(); assertNotNull(service); assertEquals(Status.OK.getStatusCode(), response.getStatusLine().getStatusCode()); assertEquals("$metadata", context.getPathInfo().getODataSegments().get(0).getPath()); }