Best Jmock-library code snippet using org.jmock.integration.junit3.MockObjectTestCase.states
Source:NorFlashMemoryHeapTest.java
1/*2 * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER4 * 5 * This code is free software; you can redistribute it and/or modify6 * it under the terms of the GNU General Public License version 27 * only, as published by the Free Software Foundation.8 * 9 * This code is distributed in the hope that it will be useful, but10 * WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12 * General Public License version 2 for more details (a copy is13 * included in the LICENSE file that accompanied this code).14 * 15 * You should have received a copy of the GNU General Public License16 * version 2 along with this work; if not, write to the Free Software17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA18 * 02110-1301 USA19 * 20 * Please contact Sun Microsystems, Inc., 16 Network Circle, Menlo21 * Park, CA 94025 or visit www.sun.com if you need additional22 * information or have any questions.23 */24package com.sun.squawk.flash;25import java.io.ByteArrayOutputStream;26import java.io.DataOutputStream;27import java.io.IOException;28import java.util.Vector;29import javax.microedition.rms.RecordStoreException;30import javax.microedition.rms.RecordStoreFullException;31import org.jmock.InAnyOrder;32import org.jmock.InThisOrder;33import org.jmock.api.Invocation;34import org.jmock.integration.junit3.MockObjectTestCase;35import org.jmock.lib.action.CustomAction;36import com.sun.squawk.Address;37import com.sun.squawk.VM;38import com.sun.squawk.peripheral.SimulatedNorFlashSector;39import com.sun.squawk.peripheral.INorFlashSector;40import com.sun.squawk.peripheral.SimulatedNorFlashSectorAllocator;41import com.sun.squawk.util.UnexpectedException;42public class NorFlashMemoryHeapTest extends MockObjectTestCase {43 protected INorFlashMemoryHeap heap;44 protected NorFlashMemoryHeap castHeap;45 46 @Override47 public void setUp() {48 castHeap = new NorFlashMemoryHeap();49 heap = castHeap;50 }51 /*52 * constructor(ILogSector[])53 */54 public void test1() throws IOException {55 INorFlashSectorState sector = mock(INorFlashSectorState.class);56 INorFlashSectorState[] sectors = new INorFlashSectorState[] {sector};57 castHeap = new NorFlashMemoryHeap(sectors);58 assertSame(sectors, castHeap.sectorStates);59 }60 61 /*62 * constructor(int purpose), and no sectors setup63 */64 public void test2() throws IOException {65 try {66 new NorFlashMemoryHeap(INorFlashSector.RMS_PURPOSED);67 fail();68 } catch (RuntimeException e) {69 }70 }71 72 /*73 * constructor(int purpose)74 */75 public void test3() throws IOException {76 final int numSectors = 1;77 SimulatedNorFlashSectorAllocator.getSingleton().setupSectors(numSectors, 1024, INorFlashSector.RMS_PURPOSED, false);78 79 castHeap = new NorFlashMemoryHeap(INorFlashSector.RMS_PURPOSED);80 81 SimulatedNorFlashSectorAllocator.getSingleton().uninstallSectors();82 83 assertSame(numSectors, castHeap.sectorStates.length);84 }85 86 public void testAllocateAndWriteBlock() throws RecordStoreException {87 final byte[] bytes = new byte[10];88 final INorFlashSectorState sector = mock(INorFlashSectorState.class);89 final Address address = Address.fromPrimitive(9);90 castHeap.currentSectorState = sector;91 castHeap.hasScannedBlocks = true;92 93 expects(new InThisOrder() {{94 one(sector).hasAvailable(NorFlashMemoryHeap.BLOCK_HEADER_SIZE + bytes.length + 2);will(returnValue(true));95 one(sector).getWriteHeadAddress();will(returnValue(address));96 one(sector).writeBytes(with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));97 one(sector).writeBytes(bytes, 0, bytes.length);98 one(sector).writeBytes(with(an(byte[].class)), with(equal(0)), with(equal((bytes.length & 1) + 2)));99 one(sector).incrementAllocatedBlockCount();100 one(sector).getStartAddress();will(returnValue(Address.zero()));101 }});102 103 Address mallocAddress = heap.allocateAndWriteBlock(bytes, 0, bytes.length, null);104 assertNotNull(mallocAddress);105 assertSame(address, mallocAddress);106 }107 /*108 * Write to an actual sector an verify that the bytes we are expecting are written109 */110 public void testAllocateAndWriteBlock2() throws RecordStoreException {111 final byte[] block = new byte[10];112 for (int i=0; i < block.length; i++) {113 block[i] = (byte) i;114 }115 final Address address = Address.fromPrimitive(9);116 final NorFlashSectorState sector = new NorFlashSectorState(new SimulatedNorFlashSector(address, 1024, 0, false));117 castHeap.currentSectorState = sector;118 castHeap.hasScannedBlocks = true;119 120 Address mallocAddress = heap.allocateAndWriteBlock(block, 0, block.length, null);121 byte[] bytes = new byte[sector.getWriteHeadPosition()];122 sector.flashSector.getBytes(0, bytes, 0, bytes.length);123 assertEquals(0, bytes[0]);124 assertEquals(0, bytes[1]);125 assertEquals(0, bytes[2]);126 assertEquals(block.length, bytes[3]);127 assertEquals((byte) 0xFF, bytes[4]);128 assertEquals((byte) 0xFF, bytes[5]);129 for (int i=0; i < block.length; i++) {130 assertEquals((byte) i, bytes[6+i]);131 }132 assertSame(address, mallocAddress);133 }134 135 /*136 * Test case of free block where the sector is not on the to be erased queue137 */138 public void testFreeBlockAt1() throws RecordStoreException {139 final INorFlashSectorState sector = mock(INorFlashSectorState.class);140 final Address address = Address.fromPrimitive(12);141 final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class);142 final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class);143 castHeap.sectorStates = new INorFlashSectorState[] {sector};144 castHeap.inUseSectorStateList = inUseList;145 castHeap.toBeErasedSectorStateList = toBeErasedList;146 castHeap.hasScannedBlocks = true;147 148 expects(new InAnyOrder() {{149 allowing(sector).getStartAddress();will(returnValue(Address.zero()));150 allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1024)));151 one(sector).writeBytes(with(equal(address.toUWord().toInt() + NorFlashMemoryHeap.BLOCK_HEADER_SIZE - 2)), with(an(byte[].class)), with(equal(0)), with(equal(2)));152 one(sector).decrementMallocedCount();153 one(sector).incrementFreedBlockCount();154 one(sector).getOwningList();will(returnValue(castHeap.toBeErasedSectorStateList));155 }});156 157 heap.freeBlockAt(address);158 }159 /*160 * Test case of free block where the sector is not on the to be erased queue and has no malloced blocks left161 */162 public void testFreeBlockAt2() throws RecordStoreException {163 final INorFlashSectorState sector = mock(INorFlashSectorState.class);164 final Address address = Address.fromPrimitive(12);165 final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class);166 final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class);167 castHeap.sectorStates = new INorFlashSectorState[] {sector};168 castHeap.inUseSectorStateList = inUseList;169 castHeap.toBeErasedSectorStateList = toBeErasedList;170 castHeap.hasScannedBlocks = true;171 expects(new InAnyOrder() {{172 allowing(sector).getStartAddress();will(returnValue(Address.zero()));173 allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1024)));174 one(sector).writeBytes(with(equal(address.toUWord().toInt() + NorFlashMemoryHeap.BLOCK_HEADER_SIZE - 2)), with(an(byte[].class)), with(equal(0)), with(equal(2)));175 one(sector).decrementMallocedCount();176 one(sector).incrementFreedBlockCount();177 one(sector).getOwningList();will(returnValue(castHeap.inUseSectorStateList));178 one(sector).getAllocatedBlockCount();will(returnValue(0));179 one(toBeErasedList).addLast(sector);180 }});181 182 heap.freeBlockAt(address);183 }184 // No sector contains the specified address185 public void testGetBlockAtAddress1() {186 final INorFlashSectorState sector = mock(INorFlashSectorState.class);187 castHeap.sectorStates = new INorFlashSectorState[] {sector};188 189 expects(new InThisOrder() {{190 one(sector).getStartAddress();will(returnValue(Address.fromPrimitive(1)));191 one(sector).getSize();will(returnValue(1));192 }});193 194 try {195 heap.getBlockAt(Address.zero());196 fail();197 } catch (RecordStoreException e) {198 }199 }200 201 public void testGetBlockAtAddress2(boolean blocksScanned) throws IOException, RecordStoreException {202 final INorFlashSectorState sector = mock(INorFlashSectorState.class);203 castHeap.sectorStates = new INorFlashSectorState[] {sector};204 205 expects(new InAnyOrder() {{206 allowing(sector).getStartAddress();will(returnValue(Address.zero()));207 allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1)));208 one(sector).getWriteHeadPosition();will(returnValue(0));209 }});210 IMemoryHeapBlock block = heap.getBlockAt(Address.zero());211 assertNull(block);212 }213 214 // Reading at or past the head position of the sector215 public void testGetBlockAtAddress2() throws IOException, RecordStoreException {216 testGetBlockAtAddress2(true);217 testGetBlockAtAddress2(false);218 }219 220 // testing of read block that is both smaller and larger than sectorSize. 221 public void testGetBlockAtAddress3(final int sectorSize, final int blockSize) throws IOException, RecordStoreException {222 final INorFlashSectorState sector = mock(INorFlashSectorState.class);223 castHeap.sectorStates = new INorFlashSectorState[] {sector};224 225 expects(new InAnyOrder() {{226 allowing(sector).getStartAddress();will(returnValue(Address.fromPrimitive(0)));227 allowing(sector).getEndAddress();will(returnValue(Address.zero().add(sectorSize)));228 one(sector).getWriteHeadPosition();will(returnValue(1));229 allowing(sector).getSize();will(returnValue(sectorSize));230 if (blockSize < sectorSize) {231 one(sector).readBytes(with(equal(0)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {232 public Object invoke(Invocation invocation) throws Throwable {233 ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();234 DataOutputStream dataOut = new DataOutputStream(bytesOut);235 dataOut.writeInt(blockSize);236 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);237 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);238 for (int i=0; i < blockSize; i++) {239 bytesOut.write(0);240 }241 System.arraycopy(bytesOut.toByteArray(), 0, (byte[]) invocation.getParameter(1), 0, NorFlashMemoryHeap.BLOCK_HEADER_SIZE);242 return null;243 }244 });245 one(sector).readBytes(with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)), with(an(byte[].class)), with(equal(0)), with(equal(blockSize + (blockSize & 1) + 2)));will(new CustomAction("") {246 public Object invoke(Invocation invocation) throws Throwable {247 byte[] bytes = ((byte[]) invocation.getParameter(1));248 int index = (Integer) invocation.getParameter(3);249 bytes[index-2] = NorFlashMemoryHeap.ERASED_VALUE_XOR;250 bytes[index-1] = NorFlashMemoryHeap.ERASED_VALUE_XOR;251 return null;252 }253 });254 }255 }});256 try {257 IMemoryHeapBlock block = heap.getBlockAt(Address.zero());258 if (blockSize >= sectorSize) {259 assertNull(block);260 } else {261 assertNotNull(block);262 assertEquals(blockSize, block.getLength());263 }264 } catch (RecordStoreException e) {265 if (blockSize < sectorSize) {266 fail();267 }268 }269 }270 271 // Block size read results in chunk larger than what is left in sector272 public void testGetBlockAtAddress3() throws IOException, RecordStoreException {273 testGetBlockAtAddress3(10, 1);274 testGetBlockAtAddress3(1, 10);275 }276 // address in a valid sector and not passed end of the sector's write head, so normal case277 public void testGetBlockAtAddress4() throws IOException, RecordStoreException {278 final INorFlashSectorState sector = mock(INorFlashSectorState.class);279 final int sectorSize = 1024;280 castHeap.sectorStates = new INorFlashSectorState[] {sector};281 282 expects(new InAnyOrder() {{283 allowing(sector).getStartAddress();will(returnValue(Address.zero()));284 allowing(sector).getEndAddress();will(returnValue(Address.zero().add(sectorSize)));285 one(sector).getWriteHeadPosition();will(returnValue(100));286 one(sector).readBytes(with(equal(0)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("copy bytes") {287 public Object invoke(Invocation invocation) throws Throwable {288 byte[] bytes = (byte[]) invocation.getParameter(1);289 bytes[0] = 0;290 bytes[1] = 0;291 bytes[2] = 0;292 bytes[3] = 0;293 bytes[4] = NorFlashMemoryHeap.ERASED_VALUE;294 bytes[5] = NorFlashMemoryHeap.ERASED_VALUE;295 return null;296 }297 });298 one(sector).readBytes(with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)), with(an(byte[].class)), with(equal(0)), with(equal(2)));will(new CustomAction("copy bytes") {299 public Object invoke(Invocation invocation) throws Throwable {300 byte[] bytes = (byte[]) invocation.getParameter(1);301 bytes[0] = NorFlashMemoryHeap.ERASED_VALUE_XOR;302 bytes[1] = NorFlashMemoryHeap.ERASED_VALUE_XOR;303 return null;304 }305 });306 allowing(sector).getSize();will(returnValue(sectorSize));307 }});308 IMemoryHeapBlock block = heap.getBlockAt(Address.zero());309 assertNotNull(block);310 assertNotNull(block.getAddress());311 }312 // encounter the erased value on reading the entry size, indicating the end block written to that sector313 public void testGetBlockAtSector1() throws RecordStoreException {314 final INorFlashSectorState sector = mock(INorFlashSectorState.class);315 final int offset = 10;316 final Address address = Address.fromPrimitive(11);317 318 expects(new InAnyOrder() {{319 one(sector).getSize();will(returnValue(1024));320 one(sector).getStartAddress();will(returnValue(address));321 one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {322 public Object invoke(Invocation invocation) throws Throwable {323 ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();324 DataOutputStream dataOut = new DataOutputStream(bytesOut);325 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);326 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);327 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);328 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);329 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);330 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);331 assertEquals(bytesOut.size(), NorFlashMemoryHeap.BLOCK_HEADER_SIZE);332 System.arraycopy(bytesOut.toByteArray(), 0, (byte[]) invocation.getParameter(1), 0, NorFlashMemoryHeap.BLOCK_HEADER_SIZE);333 return null;334 }335 });336 }});337 MemoryHeapBlock block = new MemoryHeapBlock();338 assertFalse(castHeap.getBlockAt(block, sector, offset));339 assertSame(address.add(offset), block.getAddress());340 }341 342 public void testGetBlockAtSector2() throws RecordStoreException {343 final INorFlashSectorState sector = mock(INorFlashSectorState.class);344 final int offset = 10;345 final MemoryHeapBlock block = new MemoryHeapBlock();346 final Address address = Address.fromPrimitive(11);347 final int sectorSize = 1024;348 expects(new InAnyOrder() {{349 one(sector).getSize();will(returnValue(sectorSize));350 one(sector).getStartAddress();will(returnValue(address));351 one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {352 public Object invoke(Invocation invocation) throws Throwable {353 block.setBytes(new byte[] {0, 0}, 0, 1);354 return null;355 }356 });357 }});358 try {359 castHeap.getBlockAt(block, sector, offset);360 fail();361 } catch (UnexpectedException e) {362 }363 }364 365 // Test the throwing of the RecordStoreException("This block did not finish being written") exception366 public void testGetBlockAtSector3() throws RecordStoreException {367 final INorFlashSectorState sector = mock(INorFlashSectorState.class);368 final int offset = 10;369 final MemoryHeapBlock block = new MemoryHeapBlock();370 final Address address = Address.fromPrimitive(11);371 final int sectorSize = 1024;372 373 expects(new InAnyOrder() {{374 one(sector).getSize();will(returnValue(sectorSize));375 one(sector).getStartAddress();will(returnValue(address));376 one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {377 public Object invoke(Invocation invocation) throws Throwable {378 ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();379 DataOutputStream dataOut = new DataOutputStream(bytesOut);380 dataOut.writeInt(0);381 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);382 dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);383 System.arraycopy(bytesOut.toByteArray(), 0, (byte[]) invocation.getParameter(1), 0, NorFlashMemoryHeap.BLOCK_HEADER_SIZE);384 return null;385 }386 });387 allowing(sector).getSize();will(returnValue(sectorSize));388 one(sector).readBytes(with(equal(offset + NorFlashMemoryHeap.BLOCK_HEADER_SIZE)), with(an(byte[].class)), with(equal(0)), with(equal(2)));will(new CustomAction("") {389 public Object invoke(Invocation invocation) throws Throwable {390 byte[] bytes = (byte []) invocation.getParameter(1);391 bytes[0] = NorFlashMemoryHeap.ERASED_VALUE;392 bytes[1] = NorFlashMemoryHeap.ERASED_VALUE;393 return null;394 }395 });396 }});397 try {398 castHeap.getBlockAt(block, sector, offset);399 assertFalse(block.isAllocated());400 } catch (RecordStoreException e) {401 fail();402 }403 }404 405 public void testGetSectorContaining(final int numSectors, final int sectorSize) {406 final Address[] addresses = new Address[numSectors];407 Address endAddress = Address.fromPrimitive(0);408 for (int i=0; i < numSectors; i++) {409 addresses[i] = endAddress;410 endAddress = endAddress.add(sectorSize);411 }412 final INorFlashSectorState[] sectors = new INorFlashSectorState[addresses.length];413 castHeap.sectorStates = sectors;414 expects(new InAnyOrder() {{415 for (int i=0; i < sectors.length; i++) {416 INorFlashSectorState sector = mock(INorFlashSectorState.class, "sector-" + i);417 sectors[i] = sector;418 allowing(sector).getStartAddress();will(returnValue(addresses[i]));419 allowing(sector).getEndAddress();will(returnValue(addresses[i].add(sectorSize)));420 }421 }});422 int max = endAddress.toUWord().toPrimitive();423 for (int i=0; i < max; i++) {424 INorFlashSectorState sector = castHeap.getSectorContaining(Address.fromPrimitive(i));425 int index = i / sectorSize;426 assertSame("index: " + i, sectors[index], sector);427 }428 assertNull(castHeap.getSectorContaining(Address.fromPrimitive(max)));429 assertNull(castHeap.getSectorContaining(Address.fromPrimitive(max + 1)));430 }431 432 public void testGetSectorContainingEven() {433 testGetSectorContaining(16, 10);434 }435 436 public void testGetSectorContainingOdd() {437 testGetSectorContaining(17, 10);438 }439 440 public void testGetSizeAvailable1() throws RecordStoreException {441 heap = castHeap;442 castHeap.hasScannedBlocks = true;443 castHeap.toBeErasedSectorStateList = mock(INorFlashSectorStateList.class);444 expects(new InThisOrder() {{445 INorFlashSectorState sector1 = mock(INorFlashSectorState.class);446 INorFlashSectorState sector2 = mock(INorFlashSectorState.class);447 castHeap.sectorStates = new INorFlashSectorState[] {sector1, sector2};448 one(sector1).getSequence();will(returnValue(1L));449 one(sector2).getSequence();will(returnValue(2L));450 one(sector1).hasErasedHeader();will(returnValue(false));451 one(castHeap.toBeErasedSectorStateList).addLast(sector1);452 one(sector2).hasErasedHeader();will(returnValue(false));453 one(castHeap.toBeErasedSectorStateList).addLast(sector2);454 one(sector1).getSize();will(returnValue(2));455 one(sector2).getSize();will(returnValue(10));456 }});457 458 int size = heap.getSizeAvailable();459 assertEquals(2 + 10, size);460 }461 462 public void testGetUserNorFlashSectors() {463 // TODO: Need to fix this test464 if (true) {465 return;466 }467 VM.getPeripheralRegistry().removeAll(INorFlashSector.class);468 assertSame(0, VM.getPeripheralRegistry().getAll(INorFlashSector.class).length);469 final INorFlashSector sector1 = mock(INorFlashSector.class);470 final INorFlashSector sector2 = mock(INorFlashSector.class);471 final INorFlashSector sector3 = mock(INorFlashSector.class);472 expects(new InAnyOrder() {{473 allowing(sector1).getPurpose(); will(returnValue(INorFlashSector.RMS_PURPOSED));474 allowing(sector2).getPurpose(); will(returnValue(INorFlashSector.SYSTEM_PURPOSED));475 allowing(sector3).getPurpose(); will(returnValue(INorFlashSector.RMS_PURPOSED));476 }});477// VM.getPeripheralRegistry().add(sector1);478// VM.getPeripheralRegistry().add(sector2);479// VM.getPeripheralRegistry().add(sector3);480 481 Vector<?> sectors = NorFlashMemoryHeap.getNorFlashSectors(INorFlashSector.RMS_PURPOSED);482 assertSame(2, sectors.size());483 assertTrue(sectors.indexOf(sector1) >= 0);484 assertTrue(sectors.indexOf(sector3) >= 0);485 486 VM.getPeripheralRegistry().removeAll(INorFlashSector.class);487 }488 489 public void testIncrementErasedSequence() {490 assertEquals(0, castHeap.erasedSequenceCurrentValue);491 assertEquals(1, castHeap.incrementErasedSequence());492 assertEquals(1, castHeap.erasedSequenceCurrentValue);493 }494 495 public void testInit() {496 final INorFlashSectorState sector1 = mock(INorFlashSectorState.class);497 final INorFlashSectorState sector2 = mock(INorFlashSectorState.class);498 final INorFlashSectorState sector3 = mock(INorFlashSectorState.class);499 final INorFlashSectorState sector4 = mock(INorFlashSectorState.class);500 INorFlashSectorState[] sectors = new INorFlashSectorState[] {sector4, sector3, sector2, sector1};501 502 expects(new InAnyOrder() {{503 allowing(sector1).getStartAddress();will(returnValue(Address.fromPrimitive(1)));504 allowing(sector1).getSequence();will(returnValue(1L));505 allowing(sector2).getStartAddress();will(returnValue(Address.fromPrimitive(2)));506 allowing(sector2).getSequence();will(returnValue(2L));507 allowing(sector3).getStartAddress();will(returnValue(Address.fromPrimitive(3)));508 allowing(sector3).getSequence();will(returnValue(3L));509 allowing(sector4).getStartAddress();will(returnValue(Address.fromPrimitive(4)));510 allowing(sector4).getSequence();will(returnValue(3L));511 }});512 513 castHeap.init(sectors);514 assertSame(sectors, castHeap.sectorStates);515 assertSame(castHeap.sectorStates[0], sector1);516 assertSame(castHeap.sectorStates[1], sector2);517 assertSame(castHeap.sectorStates[2], sector3);518 assertSame(castHeap.sectorStates[3], sector4);519 assertSame(0, castHeap.erasedSequenceCurrentValue);520 assertNotNull(castHeap.inUseSectorStateList);521 assertNotNull(castHeap.toBeErasedSectorStateList);522 }523 /*524 * currentSector not null and has room525 */526 public void testMakeRoomToWrite1() throws RecordStoreException {527 final INorFlashSectorState sector = mock(INorFlashSectorState.class);528 castHeap.currentSectorState = sector;529 530 expects(new InThisOrder() {{531 one(sector).hasAvailable(with(an(Integer.class)));will(returnValue(true));532 }});533 534 castHeap.makeRoomToWrite(0, null);535 assertSame(sector, castHeap.currentSectorState);536 }537 538 /*539 * currentSector does not have room, test which queue it gets put into540 */541 public void testMakeRoomToWrite2() throws RecordStoreException {542 final INorFlashSectorState sector = mock(INorFlashSectorState.class);543 final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class);544 final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class);545 castHeap.sectorStates = new INorFlashSectorState[] {sector};546 castHeap.currentSectorState = sector;547 castHeap.inUseSectorStateList = inUseList;548 castHeap.toBeErasedSectorStateList = toBeErasedList;549 castHeap.hasScannedBlocks = true;550 551 expects(new InThisOrder() {{552 one(sector).hasAvailable(with(an(Integer.class)));will(returnValue(false));553 one(sector).getAllocatedBlockCount();will(returnValue(0));554 one(toBeErasedList).addLast(sector);555 one(toBeErasedList).consumeFirst();will(returnValue(null));556 }});557 558 try {559 castHeap.makeRoomToWrite(0, null);560 fail();561 } catch (RecordStoreFullException e) {562 }563 assertNull(castHeap.currentSectorState);564 castHeap.currentSectorState = sector;565 566 expects(new InThisOrder() {{567 one(sector).hasAvailable(with(an(Integer.class)));will(returnValue(false));568 one(sector).getAllocatedBlockCount();will(returnValue(1));569 one(inUseList).addLast(sector);570 one(toBeErasedList).consumeFirst();will(returnValue(null));571 }});572 573 try {574 castHeap.makeRoomToWrite(0, null);575 fail();576 } catch (RecordStoreFullException e) {577 }578 assertNull(castHeap.currentSectorState);579}580 581 public void testMakeRoomToWrite4() throws RecordStoreException {582 final INorFlashSectorState sector1 = mock(INorFlashSectorState.class, "sector1");583 final INorFlashSectorState sector2 = mock(INorFlashSectorState.class, "sector2");584 castHeap.sectorStates = new INorFlashSectorState[] {sector1, sector2};585 castHeap.currentSectorState = sector1;586 castHeap.toBeErasedSectorStateList = mock(INorFlashSectorStateList.class);587 588 expects(new InAnyOrder() {{589 one(sector1).hasAvailable(0);will(returnValue(false));590 one(sector1).getAllocatedBlockCount();will(returnValue(0));591 one(castHeap.toBeErasedSectorStateList).addLast(sector1);592 one(castHeap.toBeErasedSectorStateList).size();will(returnValue(2));593 one(castHeap.toBeErasedSectorStateList).consumeFirst();will(returnValue(sector2));594 one(sector2).erase(1L);595 one(sector2).hasAvailable(with(an(Integer.class)));will(returnValue(true));596 }});597 598 castHeap.makeRoomToWrite(0, null);599 assertSame(sector2, castHeap.currentSectorState);600 }601 602 /*603 * None of the sectors need to be erased, and current does not have room604 */605 public void testMakeRoomToWrite5() throws RecordStoreException {606 final INorFlashSectorState sector1 = mock(INorFlashSectorState.class, "sector1");607 final INorFlashSectorState sector2 = mock(INorFlashSectorState.class, "sector2");608 castHeap.sectorStates = new INorFlashSectorState[] {sector1, sector2};609 castHeap.currentSectorState = sector1;610 castHeap.toBeErasedSectorStateList = mock(INorFlashSectorStateList.class);611 612 expects(new InAnyOrder() {{613 one(sector1).hasAvailable(0);will(returnValue(false));614 one(sector1).getAllocatedBlockCount();will(returnValue(0));615 one(castHeap.toBeErasedSectorStateList).addLast(sector1);616 one(castHeap.toBeErasedSectorStateList).size();will(returnValue(2));617 one(castHeap.toBeErasedSectorStateList).consumeFirst();will(returnValue(sector2));618 one(sector2).erase(1L);619 one(sector2).hasAvailable(0);will(returnValue(false));620 one(sector2).getSize();will(returnValue(0));621 }});622 623 try {624 castHeap.makeRoomToWrite(0, null);625 fail();626 } catch (RecordStoreFullException e) {627 }628 assertSame(sector2, castHeap.currentSectorState);629 }630 /*631 * test scanBlocks()632 */633 public void testScanBlocks() throws RecordStoreException {634 final boolean[] calledScanBlocksHandle = new boolean[1];635 castHeap = new NorFlashMemoryHeap() {636 @Override637 public void scanBlocks(INorFlashMemoryHeapScanner scanner) throws RecordStoreException {638 assertNull(scanner);639 calledScanBlocksHandle[0] = true;640 }641 };642 heap = castHeap;643 644 castHeap.scanBlocks(null);645 assertTrue(calledScanBlocksHandle[0]);646 }647 648 /*649 * 650 */651 public void testScanBlocksWithScanner() throws RecordStoreException {652 final INorFlashSectorState sector1 = mock(INorFlashSectorState.class, "sector1");653 final INorFlashSectorState sector2 = mock(INorFlashSectorState.class, "sector2");654 final INorFlashSectorState sector3 = mock(INorFlashSectorState.class, "sector3");655 // key: put them in a different order, so that we can test outcome of sort happening in scan656 INorFlashSectorState[] sectors = new INorFlashSectorState[] {sector3, sector2, sector1};657 final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class, "inUse");658 final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class, "toBeErased");659 final byte[] sampleBytes = new byte[] {0, 1, 2, 3};660 castHeap = new NorFlashMemoryHeap() {661 @Override662 protected boolean getBlockAt(IMemoryHeapBlock block, INorFlashSectorState sector, int offset) throws RecordStoreException {663 if (offset == 0) {664 block.setIsAllocated(false);665 block.setNextOffset(1);666 } else if (offset == 1) {667 block.setIsAllocated(true);668 block.setBytes(sampleBytes, 0, sampleBytes.length);669 block.setNextOffset(2);670 } else {671 return false;672 }673 return true;674 }675 };676 heap = castHeap;677 castHeap.sectorStates = sectors;678 castHeap.inUseSectorStateList = inUseList;679 castHeap.toBeErasedSectorStateList = toBeErasedList;680 681 expects(new InThisOrder() {{682 expects(new InAnyOrder() {{683 allowing(sector1).getSequence();will(returnValue(1L));684 allowing(sector2).getSequence();will(returnValue(2L));685 allowing(sector3).getSequence();will(returnValue(3L));686 }});687 one(sector1).hasErasedHeader();will(returnValue(false));688 one(toBeErasedList).addLast(sector1);689 one(sector2).hasErasedHeader();will(returnValue(true));690 one(sector2).resetHead();691 one(sector2).getWriteHeadPosition();will(returnValue(0));692 one(sector2).incrementFreedBlockCount();693 one(sector2).incrementAllocatedBlockCount();694 one(sector2).setWriteHeadPosition(2);695 one(sector2).getAllocatedBlockCount();will(returnValue(1));696 one(inUseList).addLast(sector2);697 one(sector3).hasErasedHeader();will(returnValue(true));698 one(sector3).resetHead();699 one(sector3).getWriteHeadPosition();will(returnValue(0));700 one(sector3).incrementFreedBlockCount();701 one(sector3).incrementAllocatedBlockCount();702 one(sector3).setWriteHeadPosition(2);703 one(sector3).getAllocatedBlockCount();will(returnValue(0));704 one(toBeErasedList).addLast(sector3);705 }});706 INorFlashMemoryHeapScanner scanner = new INorFlashMemoryHeapScanner() {707 public void reScanBlock(Address oldAddress, Address newAddress, IMemoryHeapBlock block) throws RecordStoreException {708 fail();709 }710 public void scanBlock(IMemoryHeapBlock block) throws RecordStoreException {711 for (int i=0; i < block.getLength(); i++) {712 assertEquals(sampleBytes[i], block.getBytes()[block.getOffset() + i]);713 }714 }715 };716 castHeap.scanBlocks(scanner);717 }718 719 // TODO More testWriteBlock tests720 // - add a test that ensures that the oldAddress is freed721 // - test the odd even handling to make sure it writes into correct part of byte array722 /**723 * Case where oldAddress is zero, indicating we are inserting new data724 *725 */726 public void testWriteBlock1() throws RecordStoreException {727 final INorFlashSectorState sectorState = mock(INorFlashSectorState.class);728 final INorFlashMemoryHeapScanner scanner = mock(INorFlashMemoryHeapScanner.class);729 final byte[] bytes = new byte[0];730 final Address oldAddress = Address.zero();731 castHeap.currentSectorState = sectorState;732 castHeap.hasScannedBlocks = true;733 734 expects(new InThisOrder() {{735 one(sectorState).hasAvailable(8);will(returnValue(true));736 one(sectorState).getWriteHeadAddress();will(returnValue(Address.zero()));737 one(sectorState).writeBytes(with(an(byte[].class)), with(equal(0)), with(equal(6)));738 one(sectorState).writeBytes(bytes, 0, bytes.length);739 one(sectorState).writeBytes(with(an(byte[].class)), with(equal(0)), with(equal(2)));740 one(sectorState).incrementAllocatedBlockCount();741 one(sectorState).getStartAddress();will(returnValue(Address.zero()));742 }});743 744 MemoryHeapBlock block = new MemoryHeapBlock();745 block.setBytes(bytes, 0, 0);746 try {747 castHeap.writeBlock(block, scanner, oldAddress);748 assertSame(Address.zero(), block.getAddress());749 } catch (RecordStoreException e) {750 fail();751 }752 }753}...
Source:MockObjectTestCase.java
...134 * The name of the state machine.135 * @return136 * A new state machine with the given name.137 */138 public States states(String name) {139 return context.states(name);140 }141}...
states
Using AI Code Generation
1package org.jmock.test.acceptance.junit3;2import junit.framework.TestCase;3import org.jmock.Mock;4import org.jmock.MockObjectTestCase;5import org.jmock.core.Stub;6import org.jmock.core.constraint.IsEqual;7import org.jmock.core.constraint.IsSame;8import org.jmock.core.stub.ReturnStub;9import org.jmock.core.stub.ThrowStub;10import org.jmock.test.acceptance.junit3.testdata.SimpleInterface;11public class StatesAcceptanceTest extends MockObjectTestCase {12 public void testCanUseStatesToControlStubbing() {13 Mock mock = mock(SimpleInterface.class);14 SimpleInterface si = (SimpleInterface) mock.proxy();15 mock.expects(atLeastOnce()).method("doSomething").withNoArguments().will(returnValue("foo"));16 mock.expects(atLeastOnce()).method("doSomething").withNoArguments().will(returnValue("bar"));17 mock.expects(atLeastOnce()).method("doSomethingElse").withNoArguments().will(returnValue("baz"));18 mock.states("foo", "bar", "baz");19 assertEquals("foo", si.doSomething());20 assertEquals("bar", si.doSomething());21 assertEquals("baz", si.doSomethingElse());22 assertEquals("foo", si.doSomething());23 assertEquals("bar", si.doSomething());24 assertEquals("baz", si.doSomethingElse());25 }26}27package org.jmock.test.acceptance.junit3;28import junit.framework.TestCase;29import org.jmock.Mock;30import org.jmock.MockObjectTestCase;31import org.jmock.core.Stub;32import org.jmock.core.constraint.IsEqual;33import org.jmock.core.constraint.IsSame;34import org.jmock.core.stub.ReturnStub;35import org.jmock.core.stub.ThrowStub;36import org.jmock.test.acceptance.junit3.testdata.SimpleInterface;37public class StatesAcceptanceTest extends MockObjectTestCase {38 public void testCanUseStatesToControlStubbing() {39 Mock mock = mock(SimpleInterface.class);40 SimpleInterface si = (SimpleInterface) mock.proxy();41 mock.expects(atLeastOnce()).method("doSomething").withNoArguments().will(returnValue("foo"));42 mock.expects(atLeastOnce()).method("doSomething").withNoArguments().will(returnValue("bar"));43 mock.expects(atLeastOnce()).method("doSomethingElse").withNo
states
Using AI Code Generation
1package org.jmock.test.acceptance.junit3;2import junit.framework.*;3import org.jmock.*;4import org.jmock.core.*;5import org.jmock.core.constraint.*;6import org.jmock.core.matcher.*;7import org.jmock.core.stub.*;8import org.jmock.test.acceptance.*;9{10 public static void main(String[] args) {11 junit.textui.TestRunner.run(suite());12 }13 public static Test suite() {14 return new TestSuite(StatesAcceptanceTests_1.class);15 }16 public void testStates() {17 Mock mock = mock(TestedClass.class);18 mock.expects(once()).method("doSomething").will(returnValue("one"));19 mock.expects(once()).method("doSomething").will(returnValue("two"));20 mock.expects(once()).method("doSomething").will(returnValue("three"));21 TestedClass tested = (TestedClass)mock.proxy();22 assertEquals("one", tested.doSomething());23 assertEquals("two", tested.doSomething());24 assertEquals("three", tested.doSomething());25 }26}27package org.jmock.test.acceptance;28{29 public String doSomething();30}31package org.jmock.test.acceptance;32{33 public String doSomething() {34 return "default";35 }36}37package org.jmock.test.acceptance;38import junit.framework.*;39import org.jmock.*;40import org.jmock.core.*;41import org.jmock.core.constraint.*;42import org.jmock.core.matcher.*;43import org.jmock.core.stub.*;44import org.jmock.test.acceptance.*;45{46 public static void main(String[] args) {47 junit.textui.TestRunner.run(suite());48 }49 public static Test suite() {50 return new TestSuite(StatesAcceptanceTests_2.class);51 }52 public void testStates() {53 Mock mock = mock(TestedClass.class);54 mock.expects(once()).method("doSomething").will(returnValue("one"));55 mock.expects(once()).method("doSomething").will(returnValue("two"));56 mock.expects(once()).method("doSomething").will(returnValue("three"));57 TestedClass tested = (TestedClass)mock.proxy();58 assertEquals("
states
Using AI Code Generation
1package org.jmock.test.acceptance.junit3;2import org.jmock.Mock;3import org.jmock.MockObjectTestCase;4import org.jmock.core.Invocation;5import org.jmock.core.Stub;6import org.jmock.core.StubSequence;7import org.jmock.core.stub.StubSequenceBuilder;8public class MockObjectTestCaseAcceptanceTests extends MockObjectTestCase {9 public interface MyInterface {10 public void doSomething();11 }12 public void testCanCreateMockObjects() {13 Mock mock = mock(MyInterface.class);14 assertSame("should have created a mock object", MyInterface.class, mock15 .proxy().getClass().getInterfaces()[0]);16 }17 public void testCanSetExpectations() {18 Mock mock = mock(MyInterface.class);19 mock.expects(once()).method("doSomething");20 MyInterface myInterface = (MyInterface) mock.proxy();21 myInterface.doSomething();22 }23 public void testCanSetExpectationsWithArguments() {24 Mock mock = mock(MyInterface.class);25 mock.expects(once()).method("doSomething").with(eq("arg"));26 MyInterface myInterface = (MyInterface) mock.proxy();27 myInterface.doSomething("arg");28 }29 public void testCanSetExpectationsWithAnyArguments() {30 Mock mock = mock(MyInterface.class);31 mock.expects(once()).method("doSomething").with(anything());32 MyInterface myInterface = (MyInterface) mock.proxy();33 myInterface.doSomething("arg");34 }35 public void testCanSetExpectationsWithArgumentsThatMatch() {36 Mock mock = mock(MyInterface.class);37 mock.expects(once()).method("doSomething").with(match(new org.jmock.core.matcher.StringContains("arg")));38 MyInterface myInterface = (MyInterface) mock.proxy();39 myInterface.doSomething("argument");40 }41 public void testCanSetExpectationsWithArgumentsThatMatchUsingCustomMatcher() {42 Mock mock = mock(MyInterface.class);43 mock.expects(once()).method("doSomething").with(match(new org.jmock.core.matcher.CustomMatcher("contains") {44 protected boolean matches(Object arg) {45 return arg.toString().indexOf("arg") >= 0;46 }47 }));48 MyInterface myInterface = (MyInterface) mock.proxy();49 myInterface.doSomething("argument");50 }
states
Using AI Code Generation
1import junit.framework.TestCase;2import org.jmock.Mock;3import org.jmock.MockObjectTestCase;4import org.jmock.core.Constraint;5import org.jmock.core.constraint.IsEqual;6import org.jmock.core.constraint.IsAnything;7import org.jmock.core.constraint.IsSame;8import org.jmock.core.constraint.IsInstanceOf;9import org.jmock.core.constraint.IsIn;10import org.jmock.core.constraint.IsNot;11import org.jmock.core.constraint.IsNotSame;12import org.jmock.core.constraint.IsCollectionContaining;13import org.jmock.core.constraint.IsStringStarting;14import org.jmock.core.constraint.IsStringEnding;15import org.jmock.core.constraint.IsStringContaining;16import org.jmock.core.constraint.IsStringMatching;17import org.jmock.core.constraint.IsCompatibleType;18import org.jmock.core.constraint.IsLessThan;19import org.jmock.core.constraint.IsGreaterThan;20import org.jmock.core.constraint.IsLessThanOrEqualTo;21import org.jmock.core.constraint.IsGreaterThanOrEqualTo;22import org.jmock.core.constraint.IsCloseTo;23import org.jmock.core.constraint.IsWithin;24import org.jmock.core.constraint.IsBetween;25import org.jmock.core.constraint.IsIdentical;26import org.jmock.core.constraint.IsUnique;27import org.jmock.core.constraint.IsMapContaining;28import org.jmock.core.constraint.IsCollectionContainingAll;29import org.jmock.core.constraint.IsCollectionContainingAny;30import org.jmock.core.constraint.IsCollectionContainingNone;31import org.jmock.core.constraint.IsCollectionContainingOnly;32import org.jmock.core.constraint.IsCollectionEmpty;33import org.jmock.core.constraint.IsCollectionNotEmpty;34import org.jmock.core.constraint.IsCollectionSize;35import org.jmock.core.constraint.IsArrayContaining;36import org.jmock.core.constraint.IsArrayContainingAll;37import org.jmock.core.constraint.IsArrayContainingAny;38import org.jmock.core.constraint.IsArrayContainingNone;39import org.jmock.core.constraint.IsArrayContainingOnly;40import org.jmock.core.constraint.IsArrayEmpty;41import org.jmock.core.constraint.IsArrayNotEmpty;42import org.jmock.core.constraint.IsArraySize;43import org.jmock.core.constraint.IsSameAs;44import org.jmock.core.constraint.IsNotSameAs;45import org.jmock.core.constraint.IsEqualIgnoringCase;46import org.jmock.core.constraint.IsEqualIncludingLineBreaks;47import org.jmock.core.constraint.IsEqualTrimmingWhiteSpace;48import org.jmock.core.constraint.IsEqualCompressingWhiteSpace;49import org.jmock.core.constraint.IsEqualNormalizingWhitespace;50import org
states
Using AI Code Generation
1package org.jmock.examples.state;2import org.jmock.Mock;3import org.jmock.MockObjectTestCase;4public class StateTest extends MockObjectTestCase {5 public void testState() {6 Mock mock = mock(ExampleInterface.class);7 mock.expects(once()).method("doSomething").will(returnValue("something"));8 mock.expects(once()).method("doSomething").will(returnValue("something else"));9 ExampleInterface example = (ExampleInterface) mock.proxy();10 assertEquals("something", example.doSomething());11 assertEquals("something else", example.doSomething());12 }13 public interface ExampleInterface {14 public String doSomething();15 }16}17package org.jmock.examples.state;18import org.jmock.Mock;19import org.jmock.MockObjectTestCase;20public class StateTest extends MockObjectTestCase {21 public void testState() {22 Mock mock = mock(ExampleInterface.class);23 mock.stubs().method("doSomething").will(returnValue("something"));24 mock.stubs().method("doSomething").will(returnValue("something else"));25 ExampleInterface example = (ExampleInterface) mock.proxy();26 assertEquals("something", example.doSomething());27 assertEquals("something else", example.doSomething());28 }29 public interface ExampleInterface {30 public String doSomething();31 }32}33package org.jmock.examples.state;34import org.jmock.Mock;35import org.jmock.MockObjectTestCase;36public class StateTest extends MockObjectTestCase {37 public void testState() {38 Mock mock = mock(ExampleInterface.class);39 mock.expects(once()).method("doSomething").will(returnValue("something"));40 mock.expects(once()).method("doSomething").will(returnValue("something else"));41 ExampleInterface example = (ExampleInterface) mock.proxy();42 assertEquals("something", example.doSomething());43 assertEquals("something else", example.doSomething());44 }45 public interface ExampleInterface {46 public String doSomething();47 }48}49package org.jmock.examples.state;50import org.jmock.Mock;51import org.jmock.MockObjectTestCase;52public class StateTest extends MockObjectTestCase {
states
Using AI Code Generation
1package org.jmock.example;2import org.jmock.Mock;3import org.jmock.MockObjectTestCase;4import org.jmock.core.Stub;5import org.jmock.core.constraint.IsEqual;6import org.jmock.core.constraint.IsSame;7import org.jmock.core.stub.ReturnStub;8import org.jmock.core.stub.ThrowStub;9public class MockObjectTestCaseTest extends MockObjectTestCase {10 public void testStates() {11 Mock mock = mock(Interface.class);12 mock.stubs().method("greeting").with(new IsSame("Hello")).will(13 new ReturnStub("Hello"));14 mock.stubs().method("greeting").with(new IsEqual("Hi")).will(15 new ReturnStub("Hi"));16 mock.stubs().method("greeting").with(new IsEqual("Bye")).will(17 new ThrowStub(new RuntimeException("Bye")));18 mock.stubs().method("greeting").will(new ReturnStub("Goodbye"));19 Interface i = (Interface) mock.proxy();20 assertEquals("Hello", i.greeting("Hello"));21 assertEquals("Hi", i.greeting("Hi"));22 try {23 i.greeting("Bye");24 fail("Should have thrown an exception");25 } catch (RuntimeException e) {26 assertEquals("Bye", e.getMessage());27 }28 assertEquals("Goodbye", i.greeting("anything"));29 }30 public void testStub() {31 Mock mock = mock(Interface.class);32 Stub stub = new Stub() {33 public Object invoke(org.jmock.core.Invocation invocation)34 throws Throwable {35 return invocation.parameterValues.get(0);36 }37 };38 mock.stubs().method("greeting").will(stub);39 Interface i = (Interface) mock.proxy();40 assertEquals("Hello",
states
Using AI Code Generation
1import org.jmock.integration.junit3.MockObjectTestCase;2import org.jmock.Mock;3import org.jmock.Expectations;4{5 public void test1()6 {7 final Class1 mockClass1 = mock(Class1.class);8 final Class2 mockClass2 = mock(Class2.class);9 final Class3 mockClass3 = mock(Class3.class);10 final Class4 mockClass4 = mock(Class4.class);11 final Class5 mockClass5 = mock(Class5.class);12 final Class6 mockClass6 = mock(Class6.class);13 final Class7 mockClass7 = mock(Class7.class);14 final Class8 mockClass8 = mock(Class8.class);15 final Class9 mockClass9 = mock(Class9.class);16 final Class10 mockClass10 = mock(Class10.class);17 final Class11 mockClass11 = mock(Class11.class);18 final Class12 mockClass12 = mock(Class12.class);19 final Class13 mockClass13 = mock(Class13.class);20 final Class14 mockClass14 = mock(Class14.class);21 final Class15 mockClass15 = mock(Class15.class);22 final Class16 mockClass16 = mock(Class16.class);23 final Class17 mockClass17 = mock(Class17.class);24 final Class18 mockClass18 = mock(Class18.class);25 final Class19 mockClass19 = mock(Class19.class);26 final Class20 mockClass20 = mock(Class20.class);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!