From: Bartek T. <ba...@ba...> - 2008-06-06 11:07:37
|
Hi, You need to initialize the emulator before using RecordStore. We are about to add simple no-UI startup code to the upcoming 2.0.3 release + some documentation. I hope that will help you in your task then. At this moment you can experiment with the following code: package org.microemu.app; import java.io.InputStream; import java.util.ArrayList; import org.microemu.DisplayComponent; import org.microemu.EmulatorContext; import org.microemu.MIDletBridge; import org.microemu.app.ui.noui.NoUiDisplayComponent; import org.microemu.app.util.DeviceEntry; import org.microemu.device.DeviceDisplay; import org.microemu.device.FontManager; import org.microemu.device.InputMethod; import org.microemu.device.j2se.J2SEDevice; import org.microemu.device.j2se.J2SEDeviceDisplay; import org.microemu.device.j2se.J2SEFontManager; import org.microemu.device.j2se.J2SEInputMethod; public class Headless { private Common emulator; private EmulatorContext context = new EmulatorContext() { private DisplayComponent displayComponent = new NoUiDisplayComponent(); private InputMethod inputMethod = new J2SEInputMethod(); private DeviceDisplay deviceDisplay = new J2SEDeviceDisplay(this); private FontManager fontManager = new J2SEFontManager(); public DisplayComponent getDisplayComponent() { return displayComponent; } public InputMethod getDeviceInputMethod() { return inputMethod; } public DeviceDisplay getDeviceDisplay() { return deviceDisplay; } public FontManager getDeviceFontManager() { return fontManager; } public InputStream getResourceAsStream(String name) { return MIDletBridge.getCurrentMIDlet().getClass().getResourceAsStream(name); } }; public Headless() { emulator = new Common(context); } public static void main(String[] args) { ArrayList params = new ArrayList(); for (int i = 0; i < args.length; i++) { params.add(args[i]); } // Non-persistent RMS params.add("--rms"); params.add("memory"); Headless app = new Headless(); DeviceEntry defaultDevice = new DeviceEntry( "Default device", null, "org/microemu/device/device.xml", true, false); app.emulator.initParams(params, defaultDevice, J2SEDevice.class); app.emulator.initMIDlet(true); // TODO } } Regards, Bartek On Tue, May 20, 2008 at 3:05 AM, Karsten Ohme <wid...@t-...> wrote: > Hi, > > I want to run my CLDCUnit tests during the maven install. I use a > RecordStore, but the RecordStore seems to be only available, when an > emulator is running. > > The method: > > public static RecordStoreManager getRecordStoreManager() { > return emulator.getRecordStoreManager(); > } > > throws > > java.lang.NullPointerException > at org.microemu.MIDletBridge.getRecordStoreManager(MIDletBridge.java:122) > at javax.microedition.rms.RecordStore.openRecordStore(RecordStore.java:58) > at > net.sf.microlog.appender.RecordStoreAppender.initLimitedEntries(RecordStoreAppender.java:226) > at > net.sf.microlog.appender.RecordStoreAppender.<init>(RecordStoreAppender.java:59) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at > sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) > at > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) > at java.lang.reflect.Constructor.newInstance(Constructor.java:513) > at java.lang.Class.newInstance0(Class.java:355) > at java.lang.Class.newInstance(Class.java:308) > at net.sf.microlog.Logger.configureAppender(Logger.java:113) > at net.sf.microlog.Logger.configure(Logger.java:55) > > ------- > > How can I use microemulator in Maven with CLDCUnit tests and in eclipse? > I would like to have an embeddable microemulator. > > Regards, > Karsten > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Microemulator-users mailing list > Mic...@li... > https://lists.sourceforge.net/lists/listinfo/microemulator-users > |