Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vitalijr2/ijhttp-tools
Maven plugin, Spring Boot Test autoconfiguration and jUnit Extension for IntelliJ HTTP Client
https://github.com/vitalijr2/ijhttp-tools
Last synced: 14 days ago
JSON representation
Maven plugin, Spring Boot Test autoconfiguration and jUnit Extension for IntelliJ HTTP Client
- Host: GitHub
- URL: https://github.com/vitalijr2/ijhttp-tools
- Owner: vitalijr2
- License: apache-2.0
- Created: 2024-02-03T07:23:08.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-03T15:55:11.000Z (about 2 months ago)
- Last Synced: 2024-12-07T22:29:18.428Z (15 days ago)
- Language: Java
- Size: 381 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: contributing.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
README
# Maven plugin, Spring Boot Test autoconfiguration and jUnit Extension for IntelliJ HTTP Client
I had started with a Maven plugin to run HTTP requests
on the _integration-test_ phase
using the [IntelliJ HTTP Client][http-client].
Later I added a Spring Boot Test autoconfiguration,
thanks [@GoncaloPT][GoncaloPT] for [his idea][leverage-test].
Next step was jUnit Extension.[![Codacy Badge](https://app.codacy.com/project/badge/Grade/5bd5f31b51114de7b29663d2bf000aaa)](https://app.codacy.com/gh/vitalijr2/ijhttp-tools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Codacy Coverage](https://app.codacy.com/project/badge/Coverage/5bd5f31b51114de7b29663d2bf000aaa)](https://app.codacy.com/gh/vitalijr2/ijhttp-tools/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
[![Java Version](https://img.shields.io/static/v1?label=java&message=17&color=blue&logo=java&logoColor=E23D28)](https://www.oracle.com/java/technologies/downloads/#java17)## Table of Contents
* [Getting started](#getting-started)
* [Directories (extra feature)](#directories-extra-feature)
* [Usage](#usage)
* [Maven plugin](#maven-plugin)
* [jUnit Extension](#junit-extension)
* [Spring Boot Test autoconfiguration](#spring-boot-test-autoconfiguration)
* [Contributing](#contributing)
* [History](#history)
* [License](#license)Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
![Screenshot](screenshot.png)
## Getting started
Originally the IntelliJ HTTP Client plugin allows to create, edit,
and execute HTTP requests directly in the IntelliJ IDEA code editor.
The IntelliJ HTTP Client is also [available as a CLI tool][cli-tool].The Maven plugin and jUnit Extension allow to run HTTP requests
on the _integration-test_ phase using the IntelliJ HTTP Client.
The Spring Boot Test autoconfiguration allows to run them with
Spring Boot Test, you don't need to package and run whole application.The [HTTP Request in Editor Specification][specification]
describes format these files.Example requests:
```http
GET /api/get HTTP/1.1
Accept: application/json
Host: example.com### Add an item
POST /api/add HTTP/1.1
Host: example.com
Content-Type: application/json{
"name": "entity",
"value": "content"
}
```### Directories (extra feature)
**IntelliJ HTTP Client** needs HTTP files to work.
With **HTTP Client Command Line** you can set directories
that contain such files.## Usage
**Important!** plugin, extension and autoconfiguration
do not contain the HTTP client: you need to install it by yourself
then add to `PATH`. You can also set the full path to the **ijhttp**
via the parameter `executable`. The [HTTP Client Demo][demo] has some examples
how to download the HTTP client.### Maven plugin
[![Maven Central](https://img.shields.io/maven-central/v/uk.bot-by.ijhttp-tools/ijhttp-maven-plugin)](https://search.maven.org/artifact/uk.bot-by.ijhttp-tools/ijhttp-maven-plugin)
[![Javadoc](https://javadoc.io/badge2/uk.bot-by.ijhttp-tools/ijhttp-maven-plugin/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.ijhttp-tools/ijhttp-maven-plugin)There is one goal **run**. To use it add the plugin to your POM.
Example of full configuration:
```xml
io.gitlab.vitalijr2.ijhttp-tools
ijhttp-maven-plugin
src/test/resources
public-env.json
dev
sample-1-queries.http
sample-2-queries.http
HEADERS
true
target
run
simple-run-with-report
```
To manage plugin's output use `useMavenLogger`, `quietLogs` and `outputFile`.
### jUnit Extension
[![Maven Central](https://img.shields.io/maven-central/v/uk.bot-by.ijhttp-tools/ijhttp-junit-extension)](https://search.maven.org/artifact/uk.bot-by.ijhttp-tools/ijhttp-junit-extension)
[![Javadoc](https://javadoc.io/badge2/uk.bot-by.ijhttp-tools/ijhttp-junit-extension/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.ijhttp-tools/ijhttp-junit-extension)Use annotations `HttpClientExecutor` and `HttpClientCommandLineParameters`
to initialise and configure both executor and command line builder.Example of full configuration:
```java
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@AutoConfigureHttpClientCommandLine(timeout = 7000)
class HttpClientCommandLineApplicationTests {@Autowired
private Executor executor;@Autowired
private HttpClientCommandLine httpClientCommandLine;@Test
void httpClientCommandLine() throws IOException {
// when
var exitCode = executor.execute(httpClientCommandLine.getCommandLine());// then
assertEquals(0, exitCode);
}}
```### Spring Boot Test autoconfiguration
[![Maven Central](https://img.shields.io/maven-central/v/uk.bot-by.ijhttp-tools/ijhttp-spring-boot-test)](https://search.maven.org/artifact/uk.bot-by.ijhttp-tools/ijhttp-spring-boot-test)
[![Javadoc](https://javadoc.io/badge2/uk.bot-by.ijhttp-tools/ijhttp-spring-boot-test/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.ijhttp-tools/ijhttp-spring-boot-test)You can set configuration in `application.yaml` or manually,
or combine both ways.Example of autoconfiguration, full configuration:
```yaml
ijhttp:
parameters:
connect-timeout: 9000
directories:
- src/test/resources/ijhttp
# docker-mode: false default value
environment-file: public-env.json
environment-name: dev
# executable: ijhttp default value
files:
- orders.http
- products.http
- checkout.http
# insecure: false default value
log-level: verbose
private-environment-file: private-env.json
# proxy: http://localhost:3128/
report: true
report-path: target/ijhttp
socket-timeout: 9000
# timeout: 7000
``````java
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@AutoConfigureHttpClientCommandLine(timeout = 7000)
class HttpClientCommandLineApplicationTests {@Autowired
private Executor executor;@Autowired
private HttpClientCommandLine httpClientCommandLine;@Test
void httpClientCommandLine() throws IOException {
// when
var exitCode = executor.execute(httpClientCommandLine.getCommandLine());// then
assertEquals(0, exitCode);
}}
````## Contributing
Please read [Contributing](contributing.md).
## History
See [Changelog](changelog.md)
## License
Copyright 2023-2024 Vitalij Berdinskih
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 atUnless 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.[Apache License v2.0](LICENSE)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html)[http-client]: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html
[GoncaloPT]: https://github.com/GoncaloPT
[leverage-test]: https://github.com/bot-by/ijhttp-tools/issues/51 "Leverage test instead of using main app"
[cli-tool]: https://www.jetbrains.com/help/idea/http-client-cli.html
[specification]: https://github.com/JetBrains/http-request-in-editor-spec
[demo]: https://gitlab.com/vitalijr2/ijhttp-demo