All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JavaSpring.libraries.spring-mvc.api_test.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import java.util.*;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.testng.annotations.Test;
import static org.junit.Assert.assertTrue;
/**
* Test class to verify that GET endpoints on generated project are reached.
*/
public class {{classname}}ControllerIT {

    {{#operations}}
    {{#operation}}
    {{#vendorExtensions.x-is-get-method}}
    @Test
        public void {{operationId}}Test() throws Exception {
            final String requestURL = "http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}{{testPath}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{paramName}}={{testExample}}{{#hasMore}}&{{/hasMore}}{{/queryParams}}";
            final HttpClient client = HttpClientBuilder.create().build();
            final HttpResponse response = client.execute(new HttpGet(requestURL));
            assertTrue((response.getStatusLine().getStatusCode() == 415) || (response.getStatusLine().getStatusCode() == 501));
        }
    {{/vendorExtensions.x-is-get-method}}
    {{/operation}}
    {{/operations}}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy