diff --git a/changelog.md b/changelog.md index 39f1d73..22d86b6 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The proxy feature - The report path - Split Maven plugin and CLI builder modules +- The Spring Boot Test autoconfiguration ## 1.0.1 - 2023-11-08 ### Fixed diff --git a/command-line/pom.xml b/command-line/pom.xml index 0fc0cce..88ce999 100644 --- a/command-line/pom.xml +++ b/command-line/pom.xml @@ -86,11 +86,34 @@ 4.0.0 - IntelliJ HTTP Client Tools : CLI Builder + HTTP Client Tools : Command Line jar ijhttp-parent uk.bot-by.ijhttp-tools ${revision}${changelist}${sha1} + + + + + + maven-javadoc-plugin + + + + https://javadoc.io/doc/org.apache.commons/commons-exec/${commons-exec.version} + + + https://javadoc.io/doc/org.jetbrains/annotations/${jetbrains-annotations.version} + + + + org.apache.maven.plugins + + + + javadocs + + diff --git a/command-line/readme.md b/command-line/readme.md new file mode 100644 index 0000000..d65872e --- /dev/null +++ b/command-line/readme.md @@ -0,0 +1,23 @@ +# HTTP Client Command Line + +[![Maven Central](https://img.shields.io/maven-central/v/uk.bot-by.ijhttp-tools/ijhttp-command-line)](https://search.maven.org/artifact/uk.bot-by.ijhttp-tools/ijhttp-command-line) +[![Javadoc](https://javadoc.io/badge2/uk.bot-by.ijhttp-tools/ijhttp-command-line/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.ijhttp-tools/ijhttp-command-line) + +The builder-style component [HttpClientCommandLine][component] helps to prepare command line +to run [Intellij HTTP Client CLI tool][cli-tool]. + +The minimal configuration contains HTTP files only: +```java +var commandLine = new HttpClientCommandLine(); +var executor = new DefaultExecutor(); +var orders = Path.of("orders.http").toFile(); +var products = Path.of("products.http").toFile(); +var checkout = Path.of("checkout.http").toFile(); + +commandLine.files(java.util.List.of(orders, products, checkout)); +executor.execute(commandLine.getCommandLine()); +``` + +[component]: src/main/java/uk/bot_by/ijhttp_tools/command_line/HttpClientCommandLine.java + +[cli-tool]: https://www.jetbrains.com/help/idea/http-client-cli.html \ No newline at end of file diff --git a/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/HttpClientCommandLine.java b/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/HttpClientCommandLine.java index 215e2a2..a130aa6 100644 --- a/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/HttpClientCommandLine.java +++ b/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/HttpClientCommandLine.java @@ -25,6 +25,25 @@ import org.apache.commons.exec.CommandLine; import org.jetbrains.annotations.NotNull; +/** + * HTTP Client command line parameters. + *

+ * The minimal configuration contains HTTP files only: + *


+ * var commandLine = new HttpClientCommandLine();
+ * var executor = new DefaultExecutor();
+ * var files = Path.of("orders.http").toFile();
+ * var products = Path.of("products.http").toFile();
+ * var checkout = Path.of("checkout.http").toFile();
+ *
+ * commandLine.files(List.of(files, products, checkout));
+ * executor.execute(commandLine.getCommandLine());
+ * 
+ *

