当前位置: 首页>>代码示例>>Java>>正文


Java INorFlashMemoryHeap类代码示例

本文整理汇总了Java中com.sun.squawk.flash.INorFlashMemoryHeap的典型用法代码示例。如果您正苦于以下问题:Java INorFlashMemoryHeap类的具体用法?Java INorFlashMemoryHeap怎么用?Java INorFlashMemoryHeap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


INorFlashMemoryHeap类属于com.sun.squawk.flash包,在下文中一共展示了INorFlashMemoryHeap类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDeleteRecordStore2

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testDeleteRecordStore2() throws Exception {
    final IRecordStoreEntry recordStore = mock(IRecordStoreEntry.class);
    final String name = "name";
    final Address address = Address.fromPrimitive(10);
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    castManager.currentRecordStores = new IRecordStoreEntry[] {null, recordStore};
    castManager.memoryHeap = heap;
    
    expects(new InThisOrder() {{
        one(recordStore).getName();will(returnValue(name));
        one(recordStore).deleteRecords();
        one(recordStore).getAddress();will(returnValue(address));
        one(heap).freeBlockAt(address);
        one(recordStore).getId();will(returnValue(1));
    }});
    
    boolean deleted = manager.deleteRecordStore(name);
    assertTrue(deleted);
    assertNull(castManager.currentRecordStores[1]);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:21,代码来源:RecordStoreManagerTest.java

示例2: testGetEntryAt2

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testGetEntryAt2() throws IOException, RecordStoreException {
    final Address address = Address.fromPrimitive(11);
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);
    IRecordStoreSequenceEntry entry = new RecordStoreSequenceEntry();
    dataOut.writeByte(entry.getType());
    entry.writeTo(dataOut);
    final MemoryHeapBlock block = new MemoryHeapBlock();
    block.setIsAllocated(true);
    int padding = 0;
    if ((bytesOut.size() & 1) == 1) {
        bytesOut.write(0);
        padding = 1;
    }
    block.setBytes(bytesOut.toByteArray(), 0, bytesOut.size() - padding);
    castManager.memoryHeap = heap;
    
    expects(new InThisOrder() {{
        one(heap).getBlockAt(address);will(returnValue(block));
    }});
    
    IRmsEntry getEntry = manager.getEntryAt(address);
    assertNotNull(getEntry);
    assertSame(entry.getClass(), getEntry.getClass());
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:27,代码来源:RecordStoreManagerTest.java

示例3: RecordStoreManager

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public RecordStoreManager(INorFlashMemoryHeap memoryHeap, INorFlashMemoryHeapScanner memoryHeapScanner, IRmsEntryVisitor scanVisitor, IRmsEntryVisitor reScanVisitor) throws RecordStoreException {
    this.memoryHeap = memoryHeap;
    this.memoryHeapScanner = memoryHeapScanner;
    this.scanVisitor = scanVisitor;
    this.reScanVisitor = reScanVisitor;
    currentRecordStores = new IRecordStoreEntry[4];
    init();
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:9,代码来源:RecordStoreManager.java

示例4: testVisitApplicationDescriptor

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testVisitApplicationDescriptor() throws RecordStoreException, IOException {
    final IApplicationDescriptorEntry entry1 = mock(IApplicationDescriptorEntry.class, "entry1");
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    manager.memoryHeap = heap;
    
    // first app desc
    visitor.visitApplicationDescriptor(entry1);
    assertSame(entry1, manager.currentApplicationDescriptor);

    // sec app desc
    final Address address = Address.fromPrimitive(11);
    final IApplicationDescriptorEntry entry2 = mock(IApplicationDescriptorEntry.class, "entry2");
    expects(new InThisOrder() {{
        one(entry1).getAddress();will(returnValue(address));
        one(heap).freeBlockAt(address);
    }});
    visitor.visitApplicationDescriptor(entry2);
    assertSame(entry2, manager.currentApplicationDescriptor);

    // IO error on invalidate entry
    expects(new InThisOrder() {{
        one(entry2).getAddress();will(returnValue(address));
        one(heap).freeBlockAt(address);will(throwException(new RecordStoreException()));
    }});
    try {
        visitor.visitApplicationDescriptor(entry2);
        fail();
    } catch (RecordStoreException e) {
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:31,代码来源:RecordStoreManagerScanVisitorTest.java

示例5: testVisitRecordStore

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testVisitRecordStore() throws RecordStoreException, IOException {
    final IRecordStoreEntry entry1 = mock(IRecordStoreEntry.class, "entry1");
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    manager.currentRecordStores = new IRecordStoreEntry[] {null, null};
    manager.memoryHeap = heap;
    expects(new InThisOrder() {{
        one(entry1).getId();will(returnValue(1));
    }});
    
    // first encounter of record store id 1
    visitor.visitRecordStore(entry1);
    assertSame(entry1, manager.currentRecordStores[1]);

    // second encounter of record store id 1
    final IRecordStoreEntry entry2 = mock(IRecordStoreEntry.class, "entry2");
    final Address address1 = Address.fromPrimitive(12);
    expects(new InThisOrder() {{
        one(entry2).getId();will(returnValue(1));
        atLeast(1).of(entry1).getAddress();will(returnValue(address1));
        one(heap).freeBlockAt(address1);
    }});
    visitor.visitRecordStore(entry2);
    assertSame(entry2, manager.currentRecordStores[1]);
    
    // IO error on invalidate entry
    final Address address2 = Address.fromPrimitive(13);
    expects(new InThisOrder() {{
        one(entry2).getId();will(returnValue(1));
        atLeast(1).of(entry2).getAddress();will(returnValue(address2));
        one(heap).freeBlockAt(address2);will(throwException(new RecordStoreException()));
    }});
    try {
        visitor.visitRecordStore(entry2);
        fail();
    } catch (RecordStoreException e) {
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:38,代码来源:RecordStoreManagerScanVisitorTest.java

示例6: testGetEntryAt

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testGetEntryAt() throws IOException, RecordStoreException {
    final Address address = Address.fromPrimitive(11);
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    castManager.memoryHeap = heap;
    
    expects(new InThisOrder() {{
        one(heap).getBlockAt(address);will(returnValue(null));
    }});
    
    assertNull(manager.getEntryAt(address));
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:12,代码来源:RecordStoreManagerTest.java

示例7: testGetEntryAt1

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的package包/类
public void testGetEntryAt1() throws IOException, RecordStoreException {
    final Address address = Address.fromPrimitive(11);
    final INorFlashMemoryHeap heap = mock(INorFlashMemoryHeap.class);
    final MemoryHeapBlock block = new MemoryHeapBlock();
    castManager.memoryHeap = heap;
    
    expects(new InThisOrder() {{
        one(heap).getBlockAt(address);will(returnValue(block));
    }});
    
    assertNull(manager.getEntryAt(address));
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:13,代码来源:RecordStoreManagerTest.java

示例8: testGetRecordStoreByName3

import com.sun.squawk.flash.INorFlashMemoryHeap; //导入依赖的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());
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:32,代码来源:RecordStoreManagerTest.java


注:本文中的com.sun.squawk.flash.INorFlashMemoryHeap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。