mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-09 14:39:09 +00:00
Merge branch 'betamax'
This commit is contained in:
commit
7964e1bb36
4 changed files with 93 additions and 2 deletions
16
pom.xml
16
pom.xml
|
@ -415,12 +415,12 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!-- Commons -->
|
||||
<dependency>
|
||||
|
@ -451,6 +451,18 @@
|
|||
<version>4.8.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.robfletcher</groupId>
|
||||
<artifactId>betamax</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>1.7.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
55
src/test/java/org/rundeck/api/RundeckClientTest.java
Normal file
55
src/test/java/org/rundeck/api/RundeckClientTest.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2011 Vincent Behar
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.rundeck.api;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.rundeck.api.domain.RundeckProject;
|
||||
import betamax.Betamax;
|
||||
import betamax.Recorder;
|
||||
|
||||
/**
|
||||
* Test the {@link RundeckClient}. Uses betamax to unit-test HTTP requests without a live RunDeck instance.
|
||||
*
|
||||
* @author Vincent Behar
|
||||
*/
|
||||
public class RundeckClientTest {
|
||||
|
||||
@Rule
|
||||
public Recorder recorder = new Recorder();
|
||||
|
||||
private RundeckClient client;
|
||||
|
||||
@Test
|
||||
@Betamax(tape = "get_projects")
|
||||
public void getProjects() throws Exception {
|
||||
List<RundeckProject> projects = client.getProjects();
|
||||
Assert.assertEquals(1, projects.size());
|
||||
Assert.assertEquals("test", projects.get(0).getName());
|
||||
Assert.assertNull(projects.get(0).getDescription());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// not that you can put whatever here, because we don't actually connect to the RunDeck instance
|
||||
// but instead use betamax as a proxy to serve the previously recorded tapes (in src/test/resources)
|
||||
client = new RundeckClient("http://rundeck.local:4440", "PVnN5K3OPc5vduS3uVuVnEsD57pDC5pd");
|
||||
}
|
||||
|
||||
}
|
4
src/test/resources/betamax.properties
Normal file
4
src/test/resources/betamax.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
betamax.tapeRoot=src/test/resources/betamax/tapes
|
||||
betamax.proxyPort=1337
|
||||
betamax.proxyTimeout=5000
|
||||
betamax.defaultMode=READ_ONLY
|
20
src/test/resources/betamax/tapes/get_projects.yaml
Normal file
20
src/test/resources/betamax/tapes/get_projects.yaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
!tape
|
||||
name: get_projects
|
||||
interactions:
|
||||
- recorded: 2011-09-18T16:04:45.973Z
|
||||
request:
|
||||
method: GET
|
||||
uri: http://rundeck.local:4440/api/2/projects
|
||||
headers:
|
||||
Host: rundeck.local:4440
|
||||
Proxy-Connection: Keep-Alive
|
||||
User-Agent: RunDeck API Java Client 2
|
||||
X-RunDeck-Auth-Token: PVnN5K3OPc5vduS3uVuVnEsD57pDC5pd
|
||||
response:
|
||||
status: 200
|
||||
headers:
|
||||
Content-Type: text/xml; charset=utf-8
|
||||
Expires: Thu, 01 Jan 1970 00:00:00 GMT
|
||||
Server: Jetty(6.1.21)
|
||||
Set-Cookie: JSESSIONID=mxrbh6byhvxt;Path=/
|
||||
body: <result success='true' apiversion='2'><projects count='1'><project><name>test</name><description></description></project></projects></result>
|
Loading…
Add table
Add a link
Reference in a new issue