mirror of https://github.com/apache/jclouds.git
easier param when job xml is already a string
This commit is contained in:
parent
d83ce9c154
commit
a1ff6f3b59
|
@ -28,8 +28,10 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous;
|
import org.jclouds.jenkins.v1.filters.BasicAuthenticationUnlessAnonymous;
|
||||||
import org.jclouds.jenkins.v1.functions.ReturnVoidOn302Or404;
|
import org.jclouds.jenkins.v1.functions.ReturnVoidOn302Or404;
|
||||||
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -44,13 +46,20 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
public interface JobAsyncClient {
|
public interface JobAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see JobClient#createFromXML
|
* @see JobClient#createFromXML(String, Payload)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/createItem")
|
@Path("/createItem")
|
||||||
@Produces(MediaType.TEXT_XML)
|
@Produces(MediaType.TEXT_XML)
|
||||||
ListenableFuture<Void> createFromXML(@QueryParam("name") String displayName, Payload xml);
|
ListenableFuture<Void> createFromXML(@QueryParam("name") String displayName, Payload xml);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see JobClient#createFromXML(String, String)
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/createItem")
|
||||||
|
@Produces(MediaType.TEXT_XML)
|
||||||
|
ListenableFuture<Void> createFromXML(@QueryParam("name") String displayName, @BinderParam(BindToStringPayload.class) String xml);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see JobClient#getJobView
|
* @see JobClient#getJobView
|
||||||
|
|
|
@ -41,6 +41,8 @@ public interface JobClient {
|
||||||
*/
|
*/
|
||||||
void createFromXML(String displayName, Payload xml);
|
void createFromXML(String displayName, Payload xml);
|
||||||
|
|
||||||
|
void createFromXML(String displayName, String xml);
|
||||||
|
|
||||||
void delete(String displayName);
|
void delete(String displayName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.jenkins.v1.features;
|
package org.jclouds.jenkins.v1.features;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.jenkins.v1.JenkinsClient;
|
import org.jclouds.jenkins.v1.JenkinsClient;
|
||||||
import org.jclouds.jenkins.v1.internal.BaseJenkinsClientExpectTest;
|
import org.jclouds.jenkins.v1.internal.BaseJenkinsClientExpectTest;
|
||||||
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
@ -34,8 +36,6 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "JobClientExpectTest")
|
@Test(groups = "unit", testName = "JobClientExpectTest")
|
||||||
public class JobClientExpectTest extends BaseJenkinsClientExpectTest {
|
public class JobClientExpectTest extends BaseJenkinsClientExpectTest {
|
||||||
|
|
||||||
public void testCreateJobWhenResponseIs2xx() {
|
|
||||||
HttpRequest createJob = HttpRequest.builder()
|
HttpRequest createJob = HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create("http://localhost:8080/createItem?name=blagoo"))
|
.endpoint(URI.create("http://localhost:8080/createItem?name=blagoo"))
|
||||||
|
@ -46,11 +46,19 @@ public class JobClientExpectTest extends BaseJenkinsClientExpectTest {
|
||||||
|
|
||||||
HttpResponse createJobResponse = HttpResponse.builder().statusCode(200).build();
|
HttpResponse createJobResponse = HttpResponse.builder().statusCode(200).build();
|
||||||
|
|
||||||
|
public void testCreateJobPayloadWhenResponseIs2xx() {
|
||||||
|
|
||||||
JenkinsClient createJobWhenCreated = requestSendsResponse(createJob, createJobResponse);
|
JenkinsClient createJobWhenCreated = requestSendsResponse(createJob, createJobResponse);
|
||||||
|
|
||||||
createJobWhenCreated.getJobClient().createFromXML("blagoo", payloadFromResource("/sample_job.xml"));
|
createJobWhenCreated.getJobClient().createFromXML("blagoo", payloadFromResource("/sample_job.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCreateJobStringWhenResponseIs2xx() throws IOException {
|
||||||
|
JenkinsClient createJobWhenCreated = requestSendsResponse(createJob, createJobResponse);
|
||||||
|
|
||||||
|
createJobWhenCreated.getJobClient().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml")));
|
||||||
|
}
|
||||||
|
|
||||||
public void testDeleteJobWhenResponseIs2xx() {
|
public void testDeleteJobWhenResponseIs2xx() {
|
||||||
HttpRequest deleteJob = HttpRequest.builder()
|
HttpRequest deleteJob = HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.jenkins.v1.features;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jclouds.io.Payloads;
|
|
||||||
import org.jclouds.jenkins.v1.internal.BaseJenkinsClientLiveTest;
|
import org.jclouds.jenkins.v1.internal.BaseJenkinsClientLiveTest;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
|
@ -35,8 +34,7 @@ public class JobClientLiveTest extends BaseJenkinsClientLiveTest {
|
||||||
|
|
||||||
public void testCreateJob() throws IOException {
|
public void testCreateJob() throws IOException {
|
||||||
getClient().delete("blagoo");
|
getClient().delete("blagoo");
|
||||||
getClient().createFromXML("blagoo",
|
getClient().createFromXML("blagoo", Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml")));
|
||||||
Payloads.newPayload(Strings2.toStringAndClose(getClass().getResourceAsStream("/sample_job.xml"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateJob")
|
@Test(dependsOnMethods = "testCreateJob")
|
||||||
|
|
Loading…
Reference in New Issue