diff options
author | jesus m. rodriguez <jesusr@redhat.com> | 2009-07-30 14:54:43 -0400 |
---|---|---|
committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-07-30 14:54:43 -0400 |
commit | 5da18950ed4186cf410dde4ab307754d450112f9 (patch) | |
tree | 10f8b31dab28c3c8b63b8d4743594d54d795fc36 | |
parent | a88dbeab8f95777bc7e34ace9591867fcbd9647e (diff) | |
download | candlepin-5da18950ed4186cf410dde4ab307754d450112f9.tar.gz candlepin-5da18950ed4186cf410dde4ab307754d450112f9.tar.xz candlepin-5da18950ed4186cf410dde4ab307754d450112f9.zip |
adding a test api to cleanup userapi
-rwxr-xr-x | proxy/code/scripts/test-testapi.py | 24 | ||||
-rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/api/TestApi.java | 54 |
2 files changed, 78 insertions, 0 deletions
diff --git a/proxy/code/scripts/test-testapi.py b/proxy/code/scripts/test-testapi.py new file mode 100755 index 0000000..e60bd27 --- /dev/null +++ b/proxy/code/scripts/test-testapi.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import httplib, urllib +import sys + +if len(sys.argv) < 1: + print("please supply a message") + sys.exit(1) + +print("------------ TESTING json create") +params = '{"name":"now","uuid":"thiswork"}' +headers = {"Content-type":"application/json", + "Accept": "application/json"} +conn = httplib.HTTPConnection("localhost", 8080) +print("creating object with %s" % params) +conn.request("POST", '/candlepin/test/', params, headers) +response = conn.getresponse() +print("Status: %d Response: %s" % (response.status, response.reason)) +rsp = response.read() +conn.close() +print("------------ TESTING json get") +response = urllib.urlopen("http://localhost:8080/candlepin/test/") +rsp = response.read() +print("testjsonobject get: %s" % rsp) diff --git a/proxy/code/src/org/fedoraproject/candlepin/api/TestApi.java b/proxy/code/src/org/fedoraproject/candlepin/api/TestApi.java new file mode 100644 index 0000000..ddef6dc --- /dev/null +++ b/proxy/code/src/org/fedoraproject/candlepin/api/TestApi.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2008 Red Hat, Inc. + * + * This software is licensed to you under the GNU General Public License, + * version 2 (GPLv2). There is NO WARRANTY for this software, express or + * implied, including the implied warranties of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 + * along with this software; if not, see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * Red Hat trademarks are not licensed under GPLv2. No permission is + * granted to use or replicate Red Hat trademarks that are incorporated + * in this software or its documentation. + */ +package org.fedoraproject.candlepin.api; + +import org.fedoraproject.candlepin.model.JsonTestObject; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + + +/** + * TestApi - used to prototype RESTful things without mucking up real + * test classes. + * @version $Rev$ + */ +@Path("/test") +public class TestApi { + + private static JsonTestObject jto = null; + + public TestApi() { + System.out.println("hello from TestApi ctor"); + } + + @GET + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + public JsonTestObject get() { + return jto; + } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + public void create(JsonTestObject obj) { + jto = obj; + System.out.println("object.name:" + obj.getName()); + System.out.println("jto.name:" + jto.getName()); + } +} |