This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<String> getFileAsListOfStrings(String fileName) throws IOException { | |
InputStream input = this.getClass().getResourceAsStream("/" + fileName); | |
return IOUtils.readLines(input, StandardCharsets.UTF_8); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class TestData extends FileReader { | |
@Value("${testData.users.file}") | |
private String usersFile; | |
public List<User> getUsers() { | |
Gson gson = new Gson(); | |
return Arrays.asList(gson.fromJson(getFileAsString(usersFile), User[].class)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter</artifactId> | |
<exclusions> | |
<exclusion> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-tomcat</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// host will be passed in the groovy bindings for extended choice plugin. | |
def getVersion = { host, path -> | |
try { | |
def version = new groovy.json.JsonSlurper().parse(new URL("https://${host}${path}")).version | |
return version | |
} catch(Exception e) { | |
return null | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String url = "https://www.some-web-service/api/endpoint"; | |
HttpGet get = new HttpGet(url); | |
Header headers[] = { new BasicHeader("Accept", "application/json")}; | |
get.setHeaders(headers); | |
CloseableHttpClient client = HttpClients.custom().build(); | |
HttpResponse response = client.execute(get); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Listeners(value = ConditionalSkipTestAnalyzer.class) | |
public class ExampleConditionalSkippingTest { | |
@NonProduction | |
@Test | |
public void test1() { } | |
@ProductionOnly | |
@Test | |
public void test2() { } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.charset.StandardCharsets; | |
import org.apache.http.Header; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.methods.HttpDelete; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.client.methods.HttpPost; | |
import org.apache.http.client.methods.HttpPut; | |
import org.apache.http.entity.StringEntity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.nio.charset.StandardCharsets; | |
import java.util.Arrays; | |
import java.util.List; | |
import io.lenar.examples.spring.TestNGWithSpringApplication; | |
import io.lenar.examples.spring.http.HttpClient; | |
import io.lenar.examples.spring.model.Book; | |
import org.apache.commons.io.IOUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import io.lenar.examples.spring.clients.response.BookResponse; | |
import io.lenar.examples.spring.clients.response.BooksResponse; | |
import io.lenar.examples.spring.clients.response.Response; | |
import io.lenar.examples.spring.http.HttpClient; | |
import io.lenar.examples.spring.model.Book; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.stereotype.Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Response { | |
private ResponseStatus status; | |
public Response(HttpResponse httpResponse) { | |
this.status = new ResponseStatus(httpResponse); | |
} | |
public ResponseStatus getStatus() { | |
return status; | |
} |