Removed prototype REST resource
Change-Id: I3edf7b7e1b4f8e7b1d26b3c5945e614da328014d
Showing
2 changed files
with
0 additions
and
96 deletions
| 1 | -/* | ||
| 2 | - * Copyright 2014 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 | - */ | ||
| 16 | -package org.onosproject.rest; | ||
| 17 | - | ||
| 18 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 19 | -import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 20 | -import org.onlab.rest.BaseResource; | ||
| 21 | - | ||
| 22 | -import javax.ws.rs.DefaultValue; | ||
| 23 | -import javax.ws.rs.GET; | ||
| 24 | -import javax.ws.rs.Path; | ||
| 25 | -import javax.ws.rs.Produces; | ||
| 26 | -import javax.ws.rs.QueryParam; | ||
| 27 | -import javax.ws.rs.core.MediaType; | ||
| 28 | -import javax.ws.rs.core.Response; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * Simple example on how to write a testable JAX-RS resource. | ||
| 32 | - */ | ||
| 33 | -@Path("greet") | ||
| 34 | -public class GreetResource extends BaseResource { | ||
| 35 | - | ||
| 36 | - @GET | ||
| 37 | - @Produces(MediaType.APPLICATION_JSON) | ||
| 38 | - public Response yo(@QueryParam("name") @DefaultValue("dude") String name) { | ||
| 39 | - ObjectMapper mapper = new ObjectMapper(); | ||
| 40 | - ObjectNode root = mapper.createObjectNode(); | ||
| 41 | - root.put("greeting", "Yo!!!!"); | ||
| 42 | - return Response.ok(root).build(); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2014 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 | - */ | ||
| 16 | -package org.onosproject.rest; | ||
| 17 | - | ||
| 18 | -import com.sun.jersey.api.client.WebResource; | ||
| 19 | -import com.sun.jersey.test.framework.JerseyTest; | ||
| 20 | -import org.junit.BeforeClass; | ||
| 21 | -import org.junit.Ignore; | ||
| 22 | -import org.junit.Test; | ||
| 23 | - | ||
| 24 | -import static org.junit.Assert.assertTrue; | ||
| 25 | - | ||
| 26 | -/** | ||
| 27 | - * Simple example on how to write a JAX-RS unit test using Jersey test framework. | ||
| 28 | - * A base class should/will be created to provide further assistance for testing. | ||
| 29 | - */ | ||
| 30 | -public class GreetResourceTest extends JerseyTest { | ||
| 31 | - | ||
| 32 | - public GreetResourceTest() { | ||
| 33 | - super("org.onosproject.rest"); | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - @BeforeClass | ||
| 37 | - public static void classSetUp() { | ||
| 38 | -// ServiceDirectory testDirectory = | ||
| 39 | -// new TestServiceDirectory().add(GreetService.class, new GreetManager()); | ||
| 40 | -// GreetResource.setServiceDirectory(testDirectory); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - @Ignore | ||
| 44 | - @Test | ||
| 45 | - public void basics() { | ||
| 46 | - WebResource rs = resource(); | ||
| 47 | - String response = rs.path("greet").get(String.class); | ||
| 48 | - assertTrue("incorrect response", response.contains("greeting")); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | -} |
-
Please register or login to post a comment