Simulating of system time for JVM

I have following problem:
There is a big system written in Java, which needs to be tested automatically. There are test cases, which concern events in the future - in a few days, months, etc. That means, some initial state of the system can be prepared today (with some input data, like request or file) and then in the production environment one would have to wait eg. 1 month for some event to occur automatically - when the tested system detects that the given date lies in the past already. Of course it's not acceptable to wait 1 month before the testcase is finished, so some workaround is needed.
There are no changes to the code of the tested system allowed - it must be tested as blackbox. Changing of system date on the OS level is neither an option.
My question is: is it possible to start somehow the virtual machine with predefined fake date - not the real system date. So that all methods using system date (like Date() constructor etc.) get this fake date as input instead of real system date.
An example to be more precise:
When I call:
java -fake_sysdate01.01.2010T12:25:00 com.company.system.main
the new Date() sets the Date object to above date + delta seconds, which ticked from the start. So if the "new Date()" would be executed 15 minutes after start of the programme, it would be initiated with 01.01.2010T12:40:00 instead of the real current date.
Any ideas? Do I have to write my own virtual machine with such an option or is there some simplier solution? :-)

Yeah I just noticed, now I'm wondering why not?Quite simple: it must be possible to run the tests
automatically on Sun or Linux machines, where the
tester is not the only person working and has noroot
privileges as well. So changing of system date isnot
possible (no privileges) and also not allowed(other
processes, tests etc. would not be happy if system
date would be changed each few minutes or so :-)One does not test in "production". A more suitable
approach is to have "sandbox" test environments,
where you can alter the environment without
affecting real productional systems.Of course not. One test on machines, which are dedicated for tests only. But not for just one tester. And such actions like changing of the system date are not allowed, because they would disturb in other tests.

