text:
namespace cucumber
{
	partial class FormReaction
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormReaction));
            this.timer_to_green = new System.Windows.Forms.Timer(this.components);
            this.butt_exit = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.label_time = new System.Windows.Forms.Label();
            this.label_try = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            //
            // timer_to_green
            //
            this.timer_to_green.Interval = 10;
            this.timer_to_green.Tick += new System.EventHandler(this.timer1_Tick);
            //
            // butt_exit
            //
            this.butt_exit.BackColor = System.Drawing.Color.Transparent;
            this.butt_exit.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("butt_exit.BackgroundImage")));
            this.butt_exit.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
            this.butt_exit.Cursor = System.Windows.Forms.Cursors.Hand;
            this.butt_exit.FlatAppearance.BorderSize = 0;
            this.butt_exit.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
            this.butt_exit.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
            this.butt_exit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            this.butt_exit.Location = new System.Drawing.Point(559, 0);
            this.butt_exit.Name = "butt_exit";
            this.butt_exit.Size = new System.Drawing.Size(25, 25);
            this.butt_exit.TabIndex = 3;
            this.butt_exit.UseVisualStyleBackColor = false;
            this.butt_exit.Click += new System.EventHandler(this.butt_exit_Click);
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Showcard Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
            this.label1.Location = new System.Drawing.Point(196, 174);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(198, 30);
            this.label1.TabIndex = 4;
            this.label1.Text = "Click to start";
            this.label1.Click += new System.EventHandler(this.label1_Click);
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Showcard Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
            this.label2.Location = new System.Drawing.Point(30, 217);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(522, 20);
            this.label2.TabIndex = 5;
            this.label2.Text = "When the red box turns green, click as quickly as you can.";
            this.label2.Click += new System.EventHandler(this.label2_Click);
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Showcard Gothic", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.LightGray;
            this.label3.Location = new System.Drawing.Point(142, 363);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(80, 18);
            this.label3.TabIndex = 6;
            this.label3.Text = "Average |";
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("Showcard Gothic", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.LightGray;
            this.label4.Location = new System.Drawing.Point(325, 363);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(55, 18);
            this.label4.TabIndex = 7;
            this.label4.Text = "Tries |";
            //
            // pictureBox1
            //
            this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
            this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
            this.pictureBox1.Location = new System.Drawing.Point(250, 50);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(100, 100);
            this.pictureBox1.TabIndex = 8;
            this.pictureBox1.TabStop = false;
            this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
            //
            // label_time
            //
            this.label_time.AutoSize = true;
            this.label_time.Font = new System.Drawing.Font("Showcard Gothic", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label_time.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
            this.label_time.Location = new System.Drawing.Point(228, 363);
            this.label_time.Name = "label_time";
            this.label_time.Size = new System.Drawing.Size(38, 18);
            this.label_time.TabIndex = 9;
            this.label_time.Text = "0ms";
            //
            // label_try
            //
            this.label_try.AutoSize = true;
            this.label_try.Font = new System.Drawing.Font("Showcard Gothic", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label_try.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
            this.label_try.Location = new System.Drawing.Point(386, 363);
            this.label_try.Name = "label_try";
            this.label_try.Size = new System.Drawing.Size(50, 18);
            this.label_try.TabIndex = 10;
            this.label_try.Text = "0 of 5";
            //
            // FormReaction
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.DodgerBlue;
            this.ClientSize = new System.Drawing.Size(584, 411);
            this.Controls.Add(this.label_try);
            this.Controls.Add(this.label_time);
            this.Controls.Add(this.pictureBox1);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.butt_exit);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "FormReaction";
            this.Text = "FormReaction";
            this.Paint += new System.Windows.Forms.PaintEventHandler(this.FormReaction_Paint);
            this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.FormReaction_MouseClick);
            this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FormReaction_MouseMove);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}

		#endregion

		private System.Windows.Forms.Timer timer_to_green;
		private System.Windows.Forms.Button butt_exit;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Label label_time;
		private System.Windows.Forms.Label label_try;
	}
}


text:
<title>TestNG:  Command line test</title>
<link href="../testng.css" rel="stylesheet" type="text/css" />
<link href="../my-testng.css" rel="stylesheet" type="text/css" />

Command line test

Tests passed/Failed/Skipped:	128/2/0

Started on:	Mon Sep 01 22:19:05 IST 2014

Total time:	21 seconds (21052 ms)

Included groups:

Excluded groups:

(Hover the method name to see the test class name)

PASSED TESTS

Test method
Exception
Time (seconds)
Instance

testAsymmetricAlgorithm
Test class: org.security.crypt.asymmetric.AsymmetricAlgorithmTest
Parameters: RSA/NONE/OAEPPadding, java.security.KeyPair@b1712f3

0
org.security.crypt.asymmetric.AsymmetricAlgorithmTest@62043840

testAsymmetricAlgorithm
Test class: org.security.crypt.asymmetric.AsymmetricAlgorithmTest
Parameters: RSA/NONE/OAEPPadding, java.security.KeyPair@6986bbaf

0
org.security.crypt.asymmetric.AsymmetricAlgorithmTest@62043840

testAsymmetricCli
Test class: org.security.crypt.asymmetric.AsymmetricCliTest
Parameters: rsa, null, 1536

0
org.security.crypt.asymmetric.AsymmetricCliTest@5315b42e

testAsymmetricCli
Test class: org.security.crypt.asymmetric.AsymmetricCliTest
Parameters: RSA, base64, 2048

0
org.security.crypt.asymmetric.AsymmetricCliTest@5315b42e

testAsymmetricCli
Test class: org.security.crypt.asymmetric.AsymmetricCliTest
Parameters: RSA, hex, 3072

2
org.security.crypt.asymmetric.AsymmetricCliTest@5315b42e

testClone
Test class: org.security.crypt.asymmetric.AsymmetricAlgorithmTest
Parameters: RSA/NONE/OAEPPadding, java.security.KeyPair@4879dfad

0
org.security.crypt.asymmetric.AsymmetricAlgorithmTest@62043840

testConvert
Test class: org.security.crypt.util.ConverterTest
Parameters: org.security.crypt.util.Base64Converter@95e33cc

0
org.security.crypt.util.ConverterTest@6be46e8f

testConvert
Test class: org.security.crypt.util.ConverterTest
Parameters: org.security.crypt.util.HexConverter@1e44b638

0
org.security.crypt.util.ConverterTest@6be46e8f

testConvert
Test class: org.security.crypt.util.ConverterTest
Parameters: org.security.crypt.util.HexConverter@babafc2

0
org.security.crypt.util.ConverterTest@6be46e8f

testDecodeBase64
Test class: org.security.crypt.io.Base64FilterInputStreamTest
Parameters: 0

0
org.security.crypt.io.Base64FilterInputStreamTest@1e67b872

testDecodeBase64
Test class: org.security.crypt.io.Base64FilterInputStreamTest
Parameters: 64

0
org.security.crypt.io.Base64FilterInputStreamTest@1e67b872

testDecodeBase64
Test class: org.security.crypt.io.Base64FilterInputStreamTest
Parameters: 76

0
org.security.crypt.io.Base64FilterInputStreamTest@1e67b872

testDecodeHex
Test class: org.security.crypt.io.HexFilterInputStreamTest

