Java
-
Vert.x 3.1.0 Tutorial – 2 : Hello World TEST
Vert.x applicationはJUnitとvertx-unitでunitテストが可能なので 今回は前回のHello WorldのUnitテスト手順を投稿 本家の説明はこちら 前回の記事はこちら 今回のソースはこちら 1.依存関係追加 JUnitとvertx-unitテスト用の依存関係をpom.xmlに追加 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-unit</artifactId> <version>3.1.0</version> <scope>test</scope> </dependency> 追加後libraryを更新[Maven Project パネルより->Reimport all maven projectsを実施] 2.テストソース 以下ソースをsrc/test/java/tutorial/vertx/HelloVerticleTest.javaに生成 /** * Created by bhags on 15/11/08. */ package tutorial.vertx; import io.vertx.core.Vertx; import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; import io.vertx.core.logging.LoggerFactory; import io.vertx.core.logging.Logger; import org.junit.After; import org.junit.Before;…
-
Vert.x 3.1.0 Tutorial – 1 : Hello World
Vert.xの紹介は本家サイト(http://vertx.io/)に譲ってとりあえずHello Word! まず、今回のソースコードはこちら 0.開発環境 Mac OS X java 1.8 以上 IntelliJ 14. 1 : IntelliJでmaven新規プロジェクト作成 File ->New -> Project Mavenを選択しNext maven project 設定 GroupId : totorial.vertx ArtifactId : hello-verticle Version : 1.0-SNAPSHOT Project name / location name : hello-virticle location : すきなところへ 2 : pom.xml に依存関係を追加 以下の依存関係およびbuildをpom.xml のversionの下に追加 <dependencies> <dependency> <groupId>io.vertx</groupId> <artifactId>vertx-core</artifactId> <version>3.1.0</version> </dependency> </dependencies>…
-
Javaで画面キャプチャ
モニターサイズ取得 GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = env.getMaximumWindowBounds(); setBounds(rect); ` Robotを利用し画面キャプチャ 下記サイトより抜粋 http://d.hatena.ne.jp/hase5021/20130523/1369310250 /** * Robotによる画面キャプチャ * * @param path 出力先ファイルパス */ public static void alertCaptuer(String path) { // 取得する画面エリア Rectangle screenSize = new Rectangle(0, 0, 2560, 800); try { // java.awt.Robotの生成 Robot robot = new Robot(); // イメージを所定の場所に出力 ImageIO.write(robot.createScreenCapture(screenSize), “png”, new File(path)); }…