Similar Messages

  • Faking/Altering system time with JVM

    odd question but...
    Does anybody know of a way to fake/alter the system time read by the Data/System classes? For example, if I want to pretend it is next year. Can I alter the date for all applications running in that JVM? Feels like a jvm option (didn't find any that match up).
    Realise that the clock on the machine (solaris) could be changed but I want to isolate the time shift to a particular JVM or Unix shell instance.
    thanks / Matthew

    Use Calendar and/or GregorianCalendar classes toset
    and alter the date for a jvm.
    What?! You can't do that.
    >
    You misunderstood my reply. I didn't say "modify your
    system's clock", I said change the jvm's date - which
    is internal to the jvm ONLY.IMHO you can not even do that with the methods of the calendar class.
    you can only change the date of the calendar, not of the JVM.
    As far as i can see, there is no way to change the time/date of the JVM.
    The only thing you can do (as shankar.unni suggests) is to change the Systems date/time by using:
    Runtime.getRuntime().exec(...)the limitations here are that
    - you need to do this in a operating system specific way
    - on windows it might be possible that you even have to do it in a language specific way (german win2K takes SimpleDateFormat("dd.mm.YYYY"))
    - you have to have the privileges to change the date.

  • System time for Java Stack and ABAP Stack of PI

    HI,
         We have a scenario in which we have a synchronous flow of data. In the forward flow we have used field UZEIT in an RFC Lookup to register the inbound time and in the reverse flow we have used current time function of SAP PI mapping. PI time is the local time of the server, However UZEIT is 4 hours ahead compared to PI time.
    Both the Java and the Abap stack are installed on the same server.
    Kindly let us know the reason for the difference in time on both the stacks.
    Regards,
                Milan Thaker

    Hi,
       Yes I am refering to the System->Status time in ABAP Stack. Could you please tell me where can I check the System time of JAVA stack. I got one XML file in UME which refers to some timestamp in com.sap.security.core.usermanagement but I failed to locate this field. Please let me know where can I find the Java stack time and how can that be synchronized with ABAP.
             Also, is there any time zone settting in JAVA for UTC , the way we have in ABAP
    Regards,
                  Milan Thaker

  • 42HL833B - How to change system time for Australia

    I have a Toshiba 42HL833B that I brought back with me to Australia from the UK.
    Everything works OK other than the system time still indicates UK time.
    Australia does not come up as a Country option in setup so I have chosen "Other".
    There does not appear to be anywhere where you can change the time.
    Is it possible to change the time manually somehow?

    I dont know if you have users manuals with you but you can download it from here .
    Maybe you can find info how to do this.

  • Auto populate system time for start/end times in OTL Time card

    Hi,
    Is there an option of defaulting the time-card entry/exit times to system-time.
    Say on the time-card a press of a button will default the start-time and end-time(and have these as read-only).
    Is this possible in OTL with any preferences ?
    The client wants to do-away with the time-clocks all together. If such a feature is available in OTL.
    TIA,
    VB
    Edited by: VB on Jun 13, 2011 5:39 PM

    VB,
    You can't add logic in layouts to auto populate the time based on clock. You will have to depend on a custom process to do it.
    Also least time period of entry is day, not week. Look at the preferences setup of your test employee.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • About system time for javescript

    "put the long time"
    --"15:40:25"
    but in javaScript: "trace( _system.time());"
    --"15:40"
    How get the system long time in javascript? Thanks.

    via the "Date"-object
    d = new Date();
    trace (d.getMinutes());
    trace (d.getDate());
    trace (d.toGMTString ());
    trace (d.getHours() +":"+d.getMinutes()+":"+d.getSeconds() );
    Regards
    Aldus

  • In Java,how can I get remote oracle server's system time using a XAOracle datasource

    I want to get remote oracle server's system time,for example,I use a TxDataSource:
    DRIVER className:weblogic.jdbc.oci.xa.XADataSource
    URL:jdbc:weblogic:oracle:lanhaibo
    JNDI Name:
    the following is the code which shows the exception that: sqlexception:the JDBC2.0
    method is not implemented,why? what should I do?:
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    prop.put(Context.PROVIDER_URL,"t3://"+"localhost"+":" + "7001");
    initCtx = new InitialContext(prop);
    DataSource ds = (DataSource)initCtx.lookup(strDataSource);
    Connection conn = ds.getConnection();
    String sqlQuery = "select to_char(sysdate,'yyyy') YYYY,to_char(sysdate, 'MM')
    MM,to_char(sysdate, '" +
    "dd') DD,to_char(sysdate, 'hh24') HH,to_char(sysdate, 'mi') MI,to_char(sysdate,
    '" +
    "ss') SS from dual"
    preparedStatement pstmt = conn.prepareStatement(sqlQury);
    StringBuffer sb = new StringBuffer();
    ResultSet resultset = pstmt.executeQuery();
    if(rs.next()){
    strYear = rs.getString("yyyy");
    strMonth = rs.getString("MM");
    strDay = rs.getString("DD");
    strHour = rs.getString("HH");
    strMinute = rs.getString("MI");
    strSecond = rs.getString("SS");
    sb.append(strYear);
    sb.append("/");
    sb.append(strMonth);
    sb.append("/");
    sb.append(strDay);
    sb.append(" ");
    sb.append(strHour);
    sb.append(":");
    sb.append(strMinute);
    sb.append(":");
    sb.append(strSecond);

    Joden asked:
    "I want to get a remote oracle server's time by XADataSource,
    use:"select sysdate from dual", but return a null value,and give
    the message"sqlexception the jdbc2.0 method is not implemented",
    why?"
    Let me see your code. A simple executeQuery() should do the trick:
    Statement s = c.createStatement();
    ResultSet r = s.executeQuery("select sysdate from dual");
    while (r.next())
    java.sql.Timestamp t = r.getTimestamp(1);
    Guillaume Grussenmeyer wrote:
    Hi.
    I guess you are using weblogic.jdbc.oci.xa.XADataSource as a
    datasource.
    Weblogic JDriver for Oracle "implementation" is really weak as a lot
    of methods are not implemented.
    This is why you get this message.
    You may find the (very impressive) list of non implemented methods at
    http://e-docs.bea.com/wls/docs70/oracle/API_joci.html#1162621 (sorry
    HTML links don't seem to work here).
    Any call to one of this methods will give you these nasty message and
    exception.
    Try to use the "official" Oracle JDBC driver XA Datasource
    (oracle.jdbc.xa.client.OracleXADataSource) instead of Weblogic JDriver
    for Oracle one's.

  • Time dead after changing system time

    Hi,
    I have read many posts on this but still can't find a perfect solution.
    1. tried using thread.sleep(1000) to cause a method to run every 1 sec.. but after reading online.. it seems to be a lousy design as it depends on the system cpu speed. sometimes it will stop for more than 1 sec.
    2. tried :
    private ScheduledExecutorService scheduler
    private ScheduledFuture task
    public classname(){
    scheduler = Executors.newSingleThreadScheduledExecutor();
    task = scheduler.scheduleAtFixedRate(methodToRun,1,1,TimeUnit.SECONDS)
    This works but if i changed the system time for multiple times, it will just stop my program...
    Did i use ScheduledExecutorService or thread right ?

    after reading online.. it seems to be a lousy design as it depends on the system cpu speed.God help us! Where on earth did you read that? It depends on the system clock, and it isn't guaranteed to retun in exactly the time specified.
    sometimes it will stop for more than 1 sec.That's what its specification says.
    This works but if i changed the system time for multiple times, it will just stop my program...No, it won't 'stop' your program, it will foul up the executor until it adjusts to the new time.
    There is nothing in standard Java that guarantees exact timing. If you need that you need a real-time version of Java. But probably you don't need that at all. Impossible to say without some context.

  • Hyperion System 9.3.1 reports taking longer time for the very first time

    We are on Hyperion System 9.3.1. The Financial reports are taking longer time (like 2 to 3 minuter) for the very first time for each login. The subsequest reports are does work faster.
    The behaviour is same for the Production and Development environments.
    All the reporting services have given enough JVM heap size.
    FYI, Reporting and Workspace runngin on the same server. Workspace/Reporting are clusted in two servers. HFM app is running on different server. HFM web is on different server. Shared Services is also on running on different server.
    Any help would be greately appreciated.
    Thanks.

    The reason they run quicker the subsequent times, is because the data has already been cached in the system.
    You could try the usual tricks to speed the report up:
    - move items into POV
    - have children and parent in the same row
    - arrange dimensions in inverse outline order
    - remove excessive formatting
    - push report calculations back to the data source
    We have found that using lots of dynamically calculated members also slows down reports, so try and limit the number of these.
    Hope this helps. If not maybe give us an idea of how the report is created to see if other changes could be made.

  • Changing the System time in the JVM where Weblogic runs

    Hi,
    I am trying to change the System time where the Web-logic server (11g) runs using Mocking. I use "jmockit.jar" to mock the System.class. A Spring bean is created and through that I try to change the System time. I need to change the time for testing scenarios. For example, I need to backdate and do the testing for some scenarios. For the moment I do this manually and I want to automate this by changing only the time in the JVM where the application server runs. When I try to automate this using the Spring bean, I get an error as follows. Do anyone have any idea about this.
    [WLServer adminserver] Exception in thread "Timer-5" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at java.util.TimerThread.mainLoop(Timer.java:495)
    [WLServer adminserver] at java.util.TimerThread.run(Timer.java:462)
    [WLServer adminserver] Exception in thread "DynamicListenThread[Default]" java.lang.IllegalArgumentException: No class with name "com.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at java.util.logging.LogRecord.<init>(LogRecord.java:139)
    [WLServer adminserver] at com.bea.logging.BaseLogRecord.<init>(BaseLogRecord.java:33)
    [WLServer adminserver] at com.bea.logging.BaseLogRecord.<init>(BaseLogRecord.java:48)
    [WLServer adminserver] at com.bea.logging.BaseLogRecord.<init>(BaseLogRecord.java:70)
    [WLServer adminserver] at weblogic.logging.WLLogRecord.<init>(WLLogRecord.java:63)
    [WLServer adminserver] at weblogic.logging.JDKLoggerFactory.createBaseLogRecord(JDKLoggerFactory.java:74)
    [WLServer adminserver] at com.bea.logging.LoggingService.log(LoggingService.java:216)
    [WLServer adminserver] at weblogic.server.ServerLogger.logListenThreadFailure(ServerLogger.java:205)
    [WLServer adminserver] at weblogic.server.channels.DynamicListenThread.run(DynamicListenThread.java:197)
    [WLServer adminserver] at java.lang.Thread.run(Thread.java:619)
    [WLServer adminserver] Exception in thread "weblogic.timers.TimerThread" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at weblogic.timers.internal.TimerThread$Thread.run(TimerThread.java:256)
    [WLServer adminserver] Exception in thread "Timer-4" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at java.util.TimerThread.mainLoop(Timer.java:495)
    [WLServer adminserver] at java.util.TimerThread.run(Timer.java:462)
    [WLServer adminserver] Exception in thread "ClusterNode-localhost" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at EDU.oswego.cs.dl.util.concurrent.Latch.attempt(Unknown Source)
    [WLServer adminserver] at org.apache.jackrabbit.core.cluster.ClusterNode.run(ClusterNode.java:261)
    [WLServer adminserver] at java.lang.Thread.run(Thread.java:619)
    [WLServer adminserver] Exception in thread "Timer-1" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at java.util.TimerThread.mainLoop(Timer.java:495)
    [WLServer adminserver] at java.util.TimerThread.run(Timer.java:462)
    [WLServer adminserver] Exception in thread "ClusterNode-localhost" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at EDU.oswego.cs.dl.util.concurrent.Latch.attempt(Unknown Source)
    [WLServer adminserver] at org.apache.jackrabbit.core.cluster.ClusterNode.run(ClusterNode.java:261)
    [WLServer adminserver] at java.lang.Thread.run(Thread.java:619)
    [WLServer adminserver] Exception in thread "Timer-2" java.lang.IllegalArgumentException: No class with name "com.abc.common.service.impl.MockSystem" found
    [WLServer adminserver] at mockit.internal.util.Utilities.loadClass(Utilities.java:71)
    [WLServer adminserver] at mockit.internal.MockingBridge.callMock(MockingBridge.java:156)
    [WLServer adminserver] at mockit.internal.MockingBridge.invoke(MockingBridge.java:85)
    [WLServer adminserver] at java.lang.System.currentTimeMillis(System.java)
    [WLServer adminserver] at java.util.TimerThread.mainLoop(Timer.java:495)
    [WLServer adminserver] at java.util.TimerThread.run(Timer.java:462)
    [WLServer adminserver] Exception in thread "weblogic.time.TimeEventGenerator" java.util.MissingResourceException: Can't locate bundle for class 'weblogic.common.T3MiscLogLocalizer'
    [WLServer adminserver] at weblogic.i18ntools.L10nLookup.getLocalizer(L10nLookup.java:427)
    [WLServer adminserver] at weblogic.i18n.logging.CatalogMessage.<init>(CatalogMessage.java:47)
    [WLServer adminserver] at weblogic.common.T3MiscLogger.logThrowable(T3MiscLogger.java:325)
    [WLServer adminserver] at weblogic.time.common.internal.TimeEventGenerator.run(TimeEventGenerator.java:126)
    [WLServer adminserver] at java.lang.Thread.run(Thread.java:619)
    OR
    Do anyone know any other way to overcome this issue using some other mocking jar.
    Thanks
    Edited by: 913136 on Feb 8, 2012 2:32 AM

    Hi,
    I could manage to change the time in JVM where the Weblogic server runs. I loaded an Spring bean from my Test class and from that bean I set an offset (to shift the time) in the Mock class (say, MockSystem class). In this case I used the jmockit implementation for instrumentation purposes. The MockSystem class should not be instantiated by us and jmockit takes care of that part. What I had to do was defining the javaagent and another parameter ("-Djmockit-mocks=com.abc.common.service.impl.MockSystem") in the Weblogic server build XML (mentioned in the following URL[1]). But to work this the MockSystem.class file should be wrapped in a JAR file and included in Weblogic server/lib directory and define it in the Weblogic build XML file as a classpath. For more explanations visit this URL [2].
    [1]. http://jmockit.googlecode.com/svn/trunk/www/javadoc/mockit/Mockit.html#setUpStartupMocks%28java.lang.Object...%29
    [2]. http://code.google.com/p/jmockit/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Tool%20Type%20Status%20Priority%20Summary&groupby=&sort=&id=207
    Thanks
    -thiwanka-

  • Jvm time 1 hour behind system time

    hi
    I'm running java on hp-ux 11.11
    since the system time has changed to dst, the java applications are still showing the old time (1 hour behind)
    for example
    now.get(Calendar.YEAR)+"/"+now.get(Calendar.MONTH)+"/"+now.get(Calendar.DATE)+" "+now.get(Calendar.HOUR)+":"+now.get(Calendar.MINUTE)+":"+now.get(Calendar.SECOND)+":"+now.get(Calendar. MILLISECOND)
    will give the output
    2005/7/16 1:28:58:905
    and the tcsh date command will give the output
    Tue Aug 16 13:28:58 IDT 2005
    any ideas on how to synchronize the jvm time with system time?
    thanks
    Yiftah

    I can only confirm that's its true for me too. I was ok on Win98 but shows up on WinXP with summer time (during winter time it was ok. )

  • Search for a file name corresponding to system time (nearest)

    Hi There
    I have a utility which i is dumping files into the local file system every say 4 hours .Its creating a folder corresponding to Year ie 2002 or 2004 and in that folder whenever that utility dumps data it creates a file (xml file based on the system time ex 131708.xml created at 1:17:09 PM.
    Now my application has to find dynamically the path coresponding to the latest xml file .The utility dumping xml file is running as a separte process.
    Can anyone suggest as to how to do this
    Help appreciated
    Thanks
    Raj

    I have my code which looks something like this :===
    File f = new File("C:/Text/Text Only/Text news feeds/2002");
    System.out.println("Folder Names Inside "+f.toString());
    String s[]=new String[]{};
    s=f.list();
    for(int i=0;i<s.length;i++)
    System.out.println(s);
    This code returns me all the folders inside the year folder say 2002.
    Now i have to iterate only through the latest month/day folder in this list and then select the file which is latest which is named as per the system time.
    The question is how to serach for the closest match with the file name
    Thanks
    Raj

  • I cannot do a software update, I get as far as System Updates then when I choose it a message appears say  "Check for update is not available at this time"  but I have not had a system update for a good while now.  I am on System version 6.16.211.XT912.Ve

    I cannot do a software update, I get as far as System Updates then when I choose it a message appears say  "Check for update is not available at this time"  but I have not had a system update for a good while now.  I am on System version 6.16.211.XT912.Verizon,en,US

    Which phone model?

  • I have tried many times to download creative cloud desktop app such as AI, LR, PS, ID and so on.  the following message appears You are running an operating system that Illustrator no longer supports. Refer to the system requirements for a full list of su

    I have tried many times to download creative cloud desktop app such as AI, LR, PS, ID and so on.  the following message appears You are running an operating system that Illustrator no longer supports. Refer to the system requirements for a full list of supported platforms. The only one I have succeeded to download are DW and MU.
    Please could you help out

    Hello,
    please have a look at the different sys-requirements for example:
    AI: http://helpx.adobe.com/illustrator/system-requirements.html
    PS: http://helpx.adobe.com/photoshop/system-requirements.html
    (LR 1-5: http://helpx.adobe.com/de/lightroom/system-requirements.html)
    You will find the same explanations for your other programs.
    Hans-Günter

  • Function Module for getting the System time.

    Hello All,
    Which is the Function Module used in APO to get the system time?
    Thanks for your response in advance.
    Regards, Chirag

    Hi Chirag,
    Please try the following function modules
    1) /SAPAPO/CRES_GET_TIMESTREAM_BT
    2) /SAPAPO/OM_TIME_GET
    The field name for system time is UZEIT under
    structure SYST
    Also try
    3) CALENDAR_GET_TIMESTAMP
    4) SAL_CSM_RECEIVER
    I guess the third one will have your required data
    Regards
    R. Senthil Mareeswaran.

Maybe you are looking for