本文整理汇总了Java中org.jmock.InAnyOrder类的典型用法代码示例。如果您正苦于以下问题:Java InAnyOrder类的具体用法?Java InAnyOrder怎么用?Java InAnyOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InAnyOrder类属于org.jmock包,在下文中一共展示了InAnyOrder类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCheckMIDletVersion
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testCheckMIDletVersion() throws RecordStoreException {
final String midletName = "name";
final String midletVendor = "vendor";
final String midletVersion = "version";
assertNotNull(castManager.checkMIDletVersion(midletName, midletVendor, midletVersion));
final IApplicationDescriptorEntry applicationEntry = mock(IApplicationDescriptorEntry.class);
castManager.currentApplicationDescriptor = applicationEntry;
expects(new InAnyOrder() {{
allowing(applicationEntry).getMidletName();will(returnValue(midletName));
allowing(applicationEntry).getMidletVendor();will(returnValue(midletVendor));
allowing(applicationEntry).getMidletVersion();will(returnValue(midletVersion));
}});
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, midletVersion));
assertNotNull(castManager.checkMIDletVersion(null, null, null));
assertNotNull(castManager.checkMIDletVersion(midletName, null, null));
assertNotNull(castManager.checkMIDletVersion(midletName, midletVendor, null));
assertNotNull(castManager.checkMIDletVersion(null, midletVendor, midletVersion));
assertNotNull(castManager.checkMIDletVersion(midletName, null, midletVersion));
assertNotNull(castManager.checkMIDletVersion(midletName, midletVendor, null));
assertNotNull(castManager.checkMIDletVersion(null, null, midletVersion));
}
示例2: testFreeBlockAt1
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testFreeBlockAt1() throws RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
final Address address = Address.fromPrimitive(12);
final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class);
final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class);
castHeap.sectorStates = new INorFlashSectorState[] {sector};
castHeap.inUseSectorStateList = inUseList;
castHeap.toBeErasedSectorStateList = toBeErasedList;
castHeap.hasScannedBlocks = true;
expects(new InAnyOrder() {{
allowing(sector).getStartAddress();will(returnValue(Address.zero()));
allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1024)));
one(sector).writeBytes(with(equal(address.toUWord().toInt() + NorFlashMemoryHeap.BLOCK_HEADER_SIZE - 2)), with(an(byte[].class)), with(equal(0)), with(equal(2)));
one(sector).decrementMallocedCount();
one(sector).incrementFreedBlockCount();
one(sector).getOwningList();will(returnValue(castHeap.toBeErasedSectorStateList));
}});
heap.freeBlockAt(address);
}
示例3: testFreeBlockAt2
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testFreeBlockAt2() throws RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
final Address address = Address.fromPrimitive(12);
final INorFlashSectorStateList inUseList = mock(INorFlashSectorStateList.class);
final INorFlashSectorStateList toBeErasedList = mock(INorFlashSectorStateList.class);
castHeap.sectorStates = new INorFlashSectorState[] {sector};
castHeap.inUseSectorStateList = inUseList;
castHeap.toBeErasedSectorStateList = toBeErasedList;
castHeap.hasScannedBlocks = true;
expects(new InAnyOrder() {{
allowing(sector).getStartAddress();will(returnValue(Address.zero()));
allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1024)));
one(sector).writeBytes(with(equal(address.toUWord().toInt() + NorFlashMemoryHeap.BLOCK_HEADER_SIZE - 2)), with(an(byte[].class)), with(equal(0)), with(equal(2)));
one(sector).decrementMallocedCount();
one(sector).incrementFreedBlockCount();
one(sector).getOwningList();will(returnValue(castHeap.inUseSectorStateList));
one(sector).getAllocatedBlockCount();will(returnValue(0));
one(toBeErasedList).addLast(sector);
}});
heap.freeBlockAt(address);
}
示例4: testGetBlockAtSector2
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testGetBlockAtSector2() throws RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
final int offset = 10;
final MemoryHeapBlock block = new MemoryHeapBlock();
final Address address = Address.fromPrimitive(11);
final int sectorSize = 1024;
expects(new InAnyOrder() {{
one(sector).getSize();will(returnValue(sectorSize));
one(sector).getStartAddress();will(returnValue(address));
one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {
public Object invoke(Invocation invocation) throws Throwable {
block.setBytes(new byte[] {0, 0}, 0, 1);
return null;
}
});
}});
try {
castHeap.getBlockAt(block, sector, offset);
fail();
} catch (UnexpectedException e) {
}
}
示例5: testMakeRoomToWrite4
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testMakeRoomToWrite4() throws RecordStoreException {
final INorFlashSectorState sector1 = mock(INorFlashSectorState.class, "sector1");
final INorFlashSectorState sector2 = mock(INorFlashSectorState.class, "sector2");
castHeap.sectorStates = new INorFlashSectorState[] {sector1, sector2};
castHeap.currentSectorState = sector1;
castHeap.toBeErasedSectorStateList = mock(INorFlashSectorStateList.class);
expects(new InAnyOrder() {{
one(sector1).hasAvailable(0);will(returnValue(false));
one(sector1).getAllocatedBlockCount();will(returnValue(0));
one(castHeap.toBeErasedSectorStateList).addLast(sector1);
one(castHeap.toBeErasedSectorStateList).size();will(returnValue(2));
one(castHeap.toBeErasedSectorStateList).consumeFirst();will(returnValue(sector2));
one(sector2).erase(1L);
one(sector2).hasAvailable(with(an(Integer.class)));will(returnValue(true));
}});
castHeap.makeRoomToWrite(0, null);
assertSame(sector2, castHeap.currentSectorState);
}
示例6: testMakeRoomToWrite5
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testMakeRoomToWrite5() throws RecordStoreException {
final INorFlashSectorState sector1 = mock(INorFlashSectorState.class, "sector1");
final INorFlashSectorState sector2 = mock(INorFlashSectorState.class, "sector2");
castHeap.sectorStates = new INorFlashSectorState[] {sector1, sector2};
castHeap.currentSectorState = sector1;
castHeap.toBeErasedSectorStateList = mock(INorFlashSectorStateList.class);
expects(new InAnyOrder() {{
one(sector1).hasAvailable(0);will(returnValue(false));
one(sector1).getAllocatedBlockCount();will(returnValue(0));
one(castHeap.toBeErasedSectorStateList).addLast(sector1);
one(castHeap.toBeErasedSectorStateList).size();will(returnValue(2));
one(castHeap.toBeErasedSectorStateList).consumeFirst();will(returnValue(sector2));
one(sector2).erase(1L);
one(sector2).hasAvailable(0);will(returnValue(false));
one(sector2).getSize();will(returnValue(0));
}});
try {
castHeap.makeRoomToWrite(0, null);
fail();
} catch (RecordStoreFullException e) {
}
assertSame(sector2, castHeap.currentSectorState);
}
示例7: testCheckMIDletVersionUpgrade
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testCheckMIDletVersionUpgrade() throws RecordStoreException {
final String midletName = "name";
final String midletVendor = "vendor";
final String[] midletVersionHandle = new String[] {""};
final IApplicationDescriptorEntry applicationEntry = mock(IApplicationDescriptorEntry.class);
castManager.currentApplicationDescriptor = applicationEntry;
expects(new InAnyOrder() {{
allowing(applicationEntry).getMidletName();will(returnValue(midletName));
allowing(applicationEntry).getMidletVendor();will(returnValue(midletVendor));
allowing(applicationEntry).getMidletVersion();will(new CustomAction("getMidletVersion") {
public Object invoke(Invocation invocation) throws Throwable {
return midletVersionHandle[0];
}
});
}});
midletVersionHandle[0] = "1.0";
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.0"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1.1"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.00"));
midletVersionHandle[0] = "1.1";
assertNotNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.0"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.2"));
assertNull(castManager.checkMIDletVersion(midletName, midletVendor, "1.1.1"));
}
示例8: testGetRecordStoreByName3
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testGetRecordStoreByName3() throws IOException, RecordStoreException {
final IRecordStoreEntry recordStore = mock(IRecordStoreEntry.class);
final String name = "name";
final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
final INorFlashMemoryHeapScanner heapScanner = mock(INorFlashMemoryHeapScanner.class);
castManager.currentRecordStores = new IRecordStoreEntry[] {null, recordStore};
castManager.memoryHeap = heap;
castManager.memoryHeapScanner = heapScanner;
expects(new InAnyOrder() {{
exactly(2).of(recordStore).getName();will(returnValue(name));
exactly(2).of(heap).allocateAndWriteBlock(with(an(byte[].class)), with(an(Integer.class)), with(an(Integer.class)), with(same(heapScanner)));
}});
// No need to grow entries
String notThereName = "not-there";
IRecordStoreEntry got1 = manager.getRecordStore(notThereName, true);
assertNotNull(got1);
assertSame(0, got1.getId());
assertSame(got1, castManager.currentRecordStores[0]);
assertEquals(notThereName, got1.getName());
// Will need to grow entries
String notThereName2 = "not-there2";
IRecordStoreEntry got2 = manager.getRecordStore(notThereName2, true);
assertNotNull(got2);
assertSame(2, got2.getId());
assertSame(got2, castManager.currentRecordStores[2]);
assertNotSame(got2, got1);
assertEquals(notThereName2, got2.getName());
}
示例9: testExpecsGroups2
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testExpecsGroups2() throws RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
expects(new InAnyOrder() {{
one(sector).erase(0L);
}});
expects(new InAnyOrder() {{
one(sector).erase(0L);
}});
sector.erase(0L);
sector.erase(0L);
}
示例10: testGetBlockAtAddress2
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testGetBlockAtAddress2(boolean blocksScanned) throws IOException, RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
castHeap.sectorStates = new INorFlashSectorState[] {sector};
expects(new InAnyOrder() {{
allowing(sector).getStartAddress();will(returnValue(Address.zero()));
allowing(sector).getEndAddress();will(returnValue(Address.zero().add(1)));
one(sector).getWriteHeadPosition();will(returnValue(0));
}});
IMemoryHeapBlock block = heap.getBlockAt(Address.zero());
assertNull(block);
}
示例11: testGetBlockAtSector1
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testGetBlockAtSector1() throws RecordStoreException {
final INorFlashSectorState sector = mock(INorFlashSectorState.class);
final int offset = 10;
final Address address = Address.fromPrimitive(11);
expects(new InAnyOrder() {{
one(sector).getSize();will(returnValue(1024));
one(sector).getStartAddress();will(returnValue(address));
one(sector).readBytes(with(equal(offset)), with(an(byte[].class)), with(equal(0)), with(equal(NorFlashMemoryHeap.BLOCK_HEADER_SIZE)));will(new CustomAction("") {
public Object invoke(Invocation invocation) throws Throwable {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(bytesOut);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
dataOut.writeByte(NorFlashMemoryHeap.ERASED_VALUE);
assertEquals(bytesOut.size(), NorFlashMemoryHeap.BLOCK_HEADER_SIZE);
System.arraycopy(bytesOut.toByteArray(), 0, (byte[]) invocation.getParameter(1), 0, NorFlashMemoryHeap.BLOCK_HEADER_SIZE);
return null;
}
});
}});
MemoryHeapBlock block = new MemoryHeapBlock();
assertFalse(castHeap.getBlockAt(block, sector, offset));
assertSame(address.add(offset), block.getAddress());
}
示例12: testGetUserNorFlashSectors
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testGetUserNorFlashSectors() {
// TODO: Need to fix this test
if (true) {
return;
}
VM.getPeripheralRegistry().removeAll(INorFlashSector.class);
assertSame(0, VM.getPeripheralRegistry().getAll(INorFlashSector.class).length);
final INorFlashSector sector1 = mock(INorFlashSector.class);
final INorFlashSector sector2 = mock(INorFlashSector.class);
final INorFlashSector sector3 = mock(INorFlashSector.class);
expects(new InAnyOrder() {{
allowing(sector1).getPurpose(); will(returnValue(INorFlashSector.RMS_PURPOSED));
allowing(sector2).getPurpose(); will(returnValue(INorFlashSector.SYSTEM_PURPOSED));
allowing(sector3).getPurpose(); will(returnValue(INorFlashSector.RMS_PURPOSED));
}});
// VM.getPeripheralRegistry().add(sector1);
// VM.getPeripheralRegistry().add(sector2);
// VM.getPeripheralRegistry().add(sector3);
Vector<?> sectors = NorFlashMemoryHeap.getNorFlashSectors(INorFlashSector.RMS_PURPOSED);
assertSame(2, sectors.size());
assertTrue(sectors.indexOf(sector1) >= 0);
assertTrue(sectors.indexOf(sector3) >= 0);
VM.getPeripheralRegistry().removeAll(INorFlashSector.class);
}
示例13: testInit
import org.jmock.InAnyOrder; //导入依赖的package包/类
public void testInit() {
final INorFlashSectorState sector1 = mock(INorFlashSectorState.class);
final INorFlashSectorState sector2 = mock(INorFlashSectorState.class);
final INorFlashSectorState sector3 = mock(INorFlashSectorState.class);
final INorFlashSectorState sector4 = mock(INorFlashSectorState.class);
INorFlashSectorState[] sectors = new INorFlashSectorState[] {sector4, sector3, sector2, sector1};
expects(new InAnyOrder() {{
allowing(sector1).getStartAddress();will(returnValue(Address.fromPrimitive(1)));
allowing(sector1).getSequence();will(returnValue(1L));
allowing(sector2).getStartAddress();will(returnValue(Address.fromPrimitive(2)));
allowing(sector2).getSequence();will(returnValue(2L));
allowing(sector3).getStartAddress();will(returnValue(Address.fromPrimitive(3)));
allowing(sector3).getSequence();will(returnValue(3L));
allowing(sector4).getStartAddress();will(returnValue(Address.fromPrimitive(4)));
allowing(sector4).getSequence();will(returnValue(3L));
}});
castHeap.init(sectors);
assertSame(sectors, castHeap.sectorStates);
assertSame(castHeap.sectorStates[0], sector1);
assertSame(castHeap.sectorStates[1], sector2);
assertSame(castHeap.sectorStates[2], sector3);
assertSame(castHeap.sectorStates[3], sector4);
assertSame(0, castHeap.erasedSequenceCurrentValue);
assertNotNull(castHeap.inUseSectorStateList);
assertNotNull(castHeap.toBeErasedSectorStateList);
}