{"id":286579,"date":"2017-05-19T02:20:03","date_gmt":"2017-05-18T22:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=286579"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=286579","title":{"rendered":"BDD-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 JBehave \u0438 Docker"},"content":{"rendered":"<p>\u0426\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 BDD-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Docker \u0438 JBehave<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412\u0435\u0441\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d <a href=\"https:\/\/bitbucket.org\/andrei_punko\/testing-docker-image-with-jbehave\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>  <b>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/b><\/p>\n<p>  \u0421\u0442\u0430\u0432\u0438\u043c Docker, \u043d\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u2014 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 BIOS, \u0432 Windows \u2014 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: Hyper-V, \u0438 \u0430\u043f\u0434\u0435\u0439\u0442\u0438\u043c \u0435\u0435 \u0434\u043e \u0432\u0435\u0440\u0441\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0441\u0438\u0442 Docker.<\/p>\n<p>  <b>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/b><\/p>\n<p>  \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043c\u0443\u043b\u044c\u0442\u0438\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0435 maven-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438:  <\/p>\n<ul>\n<li>spring-boot-empty-project \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e spring-boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/li>\n<li>dockerization \u2014 \u043c\u043e\u0434\u0443\u043b\u044c, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 spring-boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Docker-\u043e\u0431\u0440\u0430\u0437<\/li>\n<li>jbehave-testing \u2014 \u043c\u043e\u0434\u0443\u043b\u044c BDD-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<p>  <b>\u0421\u0435\u0440\u0432\u0438\u0441<\/b><\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u044b\u0439 spring-boot \u0441\u0435\u0440\u0432\u0438\u0441, \u0441 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u043c, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u043c \u00abHello World!\u00bb \u0434\u043b\u044f \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"java\">@RestController public class Controller {      @RequestMapping(&quot;\/&quot;)     @ResponseBody     String home() {         return &quot;Hello World!&quot;;     } }<\/code><\/pre>\n<p>  <b>\u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432 Docker-\u043e\u0431\u0440\u0430\u0437<\/b><\/p>\n<p>  \u0422\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c docker-maven-plugin \u043e\u0442 Spotify \u0438 java:8u111-jre-alpine \u043e\u0431\u0440\u0430\u0437 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0430 \u043e\u0431\u0440\u0430\u0437\u0430 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0435\u043a\u0446\u0438\u044e entryPoint \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u0430:  <\/p>\n<pre><code class=\"xml\">&lt;!-- *** Build images *** --&gt; &lt;execution&gt;   &lt;id&gt;build-spring-boot-simple-app-image&lt;\/id&gt;   &lt;phase&gt;package&lt;\/phase&gt;   &lt;goals&gt; \t&lt;goal&gt;build&lt;\/goal&gt;   &lt;\/goals&gt;   &lt;configuration&gt; \t&lt;imageName&gt;jbehave-spring-boot-simple-app-image:${project.version}&lt;\/imageName&gt; \t&lt;baseImage&gt;java:8u111-jre-alpine&lt;\/baseImage&gt; \t&lt;!-- run application when container start --&gt; \t&lt;entryPoint&gt;[&quot;java&quot;, &quot;-jar&quot;, &quot;\/spring-boot-empty-project-${project.version}.jar&quot;]&lt;\/entryPoint&gt; \t&lt;!-- copy the service's jar file from target into the root directory of the image --&gt; \t&lt;resources&gt; \t  &lt;resource&gt; \t    &lt;targetPath&gt;\/&lt;\/targetPath&gt; \t    &lt;directory&gt;${project.build.directory}\/lib&lt;\/directory&gt; \t    &lt;include&gt;spring-boot-empty-project-${project.version}.jar&lt;\/include&gt; \t  &lt;\/resource&gt; \t&lt;\/resources&gt; &lt;\/configuration&gt; &lt;\/execution&gt; <\/code><\/pre>\n<p>  \u0412 \u0442\u043e\u0439 \u0436\u0435 \u0444\u0430\u0437\u0435 package \u0442\u0435\u0433\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437:  <\/p>\n<pre><code class=\"xml\">&lt;!-- *** Tag images *** --&gt; &lt;execution&gt;   &lt;id&gt;tag-spring-boot-simple-app-image&lt;\/id&gt;   &lt;phase&gt;package&lt;\/phase&gt;   &lt;goals&gt; \t&lt;goal&gt;tag&lt;\/goal&gt;   &lt;\/goals&gt;   &lt;configuration&gt;     &lt;image&gt;jbehave-spring-boot-simple-app-image:${project.version}&lt;\/image&gt;     &lt;newName&gt;${dockerRepository}\/jbehave-spring-boot-simple-app-image:${project.version}&lt;\/newName&gt;   &lt;\/configuration&gt; &lt;\/execution&gt; <\/code><\/pre>\n<p>  \u0412 \u0444\u0430\u0437\u0435 push \u043f\u0443\u0448\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439:  <\/p>\n<pre><code class=\"xml\">&lt;!-- *** Push images *** --&gt; &lt;execution&gt;   &lt;id&gt;push-spring-boot-simple-app-image&lt;\/id&gt;   &lt;phase&gt;deploy&lt;\/phase&gt;   &lt;goals&gt;     &lt;goal&gt;push&lt;\/goal&gt;   &lt;\/goals&gt;   &lt;configuration&gt;   &lt;imageName&gt;${dockerRepository}\/jbehave-spring-boot-simple-app-image:${project.version}&lt;\/imageName&gt;   &lt;\/configuration&gt; &lt;\/execution&gt; <\/code><\/pre>\n<p>  <b>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e BDD-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/b><\/p>\n<p>  \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432 story-\u0444\u0430\u0439\u043b\u0435:  <\/p>\n<pre><code class=\"xml\">Narrative: As a developer I want to get access to spring-boot application from outside of docker container  Scenario: After when Docker container with spring-boot app in it started, application home page is accessable  Then spring-boot application home page accessable <\/code><\/pre>\n<p>   \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u043c\u0430\u0448\u043d\u044f\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430, \u0447\u0435\u0433\u043e \u0436\u0435 \u0431\u043e\u043b\u0435\u0439<\/p>\n<p>  \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c story-\u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c java-\u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c GetAccessToSpringBootAppFromOutsideOfDockerContainer:  <\/p>\n<pre><code class=\"java\">public class GetAccessToSpringBootAppFromOutsideOfDockerContainer extends JUnitStory {      \/\/ Here we specify the configuration, starting from default MostUsefulConfiguration, and changing only what is needed     @Override     public Configuration configuration() {         return new MostUsefulConfiguration()                 \/\/ where to find the stories                 .useStoryLoader(new LoadFromClasspath(this.getClass()))                 \/\/ CONSOLE and TXT reporting                 .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT));     }      \/\/ Here we specify the steps classes     @Override     public InjectableStepsFactory stepsFactory() {         \/\/ varargs, can have more that one steps classes         return new InstanceStepsFactory(configuration(), new CheckSpringBootAppHomePageAvailabilitySteps());     } }<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<pre><code class=\"java\">public class GetAccessToSpringBootAppFromOutsideOfDockerContainer extends JUnitStory {      \/\/ Here we specify the configuration, starting from default MostUsefulConfiguration, and changing only what is needed     @Override     public Configuration configuration() {         return new MostUsefulConfiguration()                 \/\/ where to find the stories                 .useStoryLoader(new LoadFromClasspath(this.getClass()))                 \/\/ CONSOLE and TXT reporting                 .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats() .withFormats(Format.CONSOLE, Format.TXT));     }      \/\/ Here we specify the steps classes     @Override     public InjectableStepsFactory stepsFactory() {         \/\/ varargs, can have more that one steps classes         return new InstanceStepsFactory(configuration(), new CheckSpringBootAppHomePageAvailabilitySteps());     } }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Docker-\u043e\u0431\u0440\u0430\u0437 \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u2014 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0437 \u0432 \u0444\u0430\u0437\u0435 pre-integration-test \u0438 \u0441\u0442\u043e\u043f\u0430\u0435\u043c \u0432 \u0444\u0430\u0437\u0435 post-integration-test:  <\/p>\n<pre><code class=\"xml\">&lt;!-- Hooking into the lifecycle --&gt; &lt;executions&gt; \t&lt;execution&gt; \t\t&lt;id&gt;start&lt;\/id&gt; \t\t&lt;phase&gt;pre-integration-test&lt;\/phase&gt; \t\t&lt;goals&gt; \t\t\t&lt;goal&gt;start&lt;\/goal&gt; \t\t&lt;\/goals&gt; \t&lt;\/execution&gt; \t&lt;execution&gt; \t\t&lt;id&gt;stop&lt;\/id&gt; \t\t&lt;phase&gt;post-integration-test&lt;\/phase&gt; \t\t&lt;goals&gt; \t\t\t&lt;goal&gt;stop&lt;\/goal&gt; \t\t&lt;\/goals&gt; \t&lt;\/execution&gt; &lt;\/executions&gt; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0434\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u043f\u0440\u0435\u0444\u0438\u043a\u0441 TC \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 Docker-\u043e\u0431\u0440\u0430\u0437\u0430 \u0432 \u043b\u043e\u0433\u0430\u0445:  <\/p>\n<pre><code class=\"xml\">&lt;!-- ............................................................... --&gt; &lt;!-- Runtime configuration for starting\/stopping\/linking containers --&gt; &lt;!-- ............................................................... --&gt; &lt;run&gt;   &lt;!-- Assign dynamically mapped ports to maven variables (which can be reused in integration tests) --&gt;   &lt;ports&gt; \t&lt;port&gt;spring-boot-app.port:8090&lt;\/port&gt;   &lt;\/ports&gt; \t&lt;wait&gt; \t  &lt;!-- Check for this URL to return a 200 return code .... --&gt; \t  &lt;url&gt;                  http:\/\/${docker.host.address}:${spring-boot-app.port} \t  &lt;\/url&gt; \t  &lt;!-- ... but at max 10 seconds --&gt; \t  &lt;time&gt;10000&lt;\/time&gt; \t&lt;\/wait&gt; \t&lt;log&gt; \t  &lt;prefix&gt;TC&lt;\/prefix&gt; \t  &lt;color&gt;cyan&lt;\/color&gt; \t&lt;\/log&gt; &lt;\/run&gt; <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0431\u0438\u043b\u0434\u0430 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e:  <\/p>\n<pre><code class=\"xml\">Running story stories\/get_access_to_spring_boot_app_from_outside_of_docker_container.story  (stories\/get_access_to_spring_boot_app_from_outside_of_docker_container.story) Scenario: After when Docker container with spring-boot app in it started, application home page is accessable ... Results :  Tests run: 1, Failures: 0, Errors: 0, Skipped: 0<\/code><\/pre>\n<p>   \u2014 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0447\u0435\u0433\u043e \u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/329034\/\"> https:\/\/habrahabr.ru\/post\/329034\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0426\u0435\u043b\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 BDD-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Docker \u0438 JBehave  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-286579","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286579"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/286579\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}