blob: 1e5e7c4bcd0a92f8da063878215316ea62b940bb [file] [log] [blame]
Ray Milkey2287d882015-01-30 10:15:20 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.rest;
17
18import org.junit.Test;
19
20import com.sun.jersey.api.client.UniformInterfaceException;
21import com.sun.jersey.api.client.WebResource;
22
23import static org.hamcrest.Matchers.containsString;
24import static org.junit.Assert.assertThat;
25import static org.junit.Assert.fail;
26
27/**
28 * Unit tests for bad REST requests.
29 */
30public class BadRequestTest extends ResourceTest {
31 @Test
32 public void badUrl() {
33 WebResource rs = resource();
34 try {
35 rs.path("ThisIsABadURL").get(String.class);
36 fail("Fetch of non-existent URL did not throw an exception");
37 } catch (UniformInterfaceException ex) {
38 assertThat(ex.getMessage(),
39 containsString("returned a response status of 404 Not Found"));
40 }
41 }
42}