+ * IntelliJ HTTP Client uses --report as boolean option and parameter with a file + * value. The component implements it by two methods: {@link #report(boolean)} and + * {@link #reportPath(java.io.File)}. + */ public class HttpClientCommandLine { private static final String CONNECT_TIMEOUT = "--connect-timeout"; @@ -195,6 +214,14 @@ public void socketTimeout(@NotNull Integer socketTimeout) { this.socketTimeout = socketTimeout; } + /** + * Get command line. + * + * @return command line + * @throws IllegalArgumentException if HTTP files are missed + * @throws IOException if path to HTTP or environment files or report directory is + * wrong + */ public CommandLine getCommandLine() throws IllegalArgumentException, IOException { var commandLine = new CommandLine(executable); diff --git a/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/package-info.java b/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/package-info.java new file mode 100644 index 0000000..dfc9ea9 --- /dev/null +++ b/command-line/src/main/java/uk/bot_by/ijhttp_tools/command_line/package-info.java @@ -0,0 +1,15 @@ +/** + * The builder-style component {@link uk.bot_by.ijhttp_tools.command_line.HttpClientCommandLine} + * helps to prepare command line to run Intellij HTTP Client CLI tool. + *

+ * There are Maven Plugin + * + * ijhttp-maven-plugin and Spring Boot Test autoconfiguration + * + * ijhttp-spring-boot-test to run HTTP requests on the integration-test phase using the + * IntelliJ HTTP Client. + * + * @author Vitalij Berdinskih + * @since 1.0.0 + */ +package uk.bot_by.ijhttp_tools.command_line; \ No newline at end of file diff --git a/command-line/src/main/javadoc/overview.html b/command-line/src/main/javadoc/overview.html new file mode 100644 index 0000000..4eb4cd4 --- /dev/null +++ b/command-line/src/main/javadoc/overview.html @@ -0,0 +1,41 @@ + + + + + ijhttp tools, command line + + +

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. +

+

The command line artifact has the builder-style component + + HttpClientCommandLine to prepare command line + to run this CLI tool.

+

There are Maven Plugin + + ijhttp-maven-plugin and Spring Boot Test autoconfiguration + + ijhttp-spring-boot-test to run HTTP requests on the integration-test phase using + the IntelliJ HTTP Client.

+

The + HTTP Request in Editor + Specification describes format these files.

+

Example requests:

+

+  GET https://example.com/api/get
+
+  ### Add an item
+  POST https://example.com/api/add
+  Content-Type: application/json
+
+  {
+    "name": "entity",
+    "value": "content"
+  }
+
+ + \ No newline at end of file diff --git a/maven-plugin/src/main/javadoc/resources/ijhttp-maven-plugin.css b/command-line/src/main/javadoc/resources/ijhttp.css similarity index 100% rename from maven-plugin/src/main/javadoc/resources/ijhttp-maven-plugin.css rename to command-line/src/main/javadoc/resources/ijhttp.css diff --git a/command-line/src/main/javadoc/resources/prism.css b/command-line/src/main/javadoc/resources/prism.css new file mode 100644 index 0000000..6f16854 --- /dev/null +++ b/command-line/src/main/javadoc/resources/prism.css @@ -0,0 +1,3 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+http+json */ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} diff --git a/command-line/src/main/javadoc/resources/prism.js b/command-line/src/main/javadoc/resources/prism.js new file mode 100644 index 0000000..1101f43 --- /dev/null +++ b/command-line/src/main/javadoc/resources/prism.js @@ -0,0 +1,6 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+http+json */ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=g.reach);A+=w.value.length,w=w.next){var E=w.value;if(n.length>e.length)return;if(!(E instanceof i)){var P,L=1;if(y){if(!(P=l(b,A,e,m))||P.index>=e.length)break;var S=P.index,O=P.index+P[0].length,j=A;for(j+=w.value.length;S>=j;)j+=(w=w.next).value.length;if(A=j-=w.value.length,w.value instanceof i)continue;for(var C=w;C!==n.tail&&(jg.reach&&(g.reach=W);var z=w.prev;if(_&&(z=u(n,z,_),A+=_.length),c(n,z,L),w=u(n,z,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),L>1){var I={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,I),g&&I.reach>g.reach&&(g.reach=I.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a"+i.content+""},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); +Prism.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^$/i;var t={"included-cdata":{pattern://i,inside:s}};t["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var n={};n[a]={pattern:RegExp("(<__[^>]*>)(?:))*\\]\\]>|(?!)".replace(/__/g,(function(){return a})),"i"),lookbehind:!0,greedy:!0,inside:t},Prism.languages.insertBefore("markup","cdata",n)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(a,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+a+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml; +!function(t){function a(t){return RegExp("(^(?:"+t+"):[ \t]*(?![ \t]))[^]+","i")}t.languages.http={"request-line":{pattern:/^(?:CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PRI|PUT|SEARCH|TRACE)\s(?:https?:\/\/|\/)\S*\sHTTP\/[\d.]+/m,inside:{method:{pattern:/^[A-Z]+\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0,alias:"url",inside:t.languages.uri},"http-version":{pattern:/^(\s)HTTP\/[\d.]+/,lookbehind:!0,alias:"property"}}},"response-status":{pattern:/^HTTP\/[\d.]+ \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/[\d.]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},header:{pattern:/^[\w-]+:.+(?:(?:\r\n?|\n)[ \t].+)*/m,inside:{"header-value":[{pattern:a("Content-Security-Policy"),lookbehind:!0,alias:["csp","languages-csp"],inside:t.languages.csp},{pattern:a("Public-Key-Pins(?:-Report-Only)?"),lookbehind:!0,alias:["hpkp","languages-hpkp"],inside:t.languages.hpkp},{pattern:a("Strict-Transport-Security"),lookbehind:!0,alias:["hsts","languages-hsts"],inside:t.languages.hsts},{pattern:a("[^:]+"),lookbehind:!0}],"header-name":{pattern:/^[^:]+/,alias:"keyword"},punctuation:/^:/}}};var e,n=t.languages,s={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css,"text/plain":n.plain},i={"application/json":!0,"application/xml":!0};function r(t){var a=t.replace(/^[a-z]+\//,"");return"(?:"+t+"|\\w+/(?:[\\w.-]+\\+)+"+a+"(?![+\\w.-]))"}for(var p in s)if(s[p]){e=e||{};var l=i[p]?r(p):p;e[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+l+"(?:(?:\r\n?|\n)[\\w-].*)*(?:\r(?:\n|(?!\n))|\n))[^ \t\\w-][^]*","i"),lookbehind:!0,inside:s[p]}}e&&t.languages.insertBefore("http","header",e)}(Prism); +Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json; diff --git a/contributing.md b/contributing.md index 59a4121..75b2a9b 100644 --- a/contributing.md +++ b/contributing.md @@ -1,19 +1,19 @@ -# Contributing to IntelliJ HTTP Client Maven Plugin +# Contributing to HTTP Client Maven Plugin -**IntelliJ HTTP Client Maven Plugin** is an open-source project and all contributions are welcome +**HTTP Client Maven Plugin** is an open-source project and all contributions are welcome to assist with its development and maintenance. ## Issues (bug and feature tracker) Please report any bugs found, feature requests or other issues on -**IntelliJ HTTP Client Maven Plugin** [GitLab tracker][gitlab-issues] +**HTTP Client Maven Plugin** [GitLab tracker][gitlab-issues] or [GitHub tracker][github-issues]. When creating a new issue, try following [necolas's guidelines][issue-guidelines]. ## Fork, patch and contribute code -Feel free to fork **IntelliJ HTTP Client Maven Plugin**'s repository at [GitLab][bot-gitlab] +Feel free to fork **HTTP Client Maven Plugin**'s repository at [GitLab][bot-gitlab] or [GitHub][bot-github] for your own use and updates. Contribute your fixes and new features back to the main codebase using diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index 1ceec6d..773aba7 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -136,7 +136,7 @@ 4.0.0 - IntelliJ HTTP Client Tools : Maven Plugin + HTTP Client Tools : Maven Plugin bot-by https://bot-by.uk diff --git a/maven-plugin/readme.md b/maven-plugin/readme.md new file mode 100644 index 0000000..9d2a718 --- /dev/null +++ b/maven-plugin/readme.md @@ -0,0 +1,73 @@ +# 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) + +The plugin allows to run HTTP requests on the integration-test phase +using the [IntelliJ HTTP Client][http-client]. The [HTTP Request in Editor Specification][specification] +describes format these files. + +Example of test request: + +```language-apex +GET https://example.com/api/get + +### Add an item +POST https://example.com/api/add +Content-Type: application/json + +{ + "name": "entity", + "value": "content" +} +``` + +## Configuration + +**Important!** The plugin does not contain the [HTTP client][cli-tool]: +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. + +There is one goal **run**. To use it add the plugin to your POM. + +Example of full configuration: + +```language-xml + + uk.bot-by.ijhttp-tools + ijhttp-maven-plugin + + + + + 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`. + +You can play with [HTTP Client Demo][demo]. + +[http-client]: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html + +[specification]: https://github.com/JetBrains/http-request-in-editor-spec + +[cli-tool]: https://www.jetbrains.com/help/idea/http-client-cli.html + +[demo]: https://gitlab.com/vitalijr2/ijhttp-demo \ No newline at end of file diff --git a/maven-plugin/src/main/java/uk/bot_by/ijhttp_tools/maven_plugin/package-info.java b/maven-plugin/src/main/java/uk/bot_by/ijhttp_tools/maven_plugin/package-info.java index f2326c0..b800a5f 100644 --- a/maven-plugin/src/main/java/uk/bot_by/ijhttp_tools/maven_plugin/package-info.java +++ b/maven-plugin/src/main/java/uk/bot_by/ijhttp_tools/maven_plugin/package-info.java @@ -1,12 +1,18 @@ /** - * The plugin allows to run HTTP requests on the integration-test phase. + * The plugin allows to run HTTP requests on the integration-test phase using the IntelliJ + * HTTP Client. + *

+ * The HTTP Request in Editor + * Specification describes format these files. *

* Important! The plugin does not contain the HTTP client: you need to install it * by yourself then add to {@code PATH}. You can also set the full path to the ijhttp via the * parameter * {@linkplain uk.bot_by.ijhttp_tools.maven_plugin.RunMojo#setExecutable(java.lang.String) - * executable}. The IntelliJ HTTP Client Demo - * has some examples how to download the HTTP client. + * executable}. + *

+ * The IntelliJ HTTP Client Demo has some + * examples how to download the HTTP client. * * @author Vitalij Berdinskih * @since 1.0.0 diff --git a/maven-plugin/src/main/javadoc/overview.html b/maven-plugin/src/main/javadoc/overview.html index 49d438b..5583c4f 100644 --- a/maven-plugin/src/main/javadoc/overview.html +++ b/maven-plugin/src/main/javadoc/overview.html @@ -2,20 +2,21 @@ - IntelliJ HTTP Client, Maven Plugin + ijhttp tools, maven plugin

Originally the HTTP + href="https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html">IntelliJ HTTP Client plugin allows to create, edit, and execute HTTP requests directly in the - IntelliJ IDEA code editor. The HTTP Client is also available as a CLI tool.

-

The plugin allows to run HTTP requests through the IntelliJ HTTP Client on the integration-test - phase. The HTTP Request in Editor - Specification describes format these files. -

Example requests: +

The plugin allows to run HTTP requests on the integration-test + phase using the IntelliJ HTTP Client.

+

The HTTP Request in Editor + Specification describes format these files.

+

Example requests:


   GET https://example.com/api/get
 
diff --git a/maven-plugin/src/main/javadoc/resources/ijhttp.css b/maven-plugin/src/main/javadoc/resources/ijhttp.css
new file mode 100644
index 0000000..6ae99c4
--- /dev/null
+++ b/maven-plugin/src/main/javadoc/resources/ijhttp.css
@@ -0,0 +1,27 @@
+.tooltip {
+  border-bottom: 1px dotted #4d7a97;
+  display: inline-block;
+  position: relative;
+}
+
+.tooltip .tooltiptext {
+  background-color: #f8981d;
+  border: 1px dotted #4d7a97;
+  -moz-border-radius: 6px;
+  -ms-border-radius: 6px;
+  -webkit-border-radius: 6px;
+  border-radius: 6px;
+  color: #253441;
+  left: 113%;
+  padding: 5px 3px;
+  position: absolute;
+  text-align: center;
+  top: -5px;
+  visibility: hidden;
+  width: 97px;
+  z-index: 1;
+}
+
+.tooltip:hover .tooltiptext {
+  visibility: visible;
+}
diff --git a/pom.xml b/pom.xml
index 8bed495..a3eb3f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -252,12 +252,12 @@
         annotations
         org.jetbrains
         provided
-        24.1.0
+        ${jetbrains-annotations.version}
       
       
         commons-exec
         org.apache.commons
-        1.3
+        ${commons-exec.version}
       
       
       
@@ -328,7 +328,7 @@
     maven-plugin
     spring-boot-test
   
-  IntelliJ HTTP Client Tools
+  HTTP Client Tools
   pom
   
     
@@ -383,12 +383,11 @@
 							]]>
               true
               none
-              false
               ${java.home}/bin/javadoc
               public
               
-
+
 							]]>
             
             
@@ -501,11 +500,13 @@
   
   
     -SNAPSHOT
+    1.3
     https://github.com/bot-by/ijhttp-maven-plugin/releases
     https://gitlab.com/bot-by/ijhttp-maven-plugin/-/releases
     
     17
     3.6.3
+    24.1.0
     5.10.1
     3.8.5
     5.8.0
diff --git a/readme.md b/readme.md
index 638bdcd..f135d6c 100644
--- a/readme.md
+++ b/readme.md
@@ -1,7 +1,8 @@
-# IntelliJ HTTP Client Maven Plugin
+# ijhttp tools: Maven Plugin and Spring Boot Test autoconfiguration
 
-A Maven Plugin  to run HTTP requests through the [IntelliJ HTTP Client][http-client] on
-the integration-test phase.
+I had started with Maven Plugin to run HTTP requests on the integration-test phase
+using the [IntelliJ HTTP Client][http-client]. Later I added Spring Boot Test autoconfiguration,
+thanks @GoncaloPT for [his idea][leverage-test].
 
 [![Codacy Badge](https://app.codacy.com/project/badge/Grade/73e1f8501ed84b0580dcf7ccee82c1e0)](https://app.codacy.com/gl/bot-by/ijhttp-maven-plugin/dashboard?utm_source=gl&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
 [![Codacy Coverage](https://app.codacy.com/project/badge/Coverage/73e1f8501ed84b0580dcf7ccee82c1e0)](https://app.codacy.com/gl/bot-by/ijhttp-maven-plugin/dashboard?utm_source=gl&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage)
@@ -19,13 +20,18 @@ Table of Contents
 Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
 
 ![Screenshot](screenshot.png)
+
 ## Getting started
 
-Originally the HTTP Client plugin allows to create, edit, and execute HTTP requests directly in the
-IntelliJ IDEA code editor. The HTTP Client is also [available as a CLI tool][cli-tool].
+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 plugin allows to run HTTP requests on the integration-test phase
+using the IntelliJ HTTP Client. The autoconfiguration allows to run them with Spring Boot Test,
+you don't need to package and run whole application.
 
-The plugin allows to run HTTP requests through the IntelliJ HTTP Client on
-the integration-test phase. The [HTTP Request in Editor Specification][specification]
+The [HTTP Request in Editor Specification][specification]
 describes format these files.
 
 Example requests:
@@ -45,12 +51,15 @@ Content-Type: application/json
 
 ## Usage
 
-**Important!** The plugin does 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 [IntelliJ HTTP Client Demo][demo] has some examples how to download the HTTP client.
+**Important!** Both plugin 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.maven-plugin/ijhttp-maven-plugin)](https://search.maven.org/artifact/uk.bot-by.maven-plugin/ijhttp-maven-plugin)
-[![Javadoc](https://javadoc.io/badge2/uk.bot-by.maven-plugin/ijhttp-maven-plugin/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.maven-plugin/ijhttp-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.
 
@@ -85,7 +94,56 @@ Example of full configuration:
 
 To manage plugin's output use `useMavenLogger`, `quietLogs` and `outputFile`.
 
-You can play with [IntelliJ HTTP Client Demo][demo].
+### Spring Boot Test autoconfiguration
+
+You can set configuration in `application.yaml` or manually, or combine both ways.
+
+Example of autoconfiguration, full configuration:
+
+```yaml
+ijhttp:
+  parameters:
+    connect-timeout: 9000
+    # 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
 
@@ -111,11 +169,13 @@ 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)  
+[Apache License v2.0](LICENSE)
 [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0.html)
 
 [http-client]: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html
 
+[leverage-test]: https://github.com/bot-by/ijhttp-maven-plugin/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
diff --git a/spring-boot-test/pom.xml b/spring-boot-test/pom.xml
index 3ad75ae..24fc3e5 100644
--- a/spring-boot-test/pom.xml
+++ b/spring-boot-test/pom.xml
@@ -34,17 +34,26 @@
       
       
         maven-compiler-plugin
+        
+          
+            
+              spring-boot-configuration-processor
+              org.springframework.boot
+              ${configuration-processor.version}
+            
+          
+        
         org.apache.maven.plugins
       
       
         maven-surefire-plugin
-        org.apache.maven.plugins
         
           
             ch.qos.logback:logback-classic
             ch.qos.logback:logback-core
           
         
+        org.apache.maven.plugins
       
       
         maven-jar-plugin
@@ -52,13 +61,13 @@
       
       
         maven-failsafe-plugin
-        org.apache.maven.plugins
         
           
             ch.qos.logback:logback-classic
             ch.qos.logback:logback-core
           
         
+        org.apache.maven.plugins
       
       
         jacoco-maven-plugin
@@ -81,6 +90,12 @@
       org.springframework.boot
       3.2.0
     
+    
+      spring-boot-configuration-processor
+      org.springframework.boot
+      true
+      ${configuration-processor.version}
+    
     
       slf4j-api
       org.slf4j
@@ -119,7 +134,7 @@
     
   
   4.0.0
-  IntelliJ HTTP Client Tools : Spring Boot Test
+  HTTP Client Tools : Spring Boot Test
   jar
   
     ijhttp-parent
@@ -138,5 +153,32 @@
       
       run-its
     
+    
+      
+        
+          
+            maven-javadoc-plugin
+            
+              
+                
+                  https://javadoc.io/doc/org.apache.commons/commons-exec/${commons-exec.version}
+                
+                
+                  https://javadoc.io/doc/org.springframework.boot/spring-boot-autoconfigure/${configuration-processor.version}
+                
+                
+                  https://javadoc.io/doc/org.springframework.boot/spring-boot-test-autoconfigure/${configuration-processor.version}
+                
+              
+            
+            org.apache.maven.plugins
+          
+        
+      
+      javadocs
+    
   
+  
+    3.2.0
+  
 
diff --git a/spring-boot-test/readme.md b/spring-boot-test/readme.md
new file mode 100644
index 0000000..d009a1f
--- /dev/null
+++ b/spring-boot-test/readme.md
@@ -0,0 +1,87 @@
+# HTTP Client Spring Boot Test
+
+[![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)
+
+The Spring Boot Test autoconfiguration to run HTTP requests on the integration-test phase
+using the [IntelliJ HTTP Client][http-client].
+The [HTTP Request in Editor Specification][specification] describes format these files.
+
+Example of test request:
+
+```language-apex
+GET https://example.com/api/get
+
+### Add an item
+POST https://example.com/api/add
+Content-Type: application/json
+
+{
+  "name": "entity",
+  "value": "content"
+}
+```
+
+## Configuration
+
+**Important!** The autoconfiguration does not contain the [HTTP client][cli-tool]:
+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.
+
+Example of autoconfiguration, full configuration:
+
+```yaml
+ijhttp:
+  parameters:
+    connect-timeout: 9000
+    # 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);
+  }
+
+}
+```
+
+You can play with [HTTP Client Demo][demo].
+
+[http-client]: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html
+
+[specification]: https://github.com/JetBrains/http-request-in-editor-spec
+
+[cli-tool]: https://www.jetbrains.com/help/idea/http-client-cli.html
+
+[demo]: https://gitlab.com/vitalijr2/ijhttp-demo
\ No newline at end of file
diff --git a/spring-boot-test/src/it/autoconfiguration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java b/spring-boot-test/src/it/autoconfiguration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
index 5dc09b8..4f5d4a3 100644
--- a/spring-boot-test/src/it/autoconfiguration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
+++ b/spring-boot-test/src/it/autoconfiguration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
@@ -4,8 +4,10 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
+
 @RestController
 public class EchoController {
+
   @GetMapping("/echo")
   public ResponseEntity> echo(RequestEntity request) {
     return ResponseEntity.ok(request);
diff --git a/spring-boot-test/src/it/autoconfiguration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java b/spring-boot-test/src/it/autoconfiguration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
index acaec13..f2564cc 100644
--- a/spring-boot-test/src/it/autoconfiguration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
+++ b/spring-boot-test/src/it/autoconfiguration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
@@ -3,8 +3,6 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.IOException;
-import java.nio.file.Path;
-import java.util.List;
 import org.apache.commons.exec.Executor;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,11 +10,10 @@
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 import uk.bot_by.ijhttp_tools.command_line.HttpClientCommandLine;
-import uk.bot_by.ijhttp_tools.command_line.LogLevel;
-import uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigurationHttpClientCommandLine;
+import uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigureHttpClientCommandLine;
 
 @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-@AutoConfigurationHttpClientCommandLine(timeout = 7000)
+@AutoConfigureHttpClientCommandLine(timeout = 7000)
 class HttpClientCommandLineApplicationTests {
 
   @Autowired
@@ -31,10 +28,6 @@ class HttpClientCommandLineApplicationTests {
   @Test
   void httpClientCommandLine() throws IOException {
     // given
-    var files = List.of(Path.of("echo.http").toFile());
-
-    httpClientCommandLine.files(files);
-    httpClientCommandLine.logLevel(LogLevel.VERBOSE);
     httpClientCommandLine.environmentVariable(String.format("timeout=%s", timeout));
 
     // when
diff --git a/spring-boot-test/src/it/autoconfiguration/src/test/resources/application.yaml b/spring-boot-test/src/it/autoconfiguration/src/test/resources/application.yaml
index e66dc09..9ffbdac 100644
--- a/spring-boot-test/src/it/autoconfiguration/src/test/resources/application.yaml
+++ b/spring-boot-test/src/it/autoconfiguration/src/test/resources/application.yaml
@@ -1,7 +1,19 @@
 ijhttp:
   parameters:
-    files1:
-      - echo.http
+    connect-timeout: 9000
+    # docker-mode: false default value
+    environment-file: src/test/resources/ijhttp/public-env.json
+    environment-name: dev
+    # executable: ijhttp default value
+    files:
+      - src/test/resources/ijhttp/echo.http
+    # insecure: false default value
+    log-level: verbose
+    private-environment-file: src/test/resources/ijhttp/private-env.json
+    # proxy: http://localhost:3128/
+    report: true
+    report-path: target/ijhttp
+    socket-timeout: 9000
 
 spring:
   jackson:
diff --git a/spring-boot-test/src/it/autoconfiguration/echo.http b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/echo.http
similarity index 70%
rename from spring-boot-test/src/it/autoconfiguration/echo.http
rename to spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/echo.http
index d2b4436..c37ae75 100644
--- a/spring-boot-test/src/it/autoconfiguration/echo.http
+++ b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/echo.http
@@ -3,5 +3,7 @@ GET http://localhost:8080/echo
 Accept: application/json
 Test: AutoConfiguration
 Auto-Configured-Timeout: {{timeout}}
+Public-Variable: {{public}}
+Private-Variable: {{private}}
 
 ###
diff --git a/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/private-env.json b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/private-env.json
new file mode 100644
index 0000000..67a8ae6
--- /dev/null
+++ b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/private-env.json
@@ -0,0 +1,5 @@
+{
+  "dev": {
+    "private": "xyz"
+  }
+}
\ No newline at end of file
diff --git a/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/public-env.json b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/public-env.json
new file mode 100644
index 0000000..497929c
--- /dev/null
+++ b/spring-boot-test/src/it/autoconfiguration/src/test/resources/ijhttp/public-env.json
@@ -0,0 +1,5 @@
+{
+  "dev": {
+    "public": "1234"
+  }
+}
\ No newline at end of file
diff --git a/spring-boot-test/src/it/autoconfiguration/verify.groovy b/spring-boot-test/src/it/autoconfiguration/verify.groovy
new file mode 100644
index 0000000..16902b6
--- /dev/null
+++ b/spring-boot-test/src/it/autoconfiguration/verify.groovy
@@ -0,0 +1,3 @@
+File report = new File(basedir, "target/ijhttp/report.xml")
+
+assert report.file
diff --git a/spring-boot-test/src/it/manual-configuration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java b/spring-boot-test/src/it/manual-configuration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
index 6e30c8d..4f5d4a3 100644
--- a/spring-boot-test/src/it/manual-configuration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
+++ b/spring-boot-test/src/it/manual-configuration/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/EchoController.java
@@ -4,6 +4,7 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
+
 @RestController
 public class EchoController {
 
diff --git a/spring-boot-test/src/it/manual-configuration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java b/spring-boot-test/src/it/manual-configuration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
index 059183b..9039951 100644
--- a/spring-boot-test/src/it/manual-configuration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
+++ b/spring-boot-test/src/it/manual-configuration/src/test/java/uk/bot_by/ijhttp_tools/spring_boot_test/it.autoconfiguration/HttpClientCommandLineApplicationTests.java
@@ -36,6 +36,7 @@ void httpClientCommandLine() throws IOException {
     httpClientCommandLine.files(files);
     httpClientCommandLine.logLevel(LogLevel.VERBOSE);
     httpClientCommandLine.environmentVariable(String.format("timeout=%s", timeout));
+    httpClientCommandLine.report(true);
 
     // when
     var exitCode = executor.execute(httpClientCommandLine.getCommandLine());
diff --git a/spring-boot-test/src/it/manual-configuration/verify.groovy b/spring-boot-test/src/it/manual-configuration/verify.groovy
new file mode 100644
index 0000000..018c30c
--- /dev/null
+++ b/spring-boot-test/src/it/manual-configuration/verify.groovy
@@ -0,0 +1,3 @@
+File report = new File(basedir, "reports/report.xml")
+
+assert report.file
diff --git a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigurationHttpClientCommandLine.java b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigureHttpClientCommandLine.java
similarity index 92%
rename from spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigurationHttpClientCommandLine.java
rename to spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigureHttpClientCommandLine.java
index 35d9481..63286d1 100644
--- a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigurationHttpClientCommandLine.java
+++ b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/AutoConfigureHttpClientCommandLine.java
@@ -24,13 +24,16 @@
 import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
 import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
 
+/**
+ * HTTP Client Command Line autoconfiguration.
+ */
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @Inherited
 @ImportAutoConfiguration
 @PropertyMapping("ijhttp")
-public @interface AutoConfigurationHttpClientCommandLine {
+public @interface AutoConfigureHttpClientCommandLine {
 
   /**
    * The timeout for the process in milliseconds. It must be greater than 0.
diff --git a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineConfiguration.java b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineConfiguration.java
index 8a53583..506f8d2 100644
--- a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineConfiguration.java
+++ b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineConfiguration.java
@@ -30,12 +30,25 @@
 import org.springframework.context.annotation.Bean;
 import uk.bot_by.ijhttp_tools.command_line.HttpClientCommandLine;
 
+/**
+ * HTTP Client configuration provides {@linkplain org.apache.commons.exec.Executor executor} and
+ * {@linkplain uk.bot_by.ijhttp_tools.command_line.HttpClientCommandLine command line} beans.
+ */
 @ConditionalOnWebApplication(type = Type.SERVLET)
 @EnableConfigurationProperties(HttpClientCommandLineParameters.class)
 public class HttpClientCommandLineConfiguration {
 
   private final Logger logger = LoggerFactory.getLogger(HttpClientCommandLineConfiguration.class);
 
+  private static void copyBooleanParametersAndLogLevelAndExecutable(
+      HttpClientCommandLineParameters parameters, HttpClientCommandLine httpClientCommandLine) {
+    httpClientCommandLine.dockerMode(parameters.isDockerMode());
+    httpClientCommandLine.executable(parameters.getExecutable());
+    httpClientCommandLine.insecure(parameters.isInsecure());
+    httpClientCommandLine.logLevel(parameters.getLogLevel());
+    httpClientCommandLine.report(parameters.isReport());
+  }
+
   private static void handleEnvironment(HttpClientCommandLineParameters parameters,
       HttpClientCommandLine httpClientCommandLine) {
     if (nonNull(parameters.getEnvironmentFile())) {
@@ -83,9 +96,17 @@ private static void handleTimeout(HttpClientCommandLineParameters parameters,
     }
   }
 
+  /**
+   * Provides an executor.
+   * 

+ * If the timeout parameter is greater than 0 then a watchdog will be added to an executor. + * + * @param timeout The timeout for the process in milliseconds. + * @return the configured executor + */ @Bean @ConditionalOnMissingBean - Executor executor(@Value("${ijhttp.timeout:0}") int timeout) { + Executor executor(@Value("${ijhttp.timeout:-1}") int timeout) { var executor = new DefaultExecutor(); if (timeout > 0) { @@ -98,6 +119,12 @@ Executor executor(@Value("${ijhttp.timeout:0}") int timeout) { return executor; } + /** + * The builder-style component to prepare command line. + * + * @param parameters Command line parameters from Spring Boot properties. + * @return the command line component. + */ @Bean HttpClientCommandLine httpClientCommandLine(HttpClientCommandLineParameters parameters) { logger.debug("HTTP Client parameters {}", parameters); @@ -113,13 +140,4 @@ HttpClientCommandLine httpClientCommandLine(HttpClientCommandLineParameters para return httpClientCommandLine; } - private void copyBooleanParametersAndLogLevelAndExecutable( - HttpClientCommandLineParameters parameters, HttpClientCommandLine httpClientCommandLine) { - httpClientCommandLine.dockerMode(parameters.isDockerMode()); - httpClientCommandLine.executable(parameters.getExecutable()); - httpClientCommandLine.insecure(parameters.isInsecure()); - httpClientCommandLine.logLevel(parameters.getLogLevel()); - httpClientCommandLine.report(parameters.isReport()); - } - } \ No newline at end of file diff --git a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineParameters.java b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineParameters.java index 5a8ebb3..692aa36 100644 --- a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineParameters.java +++ b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/HttpClientCommandLineParameters.java @@ -21,29 +21,86 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import uk.bot_by.ijhttp_tools.command_line.LogLevel; +/** + * HTTP Client parameters. + * + * @see HTTP Client CLI + */ @ConfigurationProperties(prefix = "ijhttp.parameters") public class HttpClientCommandLineParameters { + /** + * Number of milliseconds for connection. Defaults to 3000. + */ private Integer connectTimeout; + /** + * Enables Docker mode. Treat localhost as host.docker.internal. Defaults to + * false. + */ private boolean dockerMode; + /** + * Name of the public environment file, e.g. http-client.env.json. + */ private File environmentFile; + /** + * Public environment variables. + */ private List environmentVariables; + /** + * Name of the environment in a configuration file. + */ private String environmentName; + /** + * The executable. Can be a full path or the name of the executable. Defaults to + * ijhttp. + */ private String executable = "ijhttp"; + /** + * HTTP file paths. They are required. + */ private List files; + /** + * Allow insecure SSL connection. Defaults to false. + */ private boolean insecure; + /** + * Logging level: BASIC, HEADERS, VERBOSE. Defaults to BASIC. + */ private LogLevel logLevel = LogLevel.BASIC; + /** + * Name of the private environment file, e.g. http-client.private.env.json. + */ private File privateEnvironmentFile; + /** + * Private environment variables. + */ private List privateEnvironmentVariables; + /** + * Proxy URI. + *

+ * Proxy setting in format scheme://login:password@host:port, scheme can be + * socks for SOCKS or http for HTTP. + */ private String proxy; + /** + * Creates report about execution in JUnit XML Format. Defaults to false. + */ private boolean report; + /** + * Path to a report folder. Default value reports in the current directory. + */ private File reportPath; + /** + * Number of milliseconds for socket read. Defaults to 10000. + */ private Integer socketTimeout; public Integer getConnectTimeout() { return connectTimeout; } - + /** + * Number of milliseconds for connection. Defaults to 3000. + */ public void setConnectTimeout(Integer connectTimeout) { this.connectTimeout = connectTimeout; } @@ -51,7 +108,10 @@ public void setConnectTimeout(Integer connectTimeout) { public boolean isDockerMode() { return dockerMode; } - + /** + * Enables Docker mode. Treat localhost as host.docker.internal. Defaults to + * false. + */ public void setDockerMode(boolean dockerMode) { this.dockerMode = dockerMode; } @@ -59,7 +119,9 @@ public void setDockerMode(boolean dockerMode) { public File getEnvironmentFile() { return environmentFile; } - + /** + * Name of the public environment file. + */ public void setEnvironmentFile(File environmentFile) { this.environmentFile = environmentFile; } @@ -67,7 +129,9 @@ public void setEnvironmentFile(File environmentFile) { public List getEnvironmentVariables() { return environmentVariables; } - + /** + * Public environment variables. + */ public void setEnvironmentVariables(List environmentVariables) { this.environmentVariables = environmentVariables; } @@ -75,7 +139,9 @@ public void setEnvironmentVariables(List environmentVariables) { public String getEnvironmentName() { return environmentName; } - + /** + * Name of the environment in a configuration file. + */ public void setEnvironmentName(String environmentName) { this.environmentName = environmentName; } @@ -83,7 +149,10 @@ public void setEnvironmentName(String environmentName) { public String getExecutable() { return executable; } - + /** + * The executable. Can be a full path or the name of the executable. Defaults to + * ijhttp. + */ public void setExecutable(String executable) { this.executable = executable; } @@ -91,7 +160,9 @@ public void setExecutable(String executable) { public List getFiles() { return files; } - + /** + * HTTP file paths. They are required. + */ public void setFiles(List files) { this.files = files; } @@ -99,7 +170,9 @@ public void setFiles(List files) { public boolean isInsecure() { return insecure; } - + /** + * Allow insecure SSL connection. Defaults to false. + */ public void setInsecure(boolean insecure) { this.insecure = insecure; } @@ -107,7 +180,9 @@ public void setInsecure(boolean insecure) { public LogLevel getLogLevel() { return logLevel; } - + /** + * Logging level: BASIC, HEADERS, VERBOSE. Defaults to BASIC. + */ public void setLogLevel(LogLevel logLevel) { this.logLevel = logLevel; } @@ -115,7 +190,9 @@ public void setLogLevel(LogLevel logLevel) { public File getPrivateEnvironmentFile() { return privateEnvironmentFile; } - + /** + * Name of the private environment file. + */ public void setPrivateEnvironmentFile(File privateEnvironmentFile) { this.privateEnvironmentFile = privateEnvironmentFile; } @@ -123,7 +200,9 @@ public void setPrivateEnvironmentFile(File privateEnvironmentFile) { public List getPrivateEnvironmentVariables() { return privateEnvironmentVariables; } - + /** + * Private environment variables. + */ public void setPrivateEnvironmentVariables(List privateEnvironmentVariables) { this.privateEnvironmentVariables = privateEnvironmentVariables; } @@ -131,7 +210,12 @@ public void setPrivateEnvironmentVariables(List privateEnvironmentVariab public String getProxy() { return proxy; } - + /** + * Proxy URI. + *

+ * Proxy setting in format scheme://login:password@host:port, scheme can be + * socks for SOCKS or http for HTTP. + */ public void setProxy(String proxy) { this.proxy = proxy; } @@ -139,7 +223,9 @@ public void setProxy(String proxy) { public boolean isReport() { return report; } - + /** + * Creates report about execution in JUnit XML Format. Defaults to false. + */ public void setReport(boolean report) { this.report = report; } @@ -147,7 +233,9 @@ public void setReport(boolean report) { public File getReportPath() { return reportPath; } - + /** + * Path to a report folder. Default value reports in the current directory. + */ public void setReportPath(File reportPath) { this.reportPath = reportPath; } @@ -155,7 +243,9 @@ public void setReportPath(File reportPath) { public Integer getSocketTimeout() { return socketTimeout; } - + /** + * Number of milliseconds for socket read. Defaults to 10000. + */ public void setSocketTimeout(Integer socketTimeout) { this.socketTimeout = socketTimeout; } diff --git a/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/package-info.java b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/package-info.java new file mode 100644 index 0000000..c12cda9 --- /dev/null +++ b/spring-boot-test/src/main/java/uk/bot_by/ijhttp_tools/spring_boot_test/package-info.java @@ -0,0 +1,15 @@ +/** + * HTTP Client autoconfiguration. + * + *

+ *
{@link uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigureHttpClientCommandLine}
+ *
Spring Boot Test autoconfiguration annotation.
+ *
{@link uk.bot_by.ijhttp_tools.spring_boot_test.HttpClientCommandLineConfiguration}
+ *
HTTP Client configuration provides + * {@linkplain org.apache.commons.exec.Executor executor} and + * {@linkplain uk.bot_by.ijhttp_tools.command_line.HttpClientCommandLine command line} beans.
+ *
{@link uk.bot_by.ijhttp_tools.spring_boot_test.HttpClientCommandLineParameters}
+ *
HTTP Client parameters from Spring Boot properties.
+ *
+ */ +package uk.bot_by.ijhttp_tools.spring_boot_test; \ No newline at end of file diff --git a/spring-boot-test/src/main/javadoc/overview.html b/spring-boot-test/src/main/javadoc/overview.html new file mode 100644 index 0000000..fa88cce --- /dev/null +++ b/spring-boot-test/src/main/javadoc/overview.html @@ -0,0 +1,33 @@ + + + + + ijhttp tools, spring boot test + + +

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. +

+

The autoconfiguration allows to run HTTP requests on the integration-test + phase using the IntelliJ HTTP Client.

+

The HTTP Request in Editor + Specification describes format these files.

+

Example requests:

+

+  GET https://example.com/api/get
+
+  ### Add an item
+  POST https://example.com/api/add
+  Content-Type: application/json
+
+  {
+    "name": "entity",
+    "value": "content"
+  }
+
+ + diff --git a/spring-boot-test/src/main/javadoc/resources/ijhttp.css b/spring-boot-test/src/main/javadoc/resources/ijhttp.css new file mode 100644 index 0000000..6ae99c4 --- /dev/null +++ b/spring-boot-test/src/main/javadoc/resources/ijhttp.css @@ -0,0 +1,27 @@ +.tooltip { + border-bottom: 1px dotted #4d7a97; + display: inline-block; + position: relative; +} + +.tooltip .tooltiptext { + background-color: #f8981d; + border: 1px dotted #4d7a97; + -moz-border-radius: 6px; + -ms-border-radius: 6px; + -webkit-border-radius: 6px; + border-radius: 6px; + color: #253441; + left: 113%; + padding: 5px 3px; + position: absolute; + text-align: center; + top: -5px; + visibility: hidden; + width: 97px; + z-index: 1; +} + +.tooltip:hover .tooltiptext { + visibility: visible; +} diff --git a/spring-boot-test/src/main/javadoc/resources/prism.css b/spring-boot-test/src/main/javadoc/resources/prism.css new file mode 100644 index 0000000..6f16854 --- /dev/null +++ b/spring-boot-test/src/main/javadoc/resources/prism.css @@ -0,0 +1,3 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+http+json */ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} diff --git a/spring-boot-test/src/main/javadoc/resources/prism.js b/spring-boot-test/src/main/javadoc/resources/prism.js new file mode 100644 index 0000000..1101f43 --- /dev/null +++ b/spring-boot-test/src/main/javadoc/resources/prism.js @@ -0,0 +1,6 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism&languages=markup+http+json */ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=g.reach);A+=w.value.length,w=w.next){var E=w.value;if(n.length>e.length)return;if(!(E instanceof i)){var P,L=1;if(y){if(!(P=l(b,A,e,m))||P.index>=e.length)break;var S=P.index,O=P.index+P[0].length,j=A;for(j+=w.value.length;S>=j;)j+=(w=w.next).value.length;if(A=j-=w.value.length,w.value instanceof i)continue;for(var C=w;C!==n.tail&&(jg.reach&&(g.reach=W);var z=w.prev;if(_&&(z=u(n,z,_),A+=_.length),c(n,z,L),w=u(n,z,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),L>1){var I={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,I),g&&I.reach>g.reach&&(g.reach=I.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a"+i.content+""},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); +Prism.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^$/i;var t={"included-cdata":{pattern://i,inside:s}};t["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var n={};n[a]={pattern:RegExp("(<__[^>]*>)(?:))*\\]\\]>|(?!)".replace(/__/g,(function(){return a})),"i"),lookbehind:!0,greedy:!0,inside:t},Prism.languages.insertBefore("markup","cdata",n)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(a,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+a+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml; +!function(t){function a(t){return RegExp("(^(?:"+t+"):[ \t]*(?![ \t]))[^]+","i")}t.languages.http={"request-line":{pattern:/^(?:CONNECT|DELETE|GET|HEAD|OPTIONS|PATCH|POST|PRI|PUT|SEARCH|TRACE)\s(?:https?:\/\/|\/)\S*\sHTTP\/[\d.]+/m,inside:{method:{pattern:/^[A-Z]+\b/,alias:"property"},"request-target":{pattern:/^(\s)(?:https?:\/\/|\/)\S*(?=\s)/,lookbehind:!0,alias:"url",inside:t.languages.uri},"http-version":{pattern:/^(\s)HTTP\/[\d.]+/,lookbehind:!0,alias:"property"}}},"response-status":{pattern:/^HTTP\/[\d.]+ \d+ .+/m,inside:{"http-version":{pattern:/^HTTP\/[\d.]+/,alias:"property"},"status-code":{pattern:/^(\s)\d+(?=\s)/,lookbehind:!0,alias:"number"},"reason-phrase":{pattern:/^(\s).+/,lookbehind:!0,alias:"string"}}},header:{pattern:/^[\w-]+:.+(?:(?:\r\n?|\n)[ \t].+)*/m,inside:{"header-value":[{pattern:a("Content-Security-Policy"),lookbehind:!0,alias:["csp","languages-csp"],inside:t.languages.csp},{pattern:a("Public-Key-Pins(?:-Report-Only)?"),lookbehind:!0,alias:["hpkp","languages-hpkp"],inside:t.languages.hpkp},{pattern:a("Strict-Transport-Security"),lookbehind:!0,alias:["hsts","languages-hsts"],inside:t.languages.hsts},{pattern:a("[^:]+"),lookbehind:!0}],"header-name":{pattern:/^[^:]+/,alias:"keyword"},punctuation:/^:/}}};var e,n=t.languages,s={"application/javascript":n.javascript,"application/json":n.json||n.javascript,"application/xml":n.xml,"text/xml":n.xml,"text/html":n.html,"text/css":n.css,"text/plain":n.plain},i={"application/json":!0,"application/xml":!0};function r(t){var a=t.replace(/^[a-z]+\//,"");return"(?:"+t+"|\\w+/(?:[\\w.-]+\\+)+"+a+"(?![+\\w.-]))"}for(var p in s)if(s[p]){e=e||{};var l=i[p]?r(p):p;e[p.replace(/\//g,"-")]={pattern:RegExp("(content-type:\\s*"+l+"(?:(?:\r\n?|\n)[\\w-].*)*(?:\r(?:\n|(?!\n))|\n))[^ \t\\w-][^]*","i"),lookbehind:!0,inside:s[p]}}e&&t.languages.insertBefore("http","header",e)}(Prism); +Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json; diff --git a/spring-boot-test/src/main/resources/META-INF/spring/uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigurationHttpClientCommandLine.imports b/spring-boot-test/src/main/resources/META-INF/spring/uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigureHttpClientCommandLine.imports similarity index 100% rename from spring-boot-test/src/main/resources/META-INF/spring/uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigurationHttpClientCommandLine.imports rename to spring-boot-test/src/main/resources/META-INF/spring/uk.bot_by.ijhttp_tools.spring_boot_test.AutoConfigureHttpClientCommandLine.imports diff --git a/src/site/markdown/autoconfiguration.md b/src/site/markdown/autoconfiguration.md new file mode 100644 index 0000000..f37df99 --- /dev/null +++ b/src/site/markdown/autoconfiguration.md @@ -0,0 +1,83 @@ +# Srping Boot Test autoconfiguration + +**Important!** The autoconfiguration does 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 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) + +The parameters equal to arguments of `ijhttp`. Run `ijhttp --help` to learn them. + +- **connect-timeout** - Number of milliseconds for connection. Defaults to _3000_. +- **docker-mode** - Enables Docker mode. Treat `localhost` as `host.docker.internal`. Defaults to _false_. +- **environment-file** - Name of the public environment file, e.g. `http-client.env.json`. +- **environment-name** - Name of the environment in a configuration file. +- **environment-variables** - Public environment variables. +- **executable** - The executable. Can be a full path or the name of the executable. Defaults to _ijhttp_. +- **files** - HTTP file paths. They are required. +- **insecure** - Allow insecure SSL connection. Defaults to _false_. +- **log-level** - Logging level: `BASIC`, `HEADERS`, `VERBOSE`. Defaults to _BASIC_. +- **private-environment-file** - Name of the private environment file, + e.g. `http-client.private.env.json`. +- **private-environment-variables** - Private environment variables. +- **proxy** - Proxy URI. Proxy setting in format `scheme://login:password@host:port`, + _scheme_ can be _socks_ for SOCKS or _http_ for HTTP. +- **report** - Creates report about execution in JUnit XML Format. Puts it in folder `reports` + in the current directory. Defaults to _false_. +- **report-path** - Path to a report folder. Default value {@code reports } in the current directory. +- **socket-timeout** - Number of milliseconds for socket read. Defaults to _10000_. +- **timeout** - Number of milliseconds for execution. + +## Example of configuration + +```yaml +ijhttp: + # timeout: 7000 same as annotation's property 'timeout' + parameters: + connect-timeout: 9000 + # docker-mode: false default value + environment-file: public-env.json + environment-name: dev + environment-variables: + - id=1234 + - field=name + # 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 +``` + +```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); + } + +} +``` + +[demo]: https://gitlab.com/vitalijr2/ijhttp-demo \ No newline at end of file diff --git a/src/site/markdown/changelog.md b/src/site/markdown/changelog.md index 9578957..22d86b6 100644 --- a/src/site/markdown/changelog.md +++ b/src/site/markdown/changelog.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - The proxy feature +- The report path +- Split Maven plugin and CLI builder modules +- The Spring Boot Test autoconfiguration ## 1.0.1 - 2023-11-08 ### Fixed diff --git a/src/site/markdown/contributing.md b/src/site/markdown/contributing.md index 59a4121..75b2a9b 100644 --- a/src/site/markdown/contributing.md +++ b/src/site/markdown/contributing.md @@ -1,19 +1,19 @@ -# Contributing to IntelliJ HTTP Client Maven Plugin +# Contributing to HTTP Client Maven Plugin -**IntelliJ HTTP Client Maven Plugin** is an open-source project and all contributions are welcome +**HTTP Client Maven Plugin** is an open-source project and all contributions are welcome to assist with its development and maintenance. ## Issues (bug and feature tracker) Please report any bugs found, feature requests or other issues on -**IntelliJ HTTP Client Maven Plugin** [GitLab tracker][gitlab-issues] +**HTTP Client Maven Plugin** [GitLab tracker][gitlab-issues] or [GitHub tracker][github-issues]. When creating a new issue, try following [necolas's guidelines][issue-guidelines]. ## Fork, patch and contribute code -Feel free to fork **IntelliJ HTTP Client Maven Plugin**'s repository at [GitLab][bot-gitlab] +Feel free to fork **HTTP Client Maven Plugin**'s repository at [GitLab][bot-gitlab] or [GitHub][bot-github] for your own use and updates. Contribute your fixes and new features back to the main codebase using diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 135b7b0..63b1bc3 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -1,18 +1,24 @@ -# IntelliJ HTTP Client, Maven Plugin +# ijhttp tools: Maven Plugin and Spring Boot Test autoconfiguration -A Maven Plugin to run HTTP requests through the [IntelliJ HTTP Client][http-client] on -the _integration-test_ phase. +I had started with Maven Plugin to run HTTP requests on the integration-test phase +using the [IntelliJ HTTP Client][http-client]. Later I added Spring Boot Test autoconfiguration, +thanks [@GoncaloPT][GoncaloPT] for [his idea][leverage-test]. -[![Codacy Grade](https://app.codacy.com/project/badge/Grade/73e1f8501ed84b0580dcf7ccee82c1e0)](https://app.codacy.com/gl/bot-by/ijhttp-maven-plugin/dashboard?utm_source=gl&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/73e1f8501ed84b0580dcf7ccee82c1e0)](https://app.codacy.com/gl/bot-by/ijhttp-maven-plugin/dashboard?utm_source=gl&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Codacy Coverage](https://app.codacy.com/project/badge/Coverage/73e1f8501ed84b0580dcf7ccee82c1e0)](https://app.codacy.com/gl/bot-by/ijhttp-maven-plugin/dashboard?utm_source=gl&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) ## Getting started -Originally the HTTP Client plugin allows to create, edit, and execute HTTP requests directly in the -IntelliJ IDEA code editor. The HTTP Client is also [available as a CLI tool][cli-tool]. +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 plugin allows to run HTTP requests through the IntelliJ HTTP Client on -the _integration-test_ phase. The [HTTP Request in Editor Specification][specification] +The plugin allows to run HTTP requests on the integration-test phase +using the IntelliJ HTTP Client. The 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: @@ -30,15 +36,19 @@ Content-Type: application/json } ``` -* [Usage][] -* [Configuration][] +* [Maven Plugin][maven-plugin] +* [Spring Boot Test autoconfiguration][autoconfiguration] [http-client]: https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html +[GoncaloPT]: https://github.com/GoncaloPT "Gonçalo Silva" + +[leverage-test]: https://github.com/bot-by/ijhttp-maven-plugin/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 -[Usage]: usage.html +[maven-plugin]: maven-plugin.html -[Configuration]: configuration.html +[autoconfiguration]: autoconfiguration.html diff --git a/src/site/markdown/configuration.md b/src/site/markdown/maven-plugin.md similarity index 58% rename from src/site/markdown/configuration.md rename to src/site/markdown/maven-plugin.md index ac36226..fe1945d 100644 --- a/src/site/markdown/configuration.md +++ b/src/site/markdown/maven-plugin.md @@ -1,10 +1,23 @@ -# Configuration +# Maven Plugin + +**Important!** The plugin does 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 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 manage plugin's output use `useMavenLogger`, `quietLogs` and `outputFile`. + +## Parameters The parameters equal to arguments of `ijhttp`. Run `ijhttp --help` to learn them. - **connectTimeout** - Number of milliseconds for connection. Defaults to _3000_. - **dockerMode** - Enables Docker mode. Treat `localhost` as `host.docker.internal`. Defaults to _false_. - **environmentFile** - Name of the public environment file, e.g. `http-client.env.json`. +- **environmentName** - Name of the environment in a configuration file. - **environmentVariables** - Public environment variables. Example: ```language-xml @@ -15,7 +28,6 @@ The parameters equal to arguments of `ijhttp`. Run `ijhttp --help` to learn them ... ``` -- **environmentName** - Name of the environment in a configuration file. - **executable** - The executable. Can be a full path or the name of the executable. Defaults to _ijhttp_. - **files** - HTTP file paths. They are required. Example: @@ -39,6 +51,7 @@ The parameters equal to arguments of `ijhttp`. Run `ijhttp --help` to learn them output at `DEBUG` level instead of the default `INFO` level to the Maven logger. - **report** - Creates report about execution in JUnit XML Format. Puts it in folder `reports` in the current directory. Defaults to _false_. +- **reportPath** - Path to a report folder. Default value {@code reports } in the current directory. - **skip** - Skip the execution. Defaults to _false_. - **socketTimeout** - Number of milliseconds for socket read. Defaults to _10000_. - **timeout** - Number of milliseconds for execution. @@ -46,3 +59,34 @@ The parameters equal to arguments of `ijhttp`. Run `ijhttp --help` to learn them to the Maven logger as `INFO` and `ERROR` level logs, respectively. - **workingDirectory** - The working directory. This is optional: if not specified, the current directory will be used. + +## Example of configuration + +```language-xml + + uk.bot-by.ijhttp-tools + ijhttp-maven-plugin + + + + + public-env.json + dev + + sample-1-queries.http + sample-2-queries.http + + HEADERS + true + target + + + run + + simple-run-with-report + + + +``` + +[demo]: https://gitlab.com/vitalijr2/ijhttp-demo \ No newline at end of file diff --git a/src/site/markdown/usage.md b/src/site/markdown/usage.md deleted file mode 100644 index b9ad2af..0000000 --- a/src/site/markdown/usage.md +++ /dev/null @@ -1,45 +0,0 @@ -# Usage - -**Important!** The plugin does 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 [IntelliJ HTTP Client Demo][demo] has some examples how to download the HTTP client. - -[![Maven Central](https://img.shields.io/maven-central/v/uk.bot-by.maven-plugin/ijhttp-maven-plugin)](https://search.maven.org/artifact/uk.bot-by.maven-plugin/ijhttp-maven-plugin) -[![Javadoc](https://javadoc.io/badge2/uk.bot-by.maven-plugin/ijhttp-maven-plugin/javadoc.svg)](https://javadoc.io/doc/uk.bot-by.maven-plugin/ijhttp-maven-plugin) - -There is one goal **run**. Add the plugin to your POM, example of full configuration: - -```language-xml - - uk.bot-by.ijhttp-tools - ijhttp-maven-plugin - - - - - 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`. - -Further reading: [Configuration][]. - -[Configuration]: configuration.html - -[demo]: https://gitlab.com/vitalijr2/ijhttp-demo \ No newline at end of file diff --git a/src/site/site.xml b/src/site/site.xml index 75b1c59..a95d4d3 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -34,7 +34,7 @@ ]]> - +