Advertisement
Guest User

Untitled

a guest
Jan 5th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.37 KB | None | 0 0
  1. import static org.junit.jupiter.api.Assertions.assertEquals;
  2.  
  3. import org.junit.jupiter.api.DisplayName;
  4. import org.junit.jupiter.api.Test;
  5. import org.junit.jupiter.api.extension.ExtendWith;
  6. import org.mockito.invocation.InvocationOnMock;
  7. import org.mockito.stubbing.Answer;
  8.  
  9. import io.vertx.core.buffer.Buffer;
  10. import io.vertx.core.json.JsonObject;
  11. import io.vertx.core.logging.LoggerFactory;
  12. import io.vertx.ext.web.client.HttpRequest;
  13. import io.vertx.ext.web.client.WebClient;
  14. import io.vertx.ext.web.client.WebClientOptions;
  15. import io.vertx.junit5.VertxExtension;
  16. import io.vertx.core.Vertx;
  17. import io.vertx.core.logging.Logger;
  18. import io.vertx.core.logging.LoggerFactory;
  19.  
  20. @ExtendWith(VertxExtension.class)
  21. public class LoginCoreClientTest {
  22.  
  23. private LoginCoreClient client;
  24. private static io.vertx.core.logging.Logger logger = LoggerFactory.getLogger(LoginCoreClient.class);
  25.  
  26. @Test
  27. @DisplayName("Testing API response from client")
  28. public void test() {
  29. JsonObject request = new JsonObject().put("name", "Bob Smith").put("Address", "101 Broadway"));
  30.  
  31. Vertx vertx = Vertx.vertx();
  32. WebClient client = WebClient.create(vertx, new WebClientOptions()
  33. .setDefaultHost("localhost")
  34. .setDefaultPort(8080));
  35.  
  36. logger.info("Here!"); //this line gets printed
  37. client.post("/endpoint")
  38. .putHeader("content-type", "application/json")
  39. .sendJson(request, ar -> {
  40. if (ar.succeeded()) {
  41. logger.info("Now here"); //this line does NOT get printed
  42. logger.info("succeeded: " + ar.succeeded());
  43. logger.info("statusCode: " + ar.result().statusCode());
  44. logger.info("body: " + ar.result().body());
  45. logger.info("headers: " + ar.result().headers());
  46. } else
  47. {
  48. logger.info("Executed: " + ar.cause());
  49. }
  50. });
  51. }
  52. }
  53.  
  54. <?xml version="1.0" encoding="UTF-8"?>
  55. <project xmlns="http://maven.apache.org/POM/4.0.0"
  56. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  57. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  58.  
  59. <modelVersion>4.0.0</modelVersion>
  60. <groupId>com.company.MyProject</groupId>
  61. <artifactId>consumerprofile</artifactId>
  62. <version>1.0.0-SNAPSHOT</version>
  63. <packaging>jar</packaging>
  64. <name>consumerprofile</name>
  65. <description>Service to retrieve consumer profile</description>
  66.  
  67. <properties>
  68. <vertx.version>3.6.0</vertx.version>
  69. <vertx.verticle>com.company.MyProject.ConsumerProfileVerticle</vertx.verticle>
  70. <vertx-maven-plugin.version>1.0.13</vertx-maven-plugin.version>
  71. <maven.compiler.source>1.8</maven.compiler.source>
  72. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  73. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  74. <junit-jupiter.version>5.1.0</junit-jupiter.version>
  75. <assertj-core.version>3.8.0</assertj-core.version>
  76. <maven.compiler.target>1.8</maven.compiler.target>
  77. <!--maven.surefire.version>3.0.0-M2</maven.surefire.version -->
  78. <!-- Db properties -->
  79. <tag.version></tag.version>
  80. <rollbackto.version></rollbackto.version>
  81. <rollbackto.date></rollbackto.date>
  82. <changelog.file>database/changelog.xml</changelog.file>
  83. <sqloutput>tmp/tagout.txt</sqloutput>
  84. <db.url>jdbc:postgresql://localhost:5432/cudadb</db.url>
  85. <db.driver>org.postgresql.Driver</db.driver>
  86. <db.user></db.user>
  87. <db.password></db.password>
  88. <db.sql></db.sql>
  89. <db.onerror>continue</db.onerror>
  90. <postgresql.version>42.2.5</postgresql.version>
  91. </properties>
  92.  
  93. <dependencyManagement>
  94. <dependencies>
  95. <dependency>
  96. <groupId>io.vertx</groupId>
  97. <artifactId>vertx-dependencies</artifactId>
  98. <version>${vertx.version}</version>
  99. <type>pom</type>
  100. <scope>import</scope>
  101. </dependency>
  102. </dependencies>
  103. </dependencyManagement>
  104.  
  105. <dependencies>
  106. <dependency>
  107. <groupId>junit</groupId>
  108. <artifactId>junit</artifactId>
  109. <version>4.12</version>
  110. <scope>test</scope>
  111. </dependency>
  112. <dependency>
  113. <groupId>io.vertx</groupId>
  114. <artifactId>vertx-core</artifactId>
  115. </dependency>
  116. <dependency>
  117. <groupId>io.vertx</groupId>
  118. <artifactId>vertx-web</artifactId>
  119. </dependency>
  120. <dependency>
  121. <groupId>io.vertx</groupId>
  122. <artifactId>vertx-web-client</artifactId>
  123. </dependency>
  124. <dependency>
  125. <groupId>io.vertx</groupId>
  126. <artifactId>vertx-config</artifactId>
  127. </dependency>
  128. <dependency>
  129. <groupId>io.vertx</groupId>
  130. <artifactId>vertx-junit5</artifactId>
  131. <scope>test</scope>
  132. </dependency>
  133. <dependency>
  134. <groupId>org.junit.jupiter</groupId>
  135. <artifactId>junit-jupiter-api</artifactId>
  136. <version>${junit-jupiter.version}</version>
  137. <scope>test</scope>
  138. </dependency>
  139. <dependency>
  140. <groupId>org.junit.jupiter</groupId>
  141. <artifactId>junit-jupiter-engine</artifactId>
  142. <version>${junit-jupiter.version}</version>
  143. <scope>test</scope>
  144. </dependency>
  145. <dependency>
  146. <groupId>org.assertj</groupId>
  147. <artifactId>assertj-core</artifactId>
  148. <version>${assertj-core.version}</version>
  149. <scope>test</scope>
  150. </dependency>
  151. <dependency>
  152. <groupId>org.postgresql</groupId>
  153. <artifactId>postgresql</artifactId>
  154. <version>${postgresql.version}</version>
  155. </dependency>
  156. <dependency>
  157. <groupId>io.vertx</groupId>
  158. <artifactId>vertx-jdbc-client</artifactId>
  159. </dependency>
  160. <dependency>
  161. <groupId>io.vertx</groupId>
  162. <artifactId>vertx-sql-common</artifactId>
  163. </dependency>
  164. <dependency>
  165. <groupId>org.mockito</groupId>
  166. <artifactId>mockito-core</artifactId>
  167. <version>2.23.4</version>
  168. <scope>test</scope>
  169. </dependency>
  170. </dependencies>
  171.  
  172. <build>
  173. <plugins>
  174. <plugin>
  175. <groupId>io.fabric8</groupId>
  176. <artifactId>vertx-maven-plugin</artifactId>
  177. <version>${vertx-maven-plugin.version}</version>
  178. <executions>
  179. <execution>
  180. <goals>
  181. <goal>initialize</goal>
  182. <goal>package</goal>
  183. </goals>
  184. </execution>
  185. </executions>
  186. <configuration>
  187. <redeploy>true</redeploy>
  188. </configuration>
  189. </plugin>
  190. <!-- Liquibase plugin -->
  191. <plugin>
  192. <groupId>org.liquibase</groupId>
  193. <artifactId>liquibase-maven-plugin</artifactId>
  194. <version>3.6.2</version>
  195. <dependencies>
  196. <dependency>
  197. <groupId>org.postgresql</groupId>
  198. <artifactId>postgresql</artifactId>
  199. <version>${postgresql.version}</version>
  200. </dependency>
  201. </dependencies>
  202. <configuration>
  203. <changeLogFile>${changelog.file}</changeLogFile>
  204. <driver>${db.driver}</driver>
  205. <url>${db.url}</url>
  206. <username>${db.user}</username>
  207. <password>${db.password}</password>
  208. <tag>${tag.version}</tag>
  209. <rollbackTag>${rollbackto.version}</rollbackTag>
  210. <rollbackDate>${rollbackto.date}</rollbackDate>
  211. <goalPrefix>liquibase</goalPrefix>
  212. </configuration>
  213. <executions>
  214. <execution>
  215. <id>apply-db</id>
  216. <phase>update-sql</phase>
  217. <goals>
  218. <goal>update</goal>
  219. </goals>
  220. </execution>
  221. <execution>
  222. <id>apply-tag</id>
  223. <phase>tag-sql</phase>
  224. <goals>
  225. <goal>tag</goal>
  226. </goals>
  227. </execution>
  228. <execution>
  229. <id>rollback-db</id>
  230. <phase>rollback-sql</phase>
  231. <goals>
  232. <goal>rollback</goal>
  233. </goals>
  234. </execution>
  235. </executions>
  236. </plugin>
  237. <!-- posgtgresql plug in -->
  238. <plugin>
  239. <groupId>org.codehaus.mojo</groupId>
  240. <artifactId>sql-maven-plugin</artifactId>
  241. <version>1.5</version>
  242. <dependencies>
  243. <dependency>
  244. <groupId>org.postgresql</groupId>
  245. <artifactId>postgresql</artifactId>
  246. <version>42.2.5</version>
  247. </dependency>
  248. </dependencies>
  249. <configuration>
  250. <driver>${db.driver}</driver>
  251. <url>${db.url}</url>
  252. <username>${db.user}</username>
  253. <password>${db.password}</password>
  254. <sqlCommand>${db.sql}</sqlCommand>
  255. <goalPrefix>sql</goalPrefix>
  256. <printResultSet>true</printResultSet>
  257. <outputFile>${sqloutput}</outputFile>
  258. <onError>${db.onerror}</onError>
  259. </configuration>
  260. <executions>
  261. <execution>
  262. <id>fetch-db</id>
  263. <phase>fetch-tag</phase>
  264. <goals>
  265. <goal>execute</goal>
  266. </goals>
  267. </execution>
  268. </executions>
  269. </plugin>
  270. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId>
  271. <version>${maven.surefire.version}</version> </plugin >
  272. <plugin>
  273. <groupId>org.apache.maven.plugins</groupId>
  274. <artifactId>maven-surefire-plugin</artifactId>
  275. <version>2.19.1</version>
  276. <dependencies>
  277. <dependency>
  278. <groupId>org.junit.platform</groupId>
  279. <artifactId>junit-platform-surefire-provider</artifactId>
  280. <version>1.0.3</version>
  281. </dependency>
  282. <dependency>
  283. <groupId>org.junit.jupiter</groupId>
  284. <artifactId>junit-jupiter-engine</artifactId>
  285. <version>5.0.3</version>
  286. </dependency>
  287. </dependencies>
  288. </plugin>
  289. </plugins>
  290. <pluginManagement>
  291. <plugins>
  292. <!--This plugin's configuration is used to store Eclipse m2e settings
  293. only. It has no influence on the Maven build itself. -->
  294. <plugin>
  295. <groupId>org.eclipse.m2e</groupId>
  296. <artifactId>lifecycle-mapping</artifactId>
  297. <version>1.0.0</version>
  298. <configuration>
  299. <lifecycleMappingMetadata>
  300. <pluginExecutions>
  301. <pluginExecution>
  302. <pluginExecutionFilter>
  303. <groupId>io.fabric8</groupId>
  304. <artifactId>
  305. vertx-maven-plugin
  306. </artifactId>
  307. <versionRange>
  308. [1.0.13,)
  309. </versionRange>
  310. <goals>
  311. <goal>initialize</goal>
  312. </goals>
  313. </pluginExecutionFilter>
  314. <action>
  315. <ignore></ignore>
  316. </action>
  317. </pluginExecution>
  318. </pluginExecutions>
  319. </lifecycleMappingMetadata>
  320. </configuration>
  321. </plugin>
  322. </plugins>
  323. </pluginManagement>
  324. </build>
  325.  
  326. <profiles>
  327. <profile>
  328. <id>openshift</id>
  329. <build>
  330. <plugins>
  331. <!-- Fabric8 Maven Plugin -->
  332. <!-- Deploy to openshift or kubernetes: "mvn clean fabric8:deploy" -->
  333. <!-- Note: See src/main/fabric8/deployment.yml for deployment config -->
  334. <plugin>
  335. <groupId>io.fabric8</groupId>
  336. <artifactId>fabric8-maven-plugin</artifactId>
  337. <version>3.5.41</version>
  338. <executions>
  339. <execution>
  340. <id>fabric8</id>
  341. <goals>
  342. <goal>resource</goal>
  343. <goal>build</goal>
  344. </goals>
  345. </execution>
  346. </executions>
  347. </plugin>
  348. </plugins>
  349. </build>
  350. </profile>
  351. </profiles>
  352.  
  353. <!-- Deploy to Nexus -->
  354. <distributionManagement>
  355. <repository>
  356. <id>MyProjectreleases</id>
  357. <url>http://artifactory.company.local/artifactory/MyProjectReleases/</url>
  358. </repository>
  359. <snapshotRepository>
  360. <id>MyProjectsnapshots</id>
  361. <url>http://artifactory.company.local/artifactory/MyProjectSnapshots/</url>
  362. </snapshotRepository>
  363. </distributionManagement>
  364. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement