用NetBeans为Java Card编写了一个简单的8字节随机数生成程序。
这是程序:
public class RandGen extends Applet {
byte[] generatedArray;
RandomData randData = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
private RandGen() {
generatedArray = JCSystem.makeTransientByteArray((short)8, JCSystem.CLEAR_ON_DESELECT);
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new RandGen().register();
}
public void process(APDU arg0) throws ISOException {
byte[] byffer = arg0.getBuffer();
byte[] generatedRandom = MyGenerator(arg0);
Util.arrayCopyNonAtomic(generatedRandom, (short) 0, byffer, (short) 0,
(short) generatedRandom.length);
arg0.setOutgoingAndSend((short) 0, (short) generatedRandom.length);
}
public byte[] MyGenerator(APDU apdu) {
randData.generateData(generatedArray, (short) 0, (short) 8);
return generatedArray;
}
}
我点击hammer按钮构建项目,然后点击绿色三角形在模拟器上运行项目,如下所示:
其他信息:
当我尝试使用CREF和JCWDE模拟这个applet时,我收到了一些不同的状态词:
这是我在下面的模拟中使用的myscripp.script文件的内容:
powerup;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
0x80 0xB0 0x00 0x00 0x00 0x7F;
// randGen/javacard/Header.cap
0x80 0xB2 0x01 0x00 0x00 0x7F;
0x80 0xB4 0x01 0x00 0x17 0x01 0x00 0x14 0xDE 0xCA 0xFF 0xED 0x01 0x02 0x04 0x00 0x01 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x7F;
0x80 0xBC 0x01 0x00 0x00 0x7F;
// randGen/javacard/Directory.cap
0x80 0xB2 0x02 0x00 0x00 0x7F;
0x80 0xB4 0x02 0x00 0x20 0x02 0x00 0x1F 0x00 0x14 0x00 0x1F 0x00 0x0F 0x00 0x1F 0x00 0x32 0x00 0x0E 0x00 0x51 0x00 0x0A 0x00 0x13 0x00 0x00 0x00 0x83 0x00 0x00 0x00 0x00 0x00 0x00 0x03 0x7F;
0x80 0xB4 0x02 0x00 0x02 0x01 0x00 0x7F;
0x80 0xBC 0x02 0x00 0x00 0x7F;
// randGen/javacard/Import.cap
0x80 0xB2 0x04 0x00 0x00 0x7F;
0x80 0xB4 0x04 0x00 0x20 0x04 0x00 0x1F 0x03 0x03 0x01 0x07 0xA0 0x00 0x00 0x00 0x62 0x01 0x01 0x03 0x01 0x07 0xA0 0x00 0x00 0x00 0x62 0x01 0x02 0x00 0x01 0x07 0xA0 0x00 0x00 0x00 0x62 0x7F;
0x80 0xB4 0x04 0x00 0x02 0x00 0x01 0x7F;
0x80 0xBC 0x04 0x00 0x00 0x7F;
// randGen/javacard/Applet.cap
0x80 0xB2 0x03 0x00 0x00 0x7F;
0x80 0xB4 0x03 0x00 0x12 0x03 0x00 0x0F 0x01 0x0B 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x16 0x7F;
0x80 0xBC 0x03 0x00 0x00 0x7F;
// randGen/javacard/Class.cap
0x80 0xB2 0x06 0x00 0x00 0x7F;
0x80 0xB4 0x06 0x00 0x11 0x06 0x00 0x0E 0x00 0x80 0x03 0x02 0x00 0x02 0x07 0x02 0x00 0x00 0x00 0x23 0x00 0x42 0x7F;
0x80 0xBC 0x06 0x00 0x00 0x7F;
// randGen/javacard/Method.cap
0x80 0xB2 0x07 0x00 0x00 0x7F;
0x80 0xB4 0x07 0x00 0x20 0x07 0x00 0x51 0x00 0x02 0x10 0x18 0x8C 0x00 0x03 0x18 0x10 0x08 0x90 0x0B 0x87 0x00 0x18 0x05 0x8D 0x00 0x02 0x87 0x01 0x7A 0x02 0x30 0x8F 0x00 0x04 0x3D 0x8C 0x7F;
0x80 0xB4 0x07 0x00 0x20 0x00 0x05 0x8B 0x00 0x06 0x7A 0x05 0x22 0x19 0x8B 0x00 0x07 0x2D 0x18 0x19 0x8B 0x00 0x08 0x2E 0x1B 0x03 0x1A 0x03 0x1B 0x92 0x8D 0x00 0x09 0x3B 0x19 0x03 0x1B 0x7F;
0x80 0xB4 0x07 0x00 0x14 0x92 0x8B 0x00 0x0A 0x7A 0x04 0x20 0xAD 0x01 0xAD 0x00 0x03 0x10 0x08 0x8B 0x00 0x0B 0xAD 0x00 0x77 0x7F;
0x80 0xBC 0x07 0x00 0x00 0x7F;
// randGen/javacard/StaticField.cap
0x80 0xB2 0x08 0x00 0x00 0x7F;
0x80 0xB4 0x08 0x00 0x0D 0x08 0x00 0x0A 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x7F;
0x80 0xBC 0x08 0x00 0x00 0x7F;
// randGen/javacard/ConstantPool.cap
0x80 0xB2 0x05 0x00 0x00 0x7F;
0x80 0xB4 0x05 0x00 0x20 0x05 0x00 0x32 0x00 0x0C 0x02 0x00 0x00 0x00 0x02 0x00 0x00 0x01 0x06 0x81 0x0E 0x00 0x06 0x80 0x03 0x00 0x01 0x00 0x00 0x00 0x06 0x00 0x00 0x01 0x03 0x80 0x03 0x7F;
0x80 0xB4 0x05 0x00 0x15 0x01 0x03 0x80 0x0A 0x01 0x03 0x00 0x00 0x08 0x06 0x80 0x10 0x02 0x03 0x80 0x0A 0x08 0x03 0x81 0x0E 0x01 0x7F;
0x80 0xBC 0x05 0x00 0x00 0x7F;
// randGen/javacard/RefLocation.cap
0x80 0xB2 0x09 0x00 0x00 0x7F;
0x80 0xB4 0x09 0x00 0x16 0x09 0x00 0x13 0x00 0x05 0x0D 0x07 0x31 0x02 0x08 0x00 0x0A 0x05 0x0C 0x08 0x04 0x03 0x07 0x06 0x0A 0x08 0x0D 0x7F;
0x80 0xBC 0x09 0x00 0x00 0x7F;
0x80 0xBA 0x00 0x00 0x00 0x7F;
// Select the installer applet
0x00 0xA4 0x04 0x00 0x09 0xa0 0x00 0x00 0x00 0x62 0x03 0x01 0x08 0x01 0x7F;
// create RandGen applet
// select RandGen applet
0x00 0xA4 0x04 0x00 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x7F;
0x80 0xB8 0x00 0x00 0xd 0xb 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x00 0x00 0x00 0x7F;
powerdown;
C:\Java\java_card_kit-2_2_2-rr-bin-windows-do\bin>apdutool.bat C:\Users\AmirEbrahim\Documents\EclipseProjects\RandomGenerator\bin\randGen\javacard\MyScript.script
Java Card 2.2.2 APDU Tool, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
Opening connection to localhost on port 9025.
Connected.
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x01
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b0, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 01, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 01, P2: 00, Lc: 17, 01, 00, 14, de, ca, ff, ed, 01, 02, 04, 00, 01, 0a, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 01, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 02, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 02, P2: 00, Lc: 20, 02, 00, 1f, 00, 14, 00, 1f, 00, 0f, 00, 1f, 00, 32, 00, 0e, 00, 51, 00, 0a, 00, 13, 00, 00, 00, 83, 00, 00, 00, 00, 00, 00, 03, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 02, P2: 00, Lc: 02, 01, 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 02, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 04, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 04, P2: 00, Lc: 20, 04, 00, 1f, 03, 03, 01, 07, a0, 00, 00, 00, 62, 01, 01, 03, 01, 07, a0, 00, 00, 00, 62, 01, 02, 00, 01, 07, a0, 00, 00, 00, 62, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 04, P2: 00, Lc: 02, 00, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 04, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 03, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 03, P2: 00, Lc: 12, 03, 00, 0f, 01, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, 00, 16, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 03, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 06, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 06, P2: 00, Lc: 11, 06, 00, 0e, 00, 80, 03, 02, 00, 02, 07, 02, 00, 00, 00, 23, 00, 42, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 06, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 07, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 20, 07, 00, 51, 00, 02, 10, 18, 8c, 00, 03, 18, 10, 08, 90, 0b, 87, 00, 18, 05, 8d, 00, 02, 87, 01, 7a, 02, 30, 8f, 00, 04, 3d, 8c, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 20, 00, 05, 8b, 00, 06, 7a, 05, 22, 19, 8b, 00, 07, 2d, 18, 19, 8b, 00, 08, 2e, 1b, 03, 1a, 03, 1b, 92, 8d, 00, 09, 3b, 19, 03, 1b, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 14, 92, 8b, 00, 0a, 7a, 04, 20, ad, 01, ad, 00, 03, 10, 08, 8b, 00, 0b, ad, 00, 77, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 07, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 08, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 08, P2: 00, Lc: 0d, 08, 00, 0a, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 08, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 05, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 05, P2: 00, Lc: 20, 05, 00, 32, 00, 0c, 02, 00, 00, 00, 02, 00, 00, 01, 06, 81, 0e, 00, 06, 80, 03, 00, 01, 00, 00, 00, 06, 00, 00, 01, 03, 80, 03, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 05, P2: 00, Lc: 15, 01, 03, 80, 0a, 01, 03, 00, 00, 08, 06, 80, 10, 02, 03, 80, 0a, 08, 03, 81, 0e, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 05, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 09, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 09, P2: 00, Lc: 16, 09, 00, 13, 00, 05, 0d, 07, 31, 02, 08, 00, 0a, 05, 0c, 08, 04, 03, 07, 06, 0a, 08, 0d, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: bc, P1: 09, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: ba, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, Le: 00, SW1: 6d, SW2: 00
CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, 00, Le: 00, SW1: 64, SW2: 44
C:\Java\java_card_kit-2_2_2-rr-bin-windows-do\bin>apdutool.bat C:\Users\AmirEbrahim\Documents\EclipseProjects\RandomGenerator\bin\randGen\javacard\MyScript.script
Java Card 2.2.2 APDU Tool, Version 1.3
Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
Opening connection to localhost on port 9025.
Connected.
Received ATR = 0x3b 0xf0 0x11 0x00 0xff 0x00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b0, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b2, P1: 01, P2: 00, Lc: 00, Le: 00, SW1: 90, SW2: 00
CLA: 80, INS: b4, P1: 01, P2: 00, Lc: 17, 01, 00, 14, de, ca, ff, ed, 01, 02, 04, 00, 01, 0a, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, Le: 00, SW1: 64, SW2: 3a
CLA: 80, INS: bc, P1: 01, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 02, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 02, P2: 00, Lc: 20, 02, 00, 1f, 00, 14, 00, 1f, 00, 0f, 00, 1f, 00, 32, 00, 0e, 00, 51, 00, 0a, 00, 13, 00, 00, 00, 83, 00, 00, 00, 00, 00, 00, 03, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 02, P2: 00, Lc: 02, 01, 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 02, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 04, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 04, P2: 00, Lc: 20, 04, 00, 1f, 03, 03, 01, 07, a0, 00, 00, 00, 62, 01, 01, 03, 01, 07, a0, 00, 00, 00, 62, 01, 02, 00, 01, 07, a0, 00, 00, 00, 62, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 04, P2: 00, Lc: 02, 00, 01, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 04, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 03, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 03, P2: 00, Lc: 12, 03, 00, 0f, 01, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, 00, 16, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 03, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 06, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 06, P2: 00, Lc: 11, 06, 00, 0e, 00, 80, 03, 02, 00, 02, 07, 02, 00, 00, 00, 23, 00, 42, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 06, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 07, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 20, 07, 00, 51, 00, 02, 10, 18, 8c, 00, 03, 18, 10, 08, 90, 0b, 87, 00, 18, 05, 8d, 00, 02, 87, 01, 7a, 02, 30, 8f, 00, 04, 3d, 8c, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 20, 00, 05, 8b, 00, 06, 7a, 05, 22, 19, 8b, 00, 07, 2d, 18, 19, 8b, 00, 08, 2e, 1b, 03, 1a, 03, 1b, 92, 8d, 00, 09, 3b, 19, 03, 1b, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 07, P2: 00, Lc: 14, 92, 8b, 00, 0a, 7a, 04, 20, ad, 01, ad, 00, 03, 10, 08, 8b, 00, 0b, ad, 00, 77, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 07, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 08, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 08, P2: 00, Lc: 0d, 08, 00, 0a, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 08, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 05, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 05, P2: 00, Lc: 20, 05, 00, 32, 00, 0c, 02, 00, 00, 00, 02, 00, 00, 01, 06, 81, 0e, 00, 06, 80, 03, 00, 01, 00, 00, 00, 06, 00, 00, 01, 03, 80, 03, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 05, P2: 00, Lc: 15, 01, 03, 80, 0a, 01, 03, 00, 00, 08, 06, 80, 10, 02, 03, 80, 0a, 08, 03, 81, 0e, 01, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 05, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b2, P1: 09, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: b4, P1: 09, P2: 00, Lc: 16, 09, 00, 13, 00, 05, 0d, 07, 31, 02, 08, 00, 0a, 05, 0c, 08, 04, 03, 07, 06, 0a, 08, 0d, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: bc, P1: 09, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 80, INS: ba, P1: 00, P2: 00, Lc: 00, Le: 00, SW1: 64, SW2: 21
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 09, a0, 00, 00, 00, 62, 03, 01, 08, 01, Le: 00, SW1: 90, SW2: 00
CLA: 00, INS: a4, P1: 04, P2: 00, Lc: 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, Le: 00, SW1: 6d, SW2: 00
CLA: 80, INS: b8, P1: 00, P2: 00, Lc: 0d, 0b, 01, 02, 03, 04, 05, 06, 07, 08, 09, 00, 00, 00, Le: 00, SW1: 64, SW2: 44
C:\Java\java_card_kit-2_2_2-rr-bin-windows-do\bin>
编辑/更新:CREF和JCWDE的输出彼此不同。与NetBeans也不同。(上一版我错了)
也许这是模拟器限制支持alg_secure_random
的问题。
请尝试alg_pseudo_random
。
来自类RandomData:
ALG_Pseudo_Random
Utility pseudo-random number generation algorithms. The random number sequence generated by this algorithm need not be the same even if seeded with the same seed data.
Even if a transaction is in progress, the update of the internal state shall not participate in the transaction.
ALG_Secure_Random
密码安全的随机数生成算法。
我在命令行窗口(Windows7)中使用以下命令启动jcwde: 然后我启动一个新的命令行窗口,并在那里启动apdutool: 以下是。scr脚本文件:powerup;
在前几节基于Fashion-MNIST数据集的实验中,我们评价了机器学习模型在训练数据集和测试数据集上的表现。如果你改变过实验中的模型结构或者超参数,你也许发现了:当模型在训练数据集上更准确时,它在测试数据集上却不一定更准确。这是为什么呢? 训练误差和泛化误差 在解释上述现象之前,我们需要区分训练误差(training error)和泛化误差(generalization error)。通俗来讲,
问题内容: 我该如何与正在测试的班级中的Mockito其他班级进行模拟? 例如: MyClass.java 任何东西PerformerClass.java 并测试: 我是否可以欺骗以排除不必要的逻辑?我可以重写方法来简单地返回还是? 为什么指定Mockito,因为在Robolectric进行Android测试时需要它。 问题答案: 您可以重构,以便它使用依赖注入。不用让它创建实例,您可以将类的实例
我目前正在做一个分析sms_received-flow的项目。
我在LabVIEW中有一个控制和仿真循环结构,它向Multisim模型发送输入并从Multisim模型接收输出。我想测量Multisim模型的两个布尔输出变为true时的仿真时间差。我可以添加一个Control&Simulation->Simulation->Utilities->Simulation Time小部件,并将其连接到前面板上的一个指示器上,并在运行它时看到仿真时间的进展,但我无法找到
在安装到AEM 5.6.1实例之前,我正在使用maven构建和测试我的代码。我已经编写了单元测试,这些测试使用wcm的实现从aem模拟中获益。io和其他需要使用powermockito模拟静态方法的单元测试。 以下是我对aem上下文、sling Mock和powermock的maven依赖关系。 在我的课堂上,我正在为aem上下文设置规则,并准备一些用于模拟的静态类: 当我通过命令行运行mvn测试