spark-test

A library that allows the test of Spark Web Framework based applications using HTTP

Лицензия

Лицензия

Группа

Группа

com.despegar
Идентификатор

Идентификатор

spark-test
Последняя версия

Последняя версия

1.1.8
Дата

Дата

Тип

Тип

jar
Описание

Описание

spark-test
A library that allows the test of Spark Web Framework based applications using HTTP
Ссылка на сайт

Ссылка на сайт

https://github.com/despegar/spark-test
Система контроля версий

Система контроля версий

https://github.com/despegar/spark-test.git

Скачать spark-test

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.despegar/spark-test/ -->
<dependency>
    <groupId>com.despegar</groupId>
    <artifactId>spark-test</artifactId>
    <version>1.1.8</version>
</dependency>
// https://jarcasting.com/artifacts/com.despegar/spark-test/
implementation 'com.despegar:spark-test:1.1.8'
// https://jarcasting.com/artifacts/com.despegar/spark-test/
implementation ("com.despegar:spark-test:1.1.8")
'com.despegar:spark-test:jar:1.1.8'
<dependency org="com.despegar" name="spark-test" rev="1.1.8">
  <artifact name="spark-test" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.despegar', module='spark-test', version='1.1.8')
)
libraryDependencies += "com.despegar" % "spark-test" % "1.1.8"
[com.despegar/spark-test "1.1.8"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.sparkjava : spark-core jar [2.2, )
com.despegar : http-java-native-client jar 1.0.4
junit : junit jar [4.7, 4.12]

test (1)

Идентификатор библиотеки Тип Версия
org.slf4j : slf4j-simple jar 1.6.1

Модули Проекта

Данный проект не имеет модулей.

Spark Web Framework Test Library

This library allows testing Spark Web Framework based applications through HTTP. This way, the complete flow of the application can be tested, from the parsing of a HTTP request through business logic, executing asserts against HTTP responses headers, status, body, etc.

Getting Started

Dependency

Maven

Add to your pom.xml dependencies

<dependency>
    <groupId>com.despegar</groupId>
    <artifactId>spark-test</artifactId>
    <version>1.1.8</version>
</dependency>

Gradle

Add to your build.gradle dependencies:

dependencies {
    testCompile "com.despegar:spark-test:1.1.8"
}

Usage

/**
 * The class that defines a Spark Web Framework route
 *
 */
public class TestController {

	public TestController() {
		get("/test", (request, response) ->  this.testMethod(request, response));
	}

	public String testMethod(Request request, Response response) {
		return "This works!";
	}

}
/**
 * The test class
 *
 */
public class TestControllerTest {

	public static class TestContollerTestSparkApplication implements SparkApplication {
		@Override
		public void init() {
			new TestController();
		}
	}

	@ClassRule
	public static SparkServer<TestContollerTestSparkApplication> testServer = new SparkServer<>(TestControllerTest.TestContollerTestSparkApplication.class, 4567);

	@Test
	public void test() throws Exception {
		/* The second parameter indicates whether redirects must be followed or not */
		GetMethod get = testServer.get("/test", false);
		get.addHeader("Test-Header", "test");
		HttpResponse httpResponse = testServer.execute(get);
		assertEquals(200, httpResponse.code());
		assertEquals("This works!", new String(httpResponse.body()));
		assertNotNull(testServer.getApplication());
	}

}

Now http-java-native-client is used. The HTTP response body is a byte[]. You can parse it as necessary.

com.despegar

Despegar

Creamos experiencias de viaje que enriquecen tu vida

Версии библиотеки

Версия
1.1.8
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1
1.0