0
org.security.crypt.io.HexFilterInputStreamTest@246ae04d

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD2, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD2, [B@4758820d

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD4, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD4, [B@74eb909f

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, [B@28ec166e

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD128, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD128, [B@2eee3069

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD160, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD160, [B@2da59753

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD256, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD256, [B@5629510

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD320, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: RIPEMD320, [B@4df5bcb4

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, [B@12c7a01b

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-256, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-256, [B@13d9b21f

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-384, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-384, [B@2826f61

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-512, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-512, [B@62727399

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: Tiger, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: Tiger, [B@4d9ac0b4

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: Whirlpool, null

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigest
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: Whirlpool, [B@130dca52

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg MD4, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg MD5 -encoding base64 -salt D3ADF00D, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg MD5 -encoding base64, jkdiaM9v/g6hNQSr5hnmgQ==

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg RIPEMD128 -encoding hex, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg RIPEMD160 -encoding hex, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg RIPEMD256 -encoding hex, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg RIPEMD320 -encoding hex, null

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA1 -encoding hex, fa46b18852c72fe87b8954b987b897074c211131

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA-1 -encoding base64, +kaxiFLHL+h7iVS5h7iXB0whETE=

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA256 -encoding hex, 949365318ff52c4d326ff3dd806cb29bd620e458c6987635f3ba0312868d2649

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA-256 -encoding base64, lJNlMY/1LE0yb/PdgGyym9Yg5FjGmHY187oDEoaNJkk=

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA384 -encoding hex, 3ed9a131a23adb1db8837d925a04f16044df637891baf9fa178daee1d9216a84231750e9d69a37ac462cdc7abf1cc032

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA-384 -encoding base64, PtmhMaI62x24g32SWgTxYETfY3iRuvn6F42u4dkhaoQjF1Dp1po3rEYs3Hq/HMAy

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA512 -encoding hex, 4d0b1e5dccd9e8998bf08a9d0ea8b7c139643ae5a5b937219eaa47dd8237b987b4dc947b2e9001b3a5f2887a62933d4e6d79865663e6e7e5bd140f4e6079f76f

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg SHA-512 -encoding base64, TQseXczZ6JmL8IqdDqi3wTlkOuWluTchnqpH3YI3uYe03JR7LpABs6XyiHpikz1ObXmGVmPm5+W9FA9OYHn3bw==

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg Tiger -encoding hex, ff140eab46ba272631f5b02e6de52aaec6b9a2b836a5dc13

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestCli
Test class: org.security.crypt.digest.DigestCliTest
Parameters: -alg Whirlpool -encoding hex, b7a85efb1e0dce3805f30c95bb5e4595d2602bf5adc8743d39a293f726d851f9fd31c59dfd7d2175018c5f4b38747d9131c2a825206aa6d29dbb5cc0be2f0581

0
org.security.crypt.digest.DigestCliTest@2d554825

testDigestConvert
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, org.security.crypt.util.HexConverter@2654635

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestConvert
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, org.security.crypt.util.Base64Converter@737a135b

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestConvert
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, org.security.crypt.util.HexConverter@687ef2e0

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestConvert
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, org.security.crypt.util.Base64Converter@15dcfae7

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestStream
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, org.security.crypt.util.HexConverter@d41f816

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestStream
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5, org.security.crypt.util.Base64Converter@7a55af6b

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestStream
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, org.security.crypt.util.HexConverter@558bdf1f

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testDigestStream
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1, org.security.crypt.util.Base64Converter@6c2c1385

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testEncodeBase64
Test class: org.security.crypt.io.Base64FilterOutputStreamTest
Parameters: 0

0
org.security.crypt.io.Base64FilterOutputStreamTest@77b52d12

testEncodeBase64
Test class: org.security.crypt.io.Base64FilterOutputStreamTest
Parameters: 64

0
org.security.crypt.io.Base64FilterOutputStreamTest@77b52d12

testEncodeBase64
Test class: org.security.crypt.io.Base64FilterOutputStreamTest
Parameters: 76

0
org.security.crypt.io.Base64FilterOutputStreamTest@77b52d12

testEncodeHex
Test class: org.security.crypt.io.HexFilterOutputStreamTest

0
org.security.crypt.io.HexFilterOutputStreamTest@6fb554cc

testFindEntityCertificate
Test class: org.security.crypt.x509.X509UtilsTest
Parameters: [Ljava.lang.String;@3da05287, entity-key.pem, entity-cert.pem

0
org.security.crypt.x509.X509UtilsTest@1324409e

testFindEntityCertificate
Test class: org.security.crypt.x509.X509UtilsTest
Parameters: [Ljava.lang.String;@1e636ea3, entity-key.pem, null

0
org.security.crypt.x509.X509UtilsTest@1324409e

testFormat
Test class: org.security.crypt.x509.LDAPv3DNFormatterTest
Parameters: src/test/resources/x509/serac-dev-test-cert.pem, C=US,DC=vt,DC=edu,O=Virginia Polytechnic Institute and State University,CN=Marvin S Addison,UID=1145718, SERIALNUMBER=12,CN=DEV Virginia Tech Class 1 Server CA,O=Virginia Polytechnic Institute and State University,C=US,DC=vt,DC=edu

0
org.security.crypt.x509.LDAPv3DNFormatterTest@5d624da6

testFormat
Test class: org.security.crypt.x509.LDAPv3DNFormatterTest
Parameters: src/test/resources/x509/glider.cc.vt.edu.crt, C=US,DC=edu,DC=vt,ST=Virginia,L=Blacksburg,O=Virginia Polytechnic Institute and State University,OU=Middleware-Client,OU=SETI,SERIALNUMBER=1248110657961,CN=glider.cc.vt.edu, CN=Virginia Tech Middleware CA,O=Virginia Polytechnic Institute and State University,C=US,DC=vt,DC=edu

0
org.security.crypt.x509.LDAPv3DNFormatterTest@5d624da6

testGetAttributeValue
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/serac-dev-test-cert.pem, DomainComponent, vt

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetAttributeValue
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/glider.cc.vt.edu.crt, CommonName, glider.cc.vt.edu

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetAttributeValue
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/thawte-premium-server-ca-cert.pem, EmailAddress, premium-server@thawte.com

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetAttributeValues
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/serac-dev-test-cert.pem, DomainComponent, [Ljava.lang.String;@115667d

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetAttributeValues
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/glider.cc.vt.edu.crt, SerialNumber, [Ljava.lang.String;@736caf7a

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetAttributeValues
Test class: org.security.crypt.x509.DNUtilsTest
Parameters: src/test/resources/x509/glider.cc.vt.edu.crt, OrganizationalUnitName, [Ljava.lang.String;@4ce7fffa

0
org.security.crypt.x509.DNUtilsTest@4cb2c100

testGetSubjectNames
Test class: org.security.crypt.x509.X509UtilsTest
Parameters: marvin.pem, [Lorg.security.crypt.x509.types.GeneralNameType;@497486b3, [Ljava.lang.String;@63f8276e

0
org.security.crypt.x509.X509UtilsTest@1324409e

testGetSubjectNames
Test class: org.security.crypt.x509.X509UtilsTest
Parameters: marvin.pem, [Lorg.security.crypt.x509.types.GeneralNameType;@75f95314, [Ljava.lang.String;@6127a7e

0
org.security.crypt.x509.X509UtilsTest@1324409e

testHashCalculationAgainstReference
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: MD5

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testHashCalculationAgainstReference
Test class: org.security.crypt.digest.DigestAlgorithmTest
Parameters: SHA-1

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testIsKeyPair
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: DSA Public Key
            y: 7f0c090670b312ced3a20c832c2ef4a30af8e0bc7a9f7290e9291e357b5a589a861f859638fa38f73b41a9b103587c89d22197d15ce46082937a66e54b9c637774eae2b0c2c0e3437a98f371cf47d980a624ab97a8e0f35aa8bdf950e11b46ed221b0e86b98828fd5dc9b6c5dcb8e9f60c0fd81806a123c102c44fa4bf799acf
, org.bouncycastle.jce.provider.JDKDSAPrivateKey@def73fdc, true

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testIsKeyPair
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: EC Public Key
            X: 5fdf94922b3e10c146e11ae94bc24d0a113c13a17c770013ed486f136b1d6bda
            Y: 8c2d263b778a509d2d32e73ee6bd82265d78708a52dc5cb38217edee366bbcd1
, EC Private Key
             S: f10dee56b75d656ebc79aa99db09ae369d5760a622eed1470c4ff44a85aee378
, true

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testIsKeyPair
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: RSA Public Key
            modulus: d49e8bd624bcb87b12b1e10f9fadc5bd2bfe43cb30a6f418f47b732f29a3924e1028ba4ec6b8be00c2540a1a164fa9680a419dc8500777431da5d829cf9a220d96fef46a92021cfda037f692a71fda588f5eba95dea850b09ac5fddc487c42d832a91a9345f681e9a5c57ac62a1b8202483ee7a0caf32b44aff2d0d305f1a74f
    public exponent: 10001
, RSA Private CRT Key
            modulus: d49e8bd624bcb87b12b1e10f9fadc5bd2bfe43cb30a6f418f47b732f29a3924e1028ba4ec6b8be00c2540a1a164fa9680a419dc8500777431da5d829cf9a220d96fef46a92021cfda037f692a71fda588f5eba95dea850b09ac5fddc487c42d832a91a9345f681e9a5c57ac62a1b8202483ee7a0caf32b44aff2d0d305f1a74f
    public exponent: 10001
   private exponent: 93f95fe302a061582e53a40a069c9f11204c0e8c9c68a55bb4d331fff1dfc8541204f65d1b0aba19b7255bfe79e6a9452256366491e61047a29ba88cb8d251bd94c0495584b31461db5e132a8d47de789a897bb54683689747da218f57b1c45000092860bc834f25c930ce15c9857a80b309a04071b5edd7005d851f2298afd9
             primeP: ecd3338eefa6fe8537b469f96069132a17b0a5614f6aabe972855631f43bebbba3c9e2b54a6cd0cc712a89be9f461e722c46e403988f9bc261b5fba79e4d09c5
             primeQ: e5d59ee41ed1c3d92d8ab3cf9f0e229d73de56dbb2c555d37c5e14757a8a595ba1a6adeb53141e8b433d634722de4d3d83ff7e83b898e511b10ea339678b0203
     primeExponentP: 613fd94c38dd3a673a18bbebcbcb5a334ec71b227a9a333e09e8f71c4c4ecede9ec3a87509bae5830e75895addcccd73d4fac767329ec6376c286ecec6129c9
     primeExponentQ: 8adf13bdc4bd7c780a6387984903f2786edd86600359e72cfd359f69089cf5b73f2a8665ed71f7aeaff734b873e21c8bb1e93bd97d3dad138e8748aad3dc935f
     crtCoefficient: 9296f653398a83b8088a53af5c70832caeba30cca9655b490f37057921f46a5fdddcf5b172c99e6365b3476d0425610be6ed382e1e461da1885ba96d992a5360
, true

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testIsKeyPair
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: DSA Public Key
            y: 7f0c090670b312ced3a20c832c2ef4a30af8e0bc7a9f7290e9291e357b5a589a861f859638fa38f73b41a9b103587c89d22197d15ce46082937a66e54b9c637774eae2b0c2c0e3437a98f371cf47d980a624ab97a8e0f35aa8bdf950e11b46ed221b0e86b98828fd5dc9b6c5dcb8e9f60c0fd81806a123c102c44fa4bf799acf
, RSA Private CRT Key
            modulus: d49e8bd624bcb87b12b1e10f9fadc5bd2bfe43cb30a6f418f47b732f29a3924e1028ba4ec6b8be00c2540a1a164fa9680a419dc8500777431da5d829cf9a220d96fef46a92021cfda037f692a71fda588f5eba95dea850b09ac5fddc487c42d832a91a9345f681e9a5c57ac62a1b8202483ee7a0caf32b44aff2d0d305f1a74f
    public exponent: 10001
   private exponent: 93f95fe302a061582e53a40a069c9f11204c0e8c9c68a55bb4d331fff1dfc8541204f65d1b0aba19b7255bfe79e6a9452256366491e61047a29ba88cb8d251bd94c0495584b31461db5e132a8d47de789a897bb54683689747da218f57b1c45000092860bc834f25c930ce15c9857a80b309a04071b5edd7005d851f2298afd9
             primeP: ecd3338eefa6fe8537b469f96069132a17b0a5614f6aabe972855631f43bebbba3c9e2b54a6cd0cc712a89be9f461e722c46e403988f9bc261b5fba79e4d09c5
             primeQ: e5d59ee41ed1c3d92d8ab3cf9f0e229d73de56dbb2c555d37c5e14757a8a595ba1a6adeb53141e8b433d634722de4d3d83ff7e83b898e511b10ea339678b0203
     primeExponentP: 613fd94c38dd3a673a18bbebcbcb5a334ec71b227a9a333e09e8f71c4c4ecede9ec3a87509bae5830e75895addcccd73d4fac767329ec6376c286ecec6129c9
     primeExponentQ: 8adf13bdc4bd7c780a6387984903f2786edd86600359e72cfd359f69089cf5b73f2a8665ed71f7aeaff734b873e21c8bb1e93bd97d3dad138e8748aad3dc935f
     crtCoefficient: 9296f653398a83b8088a53af5c70832caeba30cca9655b490f37057921f46a5fdddcf5b172c99e6365b3476d0425610be6ed382e1e461da1885ba96d992a5360
, false

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testIterator
Test class: org.security.crypt.x509.RDNSequenceIteratorTest
Parameters: src/test/resources/x509/serac-dev-test-cert.pem, [Lorg.security.crypt.x509.types.RelativeDistinguishedName;@6bbe2511

0
org.security.crypt.x509.RDNSequenceIteratorTest@614c5515

testLength
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: java.security.KeyPair@495fac5f, 1152, 1152

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testLength
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: java.security.KeyPair@76012793, 1024, 160

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testLength
Test class: org.security.crypt.asymmetric.PublicKeyUtilsTest
Parameters: java.security.KeyPair@635572a7, 384, 384

0
org.security.crypt.asymmetric.PublicKeyUtilsTest@68837a77

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@79d94571, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@4dd02341, org.security.crypt.util.Base64Converter@5d12a356

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@3212a8d7, org.security.crypt.util.HexConverter@66ac5762

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@7a1a3478, org.security.crypt.util.HexConverter@31bcf236

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@495b0487, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@55dfcc6, org.security.crypt.util.Base64Converter@517d4a0d

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@222eb8aa, org.security.crypt.util.HexConverter@3a12c404

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@93cf163, org.security.crypt.util.HexConverter@22d7b4f8

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@1852a3ff, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testRandomizedSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@7203c7ff, org.security.crypt.util.HexConverter@2c1156a7

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testReadAll
Test class: org.security.crypt.x509.ExtensionReaderTest
Parameters: src/test/resources/x509/marvin.pem, {AuthorityKeyIdentifier=B2:25:DC:8A:4D:E6:55:53:DC:D5:1A:65:11:D0:73:98:AF:9E:7F:07, ExtendedKeyUsage=[EmailProtection, ClientAuth, SmartCardLogin], KeyUsage=[DigitalSignature, NonRepudiation], BasicConstraints=CA:false, CRLDistributionPoints=[[http://balamood2.cc.vt.edu:8080/ejbca/publicweb/webdist/certdist?cmd=crl&issuer=CN=DEV Virginia Tech User CA,O=Virginia Polytechnic Institute and State University,DC=vt,DC=edu,C=US]], SubjectKeyIdentifier=FF:39:94:8A:03:97:04:D2:34:8E:79:0A:F9:5A:36:A2:EF:9B:FC:07, CertificatePolicies=[1.3.6.1.4.1.6760.5.2.2.2.1, 1.3.6.1.4.1.6760.5.2.2.1.1, 1.3.6.1.4.1.6760.5.2.2.4.1:[CPS:http://www.pki.vt.edu/vtc1sca/cps/], 1.3.6.1.4.1.6760.5.2.2.3.1], SubjectAlternativeName=[serac@vt.edu]}

0
org.security.crypt.x509.ExtensionReaderTest@2c6a3f77

testReadAll
Test class: org.security.crypt.x509.ExtensionReaderTest
Parameters: src/test/resources/x509/thawte-premium-server-ca-cert.pem, {BasicConstraints=CA:true}

0
org.security.crypt.x509.ExtensionReaderTest@2c6a3f77

testReadAll
Test class: org.security.crypt.x509.ExtensionReaderTest
Parameters: src/test/resources/x509/login.live.com-cert.pem, {AuthorityKeyIdentifier=FC:8A:50:BA:9E:B9:25:5A:7B:55:85:4F:95:00:63:8F:E9:58:6B:43, ExtendedKeyUsage=[ClientAuth, ServerAuth], KeyUsage=[DigitalSignature, KeyEncipherment], AuthorityInformationAccess=[OCSP:http://EVSecure-ocsp.verisign.com, CAIssuers:http://EVSecure-aia.verisign.com/EVSecure2006.cer], BasicConstraints=CA:false, CRLDistributionPoints=[[http://EVSecure-crl.verisign.com/EVSecure2006.crl]], SubjectKeyIdentifier=31:AE:F1:7C:98:67:E9:1F:19:69:A2:A7:84:1E:67:5C:AA:C3:6B:75, CertificatePolicies=[2.16.840.1.113733.1.7.23.6:[CPS:https://www.verisign.com/rpa]]}

0
org.security.crypt.x509.ExtensionReaderTest@2c6a3f77

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@25bfcafd, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@4b6690c0, org.security.crypt.util.Base64Converter@4f1bfe23

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@46268f08, org.security.crypt.util.HexConverter@512535ff

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@2a76840c, org.security.crypt.util.HexConverter@61a88b8c

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@71454b9d, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@eda25e5, org.security.crypt.util.Base64Converter@3f270e0a

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@7cf6a5f9, org.security.crypt.util.HexConverter@7241a47d

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@623e088f, org.security.crypt.util.HexConverter@77258e59

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@39fcbef6, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerify
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@66565121, org.security.crypt.util.HexConverter@7e3181aa

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@2fc6f97f, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@3d2ee678, org.security.crypt.util.Base64Converter@8dbfffb

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@6179e425, org.security.crypt.util.HexConverter@5dd1c9f2

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: DSA, java.security.KeyPair@35f26e72, org.security.crypt.util.HexConverter@6187d1f5

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@2d6764b2, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@67304a40, org.security.crypt.util.Base64Converter@63798ca7

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@49c6c24f, org.security.crypt.util.HexConverter@79c7532f

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: RSA, java.security.KeyPair@6fe1b4fb, org.security.crypt.util.HexConverter@e54303

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@79351f41, null

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testSignVerifyOnStream
Test class: org.security.crypt.signature.SignatureAlgorithmTest
Parameters: ECDSA, java.security.KeyPair@1c32386d, org.security.crypt.util.HexConverter@2df6226d

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

testToString
Test class: org.security.crypt.x509.types.AttributeTypeAndValueTest
Parameters: CN=Marvin S. Addison, CN=Marvin S. Addison

0
org.security.crypt.x509.types.AttributeTypeAndValueTest@2ef9b8bc

testToString
Test class: org.security.crypt.x509.types.AttributeTypeAndValueTest
Parameters: O=Sue\, Grabbit and Runn, O=Sue\, Grabbit and Runn

0
org.security.crypt.x509.types.AttributeTypeAndValueTest@2ef9b8bc

testToString
Test class: org.security.crypt.x509.types.AttributeTypeAndValueTest
Parameters: 3.1.4.1.5=\ Apple\, Cherry\, and Mixed Berry!\ , 3.1.4.1.5=\ Apple\, Cherry\, and Mixed Berry!\

0
org.security.crypt.x509.types.AttributeTypeAndValueTest@2ef9b8bc

testToString
Test class: org.security.crypt.x509.types.RelativeDistinguishedNameTest
Parameters: DC=vt, DC=vt

0
org.security.crypt.x509.types.RelativeDistinguishedNameTest@5f2050f6

testToString
Test class: org.security.crypt.x509.types.RelativeDistinguishedNameTest
Parameters: OU=Sales+CN=J. Smith, OU=Sales+CN=J. Smith

0
org.security.crypt.x509.types.RelativeDistinguishedNameTest@5f2050f6

SKIPPED TESTS

Test method
Exception
Time (seconds)
Instance

testClone
Test class: org.security.crypt.digest.DigestAlgorithmTest

java.lang.RuntimeException: java.lang.IllegalStateException: No random provider available.
Caused by: java.lang.IllegalStateException: No random provider available.
	at org.security.crypt.AbstractAlgorithm.getRandomData(AbstractAlgorithm.java:48)
	at org.security.crypt.digest.DigestAlgorithm.getRandomSalt(DigestAlgorithm.java:118)
	at org.security.crypt.digest.DigestAlgorithmTest.createTestDataForClone(DigestAlgorithmTest.java:133)
	... 30 more
... Removed 37 stack frames

Click to show all stack frames

java.lang.RuntimeException: java.lang.IllegalStateException: No random provider available.
	at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:161)
	at org.testng.internal.Parameters.handleParameters(Parameters.java:429)
	at org.testng.internal.Invoker.handleParameters(Invoker.java:1383)
	at org.testng.internal.Invoker.createParameters(Invoker.java:1075)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1180)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.IllegalStateException: No random provider available.
	at org.security.crypt.AbstractAlgorithm.getRandomData(AbstractAlgorithm.java:48)
	at org.security.crypt.digest.DigestAlgorithm.getRandomSalt(DigestAlgorithm.java:118)
	at org.security.crypt.digest.DigestAlgorithmTest.createTestDataForClone(DigestAlgorithmTest.java:133)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:135)
	... 30 more

0
org.security.crypt.digest.DigestAlgorithmTest@3f2a3a5

testClone
Test class: org.security.crypt.signature.SignatureAlgorithmTest

java.lang.RuntimeException: org.security.crypt.CryptException: Error generatig 512-bit EC key
Caused by: org.security.crypt.CryptException: Error generatig 512-bit EC key
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:149)
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:116)
	at org.security.crypt.signature.SignatureAlgorithmTest.createTestDataForClone(SignatureAlgorithmTest.java:84)
	... 30 more
Caused by: java.security.InvalidParameterException: unknown key size.
	at org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$EC.initialize(Unknown Source)
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:146)
	... 38 more
... Removed 37 stack frames

Click to show all stack frames

java.lang.RuntimeException: org.security.crypt.CryptException: Error generatig 512-bit EC key
	at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:161)
	at org.testng.internal.Parameters.handleParameters(Parameters.java:429)
	at org.testng.internal.Invoker.handleParameters(Invoker.java:1383)
	at org.testng.internal.Invoker.createParameters(Invoker.java:1075)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1180)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
	at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.security.crypt.CryptException: Error generatig 512-bit EC key
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:149)
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:116)
	at org.security.crypt.signature.SignatureAlgorithmTest.createTestDataForClone(SignatureAlgorithmTest.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:135)
	... 30 more
Caused by: java.security.InvalidParameterException: unknown key size.
	at org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$EC.initialize(Unknown Source)
	at org.security.crypt.asymmetric.PublicKeyUtils.generate(PublicKeyUtils.java:146)
	... 38 more

0
org.security.crypt.signature.SignatureAlgorithmTest@60addb54

redpajama_set_name: RedPajamaGithub


text:
/**
  Adapters included with Ember-Data.

  @module data
  @submodule data-adapters

  @main data-adapters
*/

require("ember-data/adapters/fixture_adapter");
require("ember-data/adapters/rest_adapter");


text:
package de.arthurkaul.archref.restcontroller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import de.arthurkaul.archref.exceptions.EntityNotFoundException;
import de.arthurkaul.archref.model.levelgraph.Level;
import de.arthurkaul.archref.model.levelgraph.LevelGraph;
import de.arthurkaul.archref.model.topology.TopologyTemplate;
import de.arthurkaul.archref.services.RefinementService;
import de.arthurkaul.archref.services.topology.TopologyTemplateService;

@RestController
public class RefinementController {

	@Autowired
	TopologyTemplateService topologyTemplateService;

	@Autowired
	RefinementService refinementService;

	/******************************************************************************************************************************************
	 *
	 * @method - refineTopologyTemplate - Refine a TopologyTemplate from the current abstraction level of the TopologyTemplate in the level graph to the lowest level of abstraction in the level graph
	 *
	 *
	 * @param long idTopologyTemplate - ID of TopologyTemplate which should be refined passed as path variable of the url of the request
	 * @param LevelGraph levelGraph - LevelGraph which should be used for refinement passed in the body
	 *
	 * @return TopologyTemplate - The TopologyTemplate which was refined with all refined child TopologyTemplates
	 *
	 *****************************************************************************************************************************************/
	@RequestMapping(value = "/api/refinement/refineTopologyTemplate/{id}/{smi}", method = RequestMethod.POST)
	public ResponseEntity<TopologyTemplate> refineTopologyTemplate(@PathVariable("id") long idTopologyTemplate, @PathVariable("smi") float smi, @RequestBody LevelGraph levelGraph) {

		TopologyTemplate topologyTemplate = topologyTemplateService.findById(idTopologyTemplate);

		if (topologyTemplate == null) {
			throw new EntityNotFoundException("No refinement could be processed because <TopologyTemplate> with id" + idTopologyTemplate + "was not found in the database.");
		}

		// Determine the depth of the LevelGraph. ATTENTION the depth is in this case not equal the number of different levels of the Graph because it may be a merged LevelGraph
		for (Level level : levelGraph.getLevels()) {
			if (level.getDepth() > levelGraph.getDepth()) {
				levelGraph.setDepth(level.getDepth());
			}
		}

		topologyTemplate = refinementService.initializeRefinement(levelGraph, topologyTemplate, levelGraph.getDepth(), smi);

		for (TopologyTemplate tempTopology : topologyTemplate.getChildTopologyTemplates()) {
			topologyTemplateService.update(tempTopology);
		}

		topologyTemplate = topologyTemplateService.update(topologyTemplate);

		return ResponseEntity.ok().body(topologyTemplate);
	}

	/**
	 *
	 * @method - refineOneStepTopologyTemplate -
	 *
	 * @param idTopologyTemplate
	 * @param smi
	 * @param levelGraph
	 * @return
	 */
	@RequestMapping(value = "/api/refinement/refineOneStepTopologyTemplate/{id}/{smi}", method = RequestMethod.POST)
	public ResponseEntity<TopologyTemplate> refineOneStepTopologyTemplate(@PathVariable("id") long idTopologyTemplate, @PathVariable("smi") float smi, @RequestBody LevelGraph levelGraph) {
		TopologyTemplate topologyTemplate = topologyTemplateService.findById(idTopologyTemplate);

		if (topologyTemplate == null) {
			throw new EntityNotFoundException("No refinement could be processed because <TopologyTemplate> with id" + idTopologyTemplate + "was not found in the database.");
		}

		// Determine the depth of the LevelGraph. ATTENTION the depth is in this case is not equal the number of different levels of the Graph because it is a merged LevelGraph
		for (Level level : levelGraph.getLevels()) {
			if (level.getDepth() > levelGraph.getDepth()) {
				levelGraph.setDepth(level.getDepth());
			}
		}

		topologyTemplate = refinementService.initializeRefinement(levelGraph, topologyTemplate, topologyTemplate.getAbstractionLevel() + 1, smi);

		topologyTemplate = topologyTemplateService.update(topologyTemplate);

		return ResponseEntity.ok().body(topologyTemplate);
	}

}


text:
+++
title = "Spring MVC Unit Testing - REST API"
description = "Spring MVC Unit Testing - REST API"
date = 2016-04-09T23:07:22+08:00
draft = false
[taxonomies]
categories =  ["Spring MVC Testing"]
tags = ["spring-mvc", "testing", "java"]
+++

本文是 [Spring MVC Testing](@/posts/2016-04-09-spring-mvc-testing-content.md) 单元测试系列的第3篇,原文链接:[Unit Testing of Spring MVC Controllers: REST API](http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-rest-api/)。

使用Spring MVC可以很方便第创建REST风格的接口,但是编写REST风格接口的单元测试并不是那么方便。幸运的是,Spring MVC Test极大地简化了我们为REST风格controller编写单元测试的工作。

本文将通过为`Todo`项的增删改查(CRUD)的REST风格接口操作编写单元测试的方式,一步一步地讲解如何使用Spring MVC Test来进行单元测试。OK,我们快点进入正文吧!

<!-- more -->

# 通过Maven获取依赖

本系列用到的依赖如下:

- Hamcrest 1.3 (hamcrest-all)
- Junit 4.11
- Mockito 1.9.5 (mockito-core)
- Spring Test 3.2.3.RELEASE
- JsonPath 0.8.1 (json-path and json-path-assert)

生成的pom.xml文件的片段如下:

```xml
<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>1.3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <artifactId>hamcrest-core</artifactId>
            <groupId>org.hamcrest</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.9.5</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>3.2.3.RELEASE</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <version>0.8.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path-assert</artifactId>
    <version>0.8.1</version>
    <scope>test</scope>
</dependency>
```

# 测试用例配置

同前一篇一样,我们使用`WebApplicationContext`方式来进行单元测试,这意味着我们需要按照之前介绍的配置方法配置上下文。由于之前对这部分内容已经有了详细的介绍,这里恕不赘述。

唯一需要注意的一点是,前面我们演示了使用`SimpleMappingExceptionResolver` bean来映射异常的处理方法,这在标准的controller里面很有用;但对于REST controller而言,异常需要使用`ResponseStatusExceptionResolver` bean来处理。更进一步,我们在工程中使用了`@ControllerAdvice`来创建自定义的异常映射处理类。下文我们会详细讲解该类,在此之前,我们先看看如何实现REST controller。

# 测试用例类

要针对REST接口编写单元测试,首先要准备一些基础知识:

- Spring MVC Test如何来进行单元测试,相关内容详见 [Spring MVC Unit Testing - Normal Controllers](@/posts/2016-04-09-spring-mvc-testing-unit-testing-normal-controllers.md)
- 如何对json结果作断言,我们选择的是 [JsonPath](https://github.com/jayway/JsonPath)

然后我们可以开始编写代码了。作为演示,我们将编写一下3种类型的REST接口的单元测试:

- 返回`Todo`项列表GET结果的接口
- 返回`TOdo`项GET结果的接口
- 返回`Todo`项POST结果的接口

## GET `Todo`项列表的接口

首先看一下该接口的实现代码。

### 预期的实现

预期的接口应该做以下几件事:

1. 接收到"/api/todo"上的GET请求,开始处理流程
2. 调用`TodoService`的`findAll()`方法获取到所有的`Todo`对象的列表
3. 将`Todo`列表转换为`TodoDTO`列表
4. 返回`TodoDTO`列表的json表示

`TodoController`类内的相关代码如下:

```java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
public class TodoController {

    private TodoService service;

    @RequestMapping(value = "/api/todo", method = RequestMethod.GET)
    @ResponseBody
    public List<TodoDTO> findAll() {
        List<Todo> models = service.findAll();
        return createDTOs(models);
    }

    private List<TodoDTO> createDTOs(List<Todo> models) {
        List<TodoDTO> dtos = new ArrayList<>();

        for (Todo model: models) {
            dtos.add(createDTO(model));
        }

        return dtos;
    }

    private TodoDTO createDTO(Todo model) {
        TodoDTO dto = new TodoDTO();

        dto.setId(model.getId());
        dto.setDescription(model.getDescription());
        dto.setTitle(model.getTitle());

        return dto;
    }
}
```

返回的json结果有可能是:

```json
[
    {
        "id":1,
        "description":"Lorem ipsum",
        "title":"Foo"
    },
    {
        "id":2,
        "description":"Lorem ipsum",
        "title":"Bar"
    }
]
```

接下来我们可以编写对应的测试用例了。

### 测试用例:`Todo`项列表GET请求

该测试用例主要工作如下:

1. 准备测试数据
2. 配置mock的`TodoService`实例在`findAll()`方法被调用的时候返回准备的数据
3. 执行一个'/api/todo'的GET请求
4. 对响应作断言:HTTP返回码是200
5. 对响应作断言:Content-type的值是"application/json",并且字符集是"UTF-8"
6. 对响应作断言:使用jsonpath对结果作验证
7. 检查请求执行过程中mock的`TodoService`实例执行了`findAll()`方法有且仅1次
8. 检查请求执行过程中mock的`TodoService`实例未执行其他方法

相关代码如下:

```java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;

import java.util.Arrays;

import static org.hamcrest.Matchers.*;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, WebAppContext.class})
@WebAppConfiguration
public class TodoControllerTest {

    private MockMvc mockMvc;

    @Autowired
    private TodoService todoServiceMock;

    //Add WebApplicationContext field here.

    //The setUp() method is omitted.

    @Test
    public void findAll_TodosFound_ShouldReturnFoundTodoEntries() throws Exception {
        Todo first = new TodoBuilder()
                .id(1L)
                .description("Lorem ipsum")
                .title("Foo")
                .build();
        Todo second = new TodoBuilder()
                .id(2L)
                .description("Lorem ipsum")
                .title("Bar")
                .build();

        when(todoServiceMock.findAll()).thenReturn(Arrays.asList(first, second));

        mockMvc.perform(get("/api/todo"))
                .andExpect(status().isOk())
                .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
                .andExpect(jsonPath("$", hasSize(2)))
                .andExpect(jsonPath("$[0].id", is(1)))
                .andExpect(jsonPath("$[0].description", is("Lorem ipsum")))
                .andExpect(jsonPath("$[0].title", is("Foo")))
                .andExpect(jsonPath("$[1].id", is(2)))
                .andExpect(jsonPath("$[1].description", is("Lorem ipsum")))
                .andExpect(jsonPath("$[1].title", is("Bar")));

        verify(todoServiceMock, times(1)).findAll();
        verifyNoMoreInteractions(todoServiceMock);
    }
}
```

代码中使用的`TestUtil.APPLICATION_JSON_UTF8`的定义如下:

```java
public class TestUtil {

    public static final MediaType APPLICATION_JSON_UTF8 =
			new MediaType(
				MediaType.APPLICATION_JSON.getType(),
				MediaType.APPLICATION_JSON.getSubtype,
				Charset.forName("utf8")
			);
}
```

## GET `Todo`项的接口

首先看一下该接口的实现代码。

### 预期的实现

预期的接口应该做以下几件事:

1. 接收到"/api/todo/{id}"上的GET请求,开始处理流程
2. 调用`TodoService`的`findById()`方法获取到目标Todo对象
3. 将`Todo`项转换为`TodoDTO`项
4. 返回`TodoDTO`项的json表示

`TodoController`类内的相关代码如下:

```java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class TodoController {

    private TodoService service;

    @RequestMapping(value = "/api/todo/{id}", method = RequestMethod.GET)
    @ResponseBody
    public TodoDTO findById(@PathVariable("id") Long id) throws TodoNotFoundException {
        Todo found = service.findById(id);
        return createDTO(found);
    }

    private TodoDTO createDTO(Todo model) {
        TodoDTO dto = new TodoDTO();

        dto.setId(model.getId());
        dto.setDescription(model.getDescription());
        dto.setTitle(model.getTitle());

        return dto;
    }
}
```

> 如果抛出`TodoNotFoundException`,程序会怎么处理?

如前所述,我们编写了一个异常处理类来处理异常与HTTP返回码的映射。当程序抛出`TodoNotFoundException`异常时,异常处理类会将该异常转换为404的状态码,并写一条日志。

`RestErrorHandler`类的代码如下:

```java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

@ControllerAdvice
public class RestErrorHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(RestErrorHandler.class);

    @ExceptionHandler(TodoNotFoundException.class)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    public void handleTodoNotFoundException(TodoNotFoundException ex) {
        LOGGER.debug("handling 404 error on a todo entry");
    }
}
```

所以,我们的单元测试需要同时测试`Todo`项未找到和已找到的情况。

### 测试用例:`Todo`项GET请求返回404

该测试用例主要工作如下:

1. 配置mock的`TodoService`实例在`findById()`方法被调用的时候抛出`TodoNotFoundException`
2. 执行一个'/api/todo/1'的GET请求
3. 对响应作断言:HTTP返回码是404
4. 检查请求执行过程中mock的`TodoService`实例执行了`findById()`方法有且仅1次
5. 检查请求执行过程中mock的`TodoService`实例未执行其他方法

相关代码如下:

```java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;

import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, WebAppContext.class})
@WebAppConfiguration
public class TodoControllerTest {

    private MockMvc mockMvc;

    @Autowired
    private TodoService todoServiceMock;

    //Add WebApplicationContext field here.

    //The setUp() method is omitted.

    @Test
    public void findById_TodoEntryNotFound_ShouldReturnHttpStatusCode404() throws Exception {
        when(todoServiceMock.findById(1L)).thenThrow(new TodoNotFoundException(""));

        mockMvc.perform(get("/api/todo/{id}", 1L))
                .andExpect(status().isNotFound());

        verify(todoServiceMock, times(1)).findById(1L);
        verifyNoMoreInteractions(todoServiceMock);
    }
}
```

### 测试用例:`Todo`项GET请求返回成功

该测试用例主要工作如下:

1. 准备测试数据
2. 配置mock的`TodoService`实例在`findById()`方法被调用的时候返回准备的数据
3. 执行一个'/api/todo/1'的GET请求
4. 对响应作断言:HTTP返回码是200
5. 对响应作断言:Content-type的值是"application/json",并且字符集是"UTF-8"
6. 对响应作断言:使用jsonpath对结果作验证
7. 检查请求执行过程中mock的`TodoService`实例执行了`findById()`方法有且仅1次
8. 检查请求执行过程中mock的`TodoService`实例未执行其他方法

代码如下:

```java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, WebAppContext.class})
@WebAppConfiguration
public class TodoControllerTest {

    private MockMvc mockMvc;

    @Autowired
    private TodoService todoServiceMock;

    //Add WebApplicationContext field here.

    //The setUp() method is omitted.

    @Test
    public void findById_TodoEntryFound_ShouldReturnFoundTodoEntry() throws Exception {
        Todo found = new TodoBuilder()
                .id(1L)
                .description("Lorem ipsum")
                .title("Foo")
                .build();

        when(todoServiceMock.findById(1L)).thenReturn(found);

        mockMvc.perform(get("/api/todo/{id}", 1L))
                .andExpect(status().isOk())
                .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
                .andExpect(jsonPath("$.id", is(1)))
                .andExpect(jsonPath("$.description", is("Lorem ipsum")))
                .andExpect(jsonPath("$.title", is("Foo")));

        verify(todoServiceMock, times(1)).findById(1L);
        verifyNoMoreInteractions(todoServiceMock);
    }
}
```

## POST `Todo`项的接口

首先看一下该接口的实现代码。

### 预期的实现

预期的接口应该做以下几件事:

1. 接收到"/api/todo"上的POST请求,开始处理流程
2. 校验参数向`TodoDTO`的转换
3. 调用`TodoService`的`add()`方法添加指定的`Todo`项
4. 将`Todo`项转换为`TodoDTO`项
5. 返回`TodoDTO`项的json表示

`TodoController`类内的相关代码如下:

```java
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Controller
public class TodoController {

    private TodoService service;

    @RequestMapping(value = "/api/todo", method = RequestMethod.POST)
    @ResponseBody
    public TodoDTO add(@Valid @RequestBody TodoDTO dto) {
        Todo added = service.add(dto);
        return createDTO(added);
    }

    private TodoDTO createDTO(Todo model) {
        TodoDTO dto = new TodoDTO();

        dto.setId(model.getId());
        dto.setDescription(model.getDescription());
        dto.setTitle(model.getTitle());

        return dto;
    }
}
```

我们使用了`TodoDTO`类来封装`Todo`项的创建信息,代码如下:

```java
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

public class TodoDTO {

    private Long id;

    @Length(max = 500)
    private String description;

    @NotEmpty
    @Length(max = 100)
    private String title;

    //Constructor and other methods are omitted.
}
```

`TodoDTO`类里面有一些校验规则,如果不满足规则,Spring在接口的`BindingResult`参数里面会显示错误。

所以,我们的测试用例需要考虑两种情况:

- 参数校验通过,接口返回json
- 参数校验没有通过,异常被映射为状态码400

也就是说,如果参数正确,返回结果的状态码为200,返回json形如:

```json
{
    "fieldErrors":[
        {
            "path":"description",
            "message":"The maximum length of the description is 500 characters."
        },
        {
            "path":"title",
            "message":"The maximum length of the title is 100 characters."
        }
    ]
}
```

如果参数不正确,返回结果的状态码为400,返回json形如:

```json
{
    "id":1,
    "description":"description",
    "title":"todo"
}
```

接下来可以开始编写测试用例了。

### 测试用例:`Todo`项POST请求失败

该测试用例主要工作如下:

1. 创建一个不符合验证规则的title
2. 创建一个不符合验证规则的description
3. 执行一个'/api/todo'的POST请求
4. 对响应作断言:HTTP返回码是400
5. 对响应作断言:Content-type的值是"application/json",并且字符集是"UTF-8"
6. 检查请求执行过程中mock的`TodoService`实例未执行任何方法

代码如下:

```java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;

import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, WebAppContext.class})
@WebAppConfiguration
public class TodoControllerTest {

    private MockMvc mockMvc;

    @Autowired
    private TodoService todoServiceMock;

    //Add WebApplicationContext field here.

    //The setUp() method is omitted.

    @Test
    public void
    add_TitleAndDescriptionAreTooLong_ShouldReturnValidationErrorsForTitleAndDescription()
    throws Exception {
        String title = TestUtil.createStringWithLength(101);
        String description = TestUtil.createStringWithLength(501);

        TodoDTO dto = new TodoDTOBuilder()
                .description(description)
                .title(title)
                .build();

        mockMvc.perform(post("/api/todo")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(dto))
        )
                .andExpect(status().isBadRequest())
                .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
                .andExpect(jsonPath("$.fieldErrors", hasSize(2)))
                .andExpect(
                    jsonPath(
                        "$.fieldErrors[*].path", containsInAnyOrder("title", "description")
                    )
                )
                .andExpect(jsonPath("$.fieldErrors[*].message", containsInAnyOrder(
                        "The maximum length of the description is 500 characters.",
                        "The maximum length of the title is 100 characters."
                )));

        verifyZeroInteractions(todoServiceMock);
    }
}
```

我们使用到了`TestUtil`类,再一次地将该类的代码贴出来以供参考。

```java
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;

import java.io.IOException;
import java.nio.charset.Charset;

public class TestUtil {

    public static final MediaType APPLICATION_JSON_UTF8 =
        new MediaType(
            MediaType.APPLICATION_JSON.getType(),
            MediaType.APPLICATION_JSON.getSubtype(),
            Charset.forName("utf8")
        );

    public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return mapper.writeValueAsBytes(object);
    }

    public static String createStringWithLength(int length) {
        StringBuilder builder = new StringBuilder();

        for (int index = 0; index < length; index++) {
            builder.append("a");
        }

        return builder.toString();
    }
}
```

### 测试用例:`Todo`项POST请求成功

该测试用例主要工作如下:

1. 准备测试数据
2. 配置mock的`TodoService`实例在`add()`方法被调用的时候返回一个`Todo`项
3. 执行一个'/todo/add'的POST请求
4. 对响应作断言:HTTP返回码是200
5. 对响应作断言:Content-type的值是"application/json",并且字符集是"UTF-8"
6. 对响应作断言:使用jsonpath对结果作验证

代码如下:

```java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;

import static junit.framework.Assert.assertNull;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TestContext.class, WebAppContext.class})
@WebAppConfiguration
public class TodoControllerTest {

    private MockMvc mockMvc;

    @Autowired
    private TodoService todoServiceMock;

    //Add WebApplicationContext field here.

    //The setUp() method is omitted.

    @Test
    public void
    add_NewTodoEntry_ShouldAddTodoEntryAndReturnAddedEntry() throws Exception {
        TodoDTO dto = new TodoDTOBuilder()
                .description("description")
                .title("title")
                .build();

        Todo added = new TodoBuilder()
                .id(1L)
                .description("description")
                .title("title")
                .build();

        when(todoServiceMock.add(any(TodoDTO.class))).thenReturn(added);

        mockMvc.perform(post("/api/todo")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(dto))
        )
                .andExpect(status().isOk())
                .andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
                .andExpect(jsonPath("$.id", is(1)))
                .andExpect(jsonPath("$.description", is("description")))
                .andExpect(jsonPath("$.title", is("title")));

        ArgumentCaptor<TodoDTO> dtoCaptor = ArgumentCaptor.forClass(TodoDTO.class);
        verify(todoServiceMock, times(1)).add(dtoCaptor.capture());
        verifyNoMoreInteractions(todoServiceMock);

        TodoDTO dtoArgument = dtoCaptor.getValue();
        assertNull(dtoArgument.getId());
        assertThat(dtoArgument.getDescription(), is("description"));
        assertThat(dtoArgument.getTitle(), is("title"));
    }
}
```

# 总结

本文主要介绍了:

- 如何为REST接口的GET请求编写单元测试
- 如何为REST接口的POST请求编写单元测试
- 如何将对象序列化为json并用POST请求发送出去
- 如何使用JsonPath对返回的结果作断言

到此,整个使用Spring MVC Test来进行单元测试的系列就结束了,希望所有人能有所收获。

本文使用的代码已经放在了 [Github](https://github.com/pkainulainen/spring-mvc-test-examples/tree/master/controllers-unittest) 上,请自行查阅。

翻译完了单元测试的三篇文章,感觉心好累。不得不佩服国外的同行,研究一个东西就研究得很透,分析的很细。本系列不仅仅是一个测试的教程,而且可以作为Spring MVC的开发入门系列。

对作者致以崇高的敬意,和感谢!


text:
layout: default
category: tutorials
title: "Visual Fusion Enterprise"
link: "http://docs.idvsolutions.com/vf/5.5/Documents/connectingtoanodatas.html"
---
Connecting to an OData source


text:
////////////////////////////////////////////////////////////////////////////////
// The following FIT Protocol software provided may be used with FIT protocol
// devices only and remains the copyrighted property of Dynastream Innovations Inc.
// The software is being provided on an "as-is" basis and as an accommodation,
// and therefore all warranties, representations, or guarantees of any kind
// (whether express, implied or statutory) including, without limitation,
// warranties of merchantability, non-infringement, or fitness for a particular
// purpose, are specifically disclaimed.
//
// Copyright 2013 Dynastream Innovations Inc.
////////////////////////////////////////////////////////////////////////////////
// ****WARNING****  This file is auto-generated!  Do NOT edit this file.
// Profile Version = 8.20Release
// Tag = $Name: AKW8_200 $
////////////////////////////////////////////////////////////////////////////////

package com.garmin.fit;

public class CapabilitiesMesg extends Mesg {

   protected static final	Mesg capabilitiesMesg;
   static {
      // capabilities
      capabilitiesMesg = new Mesg("capabilities", MesgNum.CAPABILITIES);
      capabilitiesMesg.addField(new Field("languages", 0, 10, 1, 0, "", false));

      capabilitiesMesg.addField(new Field("sports", 1, 10, 1, 0, "", false));

      capabilitiesMesg.addField(new Field("workouts_supported", 21, 140, 1, 0, "", false));

   }

   public CapabilitiesMesg() {
      super(Factory.createMesg(MesgNum.CAPABILITIES));
   }

   public CapabilitiesMesg(final Mesg mesg) {
      super(mesg);
   }

   /**
    * @return number of languages
    */
   public int getNumLanguages() {
      return getNumFieldValues(0, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Get languages field
    * Comment: Use language_bits_x types where x is index of array.
    *
    * @param index of languages
    * @return languages
    */
   public Short getLanguages(int index) {
      return getFieldShortValue(0, index, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Set languages field
    * Comment: Use language_bits_x types where x is index of array.
    *
    * @param index of languages
    * @param languages
    */
   public void setLanguages(int index, Short languages) {
      setFieldValue(0, index, languages, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * @return number of sports
    */
   public int getNumSports() {
      return getNumFieldValues(1, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Get sports field
    * Comment: Use sport_bits_x types where x is index of array.
    *
    * @param index of sports
    * @return sports
    */
   public Short getSports(int index) {
      return getFieldShortValue(1, index, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Set sports field
    * Comment: Use sport_bits_x types where x is index of array.
    *
    * @param index of sports
    * @param sports
    */
   public void setSports(int index, Short sports) {
      setFieldValue(1, index, sports, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Get workouts_supported field
    *
    * @return workouts_supported
    */
   public Long getWorkoutsSupported() {
      return getFieldLongValue(21, 0, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

   /**
    * Set workouts_supported field
    *
    * @param workoutsSupported
    */
   public void setWorkoutsSupported(Long workoutsSupported) {
      setFieldValue(21, 0, workoutsSupported, Fit.SUBFIELD_INDEX_MAIN_FIELD);
   }

}


text:
namespace Microsoft.Azure.Management.AppPlatform.Models
{
    using Newtonsoft.Json;
    using System.Linq;

    /// <summary>
    /// API metadata property for Spring Cloud Gateway
    /// </summary>
    public partial class GatewayApiMetadataProperties
    {
        /// <summary>
        /// Initializes a new instance of the GatewayApiMetadataProperties
        /// class.
        /// </summary>
        public GatewayApiMetadataProperties()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the GatewayApiMetadataProperties
        /// class.
        /// </summary>
        /// <param name="title">Title describing the context of the APIs
        /// available on the Gateway instance (default: `Spring Cloud Gateway
        /// for K8S`)</param>
        /// <param name="description">Detailed description of the APIs
        /// available on the Gateway instance (default: `Generated OpenAPI 3
        /// document that describes the API routes configured.`)</param>
        /// <param name="documentation">Location of additional documentation
        /// for the APIs available on the Gateway instance</param>
        /// <param name="version">Version of APIs available on this Gateway
        /// instance (default: `unspecified`).</param>
        /// <param name="serverUrl">Base URL that API consumers will use to
        /// access APIs on the Gateway instance.</param>
        public GatewayApiMetadataProperties(string title = default(string), string description = default(string), string documentation = default(string), string version = default(string), string serverUrl = default(string))
        {
            Title = title;
            Description = description;
            Documentation = documentation;
            Version = version;
            ServerUrl = serverUrl;
            CustomInit();
        }

        /// <summary>
        /// An initialization method that performs custom operations like setting defaults
        /// </summary>
        partial void CustomInit();

        /// <summary>
        /// Gets or sets title describing the context of the APIs available on
        /// the Gateway instance (default: `Spring Cloud Gateway for K8S`)
        /// </summary>
        [JsonProperty(PropertyName = "title")]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets detailed description of the APIs available on the
        /// Gateway instance (default: `Generated OpenAPI 3 document that
        /// describes the API routes configured.`)
        /// </summary>
        [JsonProperty(PropertyName = "description")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets location of additional documentation for the APIs
        /// available on the Gateway instance
        /// </summary>
        [JsonProperty(PropertyName = "documentation")]
        public string Documentation { get; set; }

        /// <summary>
        /// Gets or sets version of APIs available on this Gateway instance
        /// (default: `unspecified`).
        /// </summary>
        [JsonProperty(PropertyName = "version")]
        public string Version { get; set; }

        /// <summary>
        /// Gets or sets base URL that API consumers will use to access APIs on
        /// the Gateway instance.
        /// </summary>
        [JsonProperty(PropertyName = "serverUrl")]
        public string ServerUrl { get; set; }

    }
}


text:
<?php

namespace Tests\AppBundle\EdgeToEdge;

use Liip\FunctionalTestBundle\Test\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class ImageUploadTest extends WebTestCase
{
    /**
     * @return array
     */
    public function testNavigateToCreateWaypointForm()
    {
        $this->loadAllFixtures();
        $client = $this->createAuthenticatedClient();

        $crawler = $client->request('GET', '/walks');
        $crawler = $crawler->selectLink('Runde beginnen');
        $crawler = $client->click($crawler->link());
        $this->isSuccessful($client->getResponse());

        $form = $crawler->selectButton('Wegpunkt anlegen')->form(
            [
                'app_create_walk_prologue[name]' => 'name test',
                'app_create_walk_prologue[conceptOfDay]' => 'conceptOfDay test',
            ]
        );

        $crawler = $client->submit($form);
        $this->isSuccessful($client->getResponse());

        return [$client, $crawler];
    }

    /**
     * @depends testNavigateToCreateWaypointForm
     * @param array $args
     */
    public function testSubmittingEmptyFormRedirectsToForm(array $args)
    {
        /**@var Client $client */
        $client = $args[0];
        /**@var Crawler $crawler */
        $crawler = $args[1];

        $form = $crawler->selectButton('speichern')->form();
        $crawler = $client->submit($form);
        $this->isSuccessful($client->getResponse());

        $form = $crawler->selectButton('speichern')->form();
        $this->assertArrayHasKey('app_create_way_point', $form->getPhpValues(),
            'Form didnt not redirect to itself when submitting with invalid values');
    }

    /**
     * @depends testNavigateToCreateWaypointForm
     * @param array $args
     */
    public function testSubmittingValidImageSavesImage(array $args)
    {
        /**@var Client $client */
        $client = $args[0];
        /**@var Crawler $crawler */
        $crawler = $args[1];

        $form = $crawler->selectButton('speichern')->form();
        $fileLocation = $client->getKernel()->getRootDir();
        $fileLocation .= '/../tests/AppBundle/fixtures/image.jpg';

        $form['app_create_way_point[imageFile][file]']->upload($fileLocation);
        $form['app_create_way_point[locationName]'] = 'Buxtehude is the locationName value';
        $form['app_create_way_point[note]'] = 'note value';

        $crawler = $client->submit($form);
        $this->isSuccessful($client->getResponse());

        // check for saved image - todo refactor to own testmethod
        $link = $crawler->selectLink('Wegpunkt ansehen');
        $crawler = $client->click($link->link());
        $this->isSuccessful($client->getResponse());

        $img = $crawler->filter('img');
        $this->assertSame('/images/way_points/image.jpg', $img->attr('src'));
    }

    /**
     * @depends testNavigateToCreateWaypointForm
     * @param array $args
     */
    public function testUploadingImageExcceedingMaxFileSizeRendersFormErrors(array $args)
    {
        /**@var Client $client */
        $client = $args[0];
        /**@var Crawler $crawler */
        $crawler = $args[1];

        $fileName = 'test_image_42MB.png';
        $fileLocation = $client->getKernel()->getRootDir();
        $fileLocation .= '/../tests/AppBundle/fixtures/' . $fileName;
        $imgStub = new UploadedFile($fileLocation, $fileName);

        $form = $crawler->selectButton('speichern')->form();
        $form['app_create_way_point[imageFile][file]'] = $imgStub;
        $form['app_create_way_point[locationName]'] = 'Buxtehude is the locationName value';
        $form['app_create_way_point[note]'] = 'note value';
        $crawler = $client->submit($form);

        // only working with german translation messages
        $text = $crawler->text();
        $this->assertContains('Datei ist zu groß',
            $text,
            'Error uploading ' . $fileName . '. Either upload_max_filesize in php.ini is lower than the assertion.
                or file was uploaded without triggering a form error.');
    }

    /**
     * @return \Doctrine\Common\DataFixtures\Executor\AbstractExecutor|null|void
     */
    private function loadAllFixtures()
    {
        $this->loadFixtureFiles(
            [
                '@AppBundle/DataFixtures/ORM/test/tag.yml',
                '@AppBundle/DataFixtures/ORM/test/guest.yml',
                '@AppBundle/DataFixtures/ORM/test/team.yml',
                '@AppBundle/DataFixtures/ORM/test/user.yml',
                '@AppBundle/DataFixtures/ORM/test/walk.yml',
                '@AppBundle/DataFixtures/ORM/test/systemicQuestion.yml',
                '@AppBundle/DataFixtures/ORM/test/wayPoint.yml',
            ]
        );
    }

    /**
     * @return Client
     */
    private function createAuthenticatedClient()
    {
        $credentials = [
            'username' => 'waldi_beta',
            'password' => 'waldi_beta',
        ];

        $client = static::makeClient($credentials);
        $client->followRedirects(true);
        return $client;
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>ArrayTool</title>
<meta name="date" content="2015-03-20">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Tree

Index

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

com.sillysoft.tools

Class ArrayTool

java.lang.Object

com.sillysoft.tools.ArrayTool

public class ArrayTool
extends java.lang.Object

Constructor Summary

Constructors

Constructor and Description

ArrayTool()

Method Summary

All Methods Static Methods Concrete Methods

Modifier and Type
Method and Description

static boolean
arrayContains(int[] array,
             int key)

Does this array contain the given key?

static boolean
arrayContains(java.lang.String[] array,
             java.lang.String key)

Does this array contain the given key?

static int
arrayIndex(java.lang.String[] array,
          java.lang.String key)

Return the index of the given key inside the array or -1 if the array does not contain the key.

static java.util.Vector
randomize(java.util.Vector v)

Shuffle the order of the elements in the List.

static java.util.Vector
randomize(java.util.Vector v,
         java.util.Random random)

Shuffle the order of the elements in the List.

static java.util.Vector
removeDuplicates(java.util.Vector v)

static int
sum(int[] array)

static java.lang.String
toString(java.util.List v)

static java.lang.String
toString(java.lang.String[] strArray)

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

ArrayTool

public ArrayTool()

Method Detail

arrayContains

public static boolean arrayContains(int[] array,
                                    int key)

Does this array contain the given key?

arrayContains

public static boolean arrayContains(java.lang.String[] array,
                                    java.lang.String key)

Does this array contain the given key?

arrayIndex

public static int arrayIndex(java.lang.String[] array,
                             java.lang.String key)

Return the index of the given key inside the array or -1 if the array does not contain the key.

randomize

public static java.util.Vector randomize(java.util.Vector v)

Shuffle the order of the elements in the List. Return the same List instance with the shuffled order.

randomize

public static java.util.Vector randomize(java.util.Vector v,
                                         java.util.Random random)

Shuffle the order of the elements in the List. Return the same List instance with the shuffled order.

removeDuplicates

public static java.util.Vector removeDuplicates(java.util.Vector v)

sum

public static int sum(int[] array)

toString

public static java.lang.String toString(java.util.List v)

toString

public static java.lang.String toString(java.lang.String[] strArray)

Skip navigation links

Overview

Package

Class

Tree

Index

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
package com.stevenschoen.putionew.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;

import com.stevenschoen.putionew.R;
import com.stevenschoen.putionew.fragments.FileDetails;
import com.stevenschoen.putionew.model.files.PutioFile;

public class FileDetailsActivity extends BaseCastActivity {

    private FileDetails fileDetailsFragment;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        PutioFile fileData = getIntent().getExtras().getParcelable("fileData");

        setContentView(R.layout.filedetailsphone);

        initCastBar();

        if (savedInstanceState == null) {
            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            Bundle fileDetailsBundle = new Bundle();
            fileDetailsBundle.putParcelable("fileData", fileData);
            fileDetailsFragment = (FileDetails) FileDetails.instantiate(
                    this, FileDetails.class.getName(), fileDetailsBundle);
            fragmentTransaction.add(R.id.DetailsHolder, fileDetailsFragment);
            fragmentTransaction.commit();
        } else {
            fileDetailsFragment = (FileDetails) getSupportFragmentManager().findFragmentById(R.id.DetailsHolder);
        }

        setTitle(fileData.name);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case android.R.id.home:
                Intent homeIntent = new Intent(getApplicationContext(), Putio.class);
                homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(homeIntent);
                return true;
        }

        return super.onOptionsItemSelected(menuItem);
    }
}


text:
exports.name = 'group';

exports.help = '';

exports.pipeWorker = function(feedIn, feedOut, fields) {
	fields || (fields = 0);
	fields = [].concat(fields);
	field = fields[0];

	feedIn.on('start', function (meta, streamIn) {
		var groups = {};

		var newFields = [field, field + '_count'];

		if (typeof field === 'string') {
			field = meta.fields.indexOf(field);
		}

		meta.fields = newFields;

		var streamOut = feedOut.start(meta);

		streamIn.on('line', function (line) {
			if ( line[field] in groups ) {
				groups[line[field]]++;
			}
			else {
				groups[line[field]]=1;
			}
		});
		streamIn.on('end', function() {
			for ( var group in groups ) {
				streamOut.write([group, groups[group]]);
			}
			streamOut.end();
		});

	});

};


text:
'use strict';

/**
 * LaTeX Invoice Generator from JSON source
 * ----------------------------------------
 *
 * Generates a pdf invoice from your json source file
 * using a LaTeX template file.
 *
 * (c) 2015 Matthias Hannig
 */

var fs   = require('fs');
var argv = require('yargs').argv;

// Load modules
var invoice_init     = require('./cli/init');
var invoice_compile  = require('./cli/compile');
var invoice_config   = require('./cli/config');
var invoice_usage    = require('./cli/usage');

// Switch action based on arguments
var actions = {
  'init':    invoice_init,
  'config':  invoice_config,
  'compile': invoice_compile,
  'help':    invoice_usage
};

var action = argv['_'][0]
var run = actions[action]||actions['help'];

run(argv);