Example usage for org.apache.commons.lang.time FastDateFormat getDateTimeInstance

List of usage examples for org.apache.commons.lang.time FastDateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for org.apache.commons.lang.time FastDateFormat getDateTimeInstance.

Prototype

public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle) 

Source Link

Document

Gets a date/time formatter instance using the specified style in the default time zone and locale.

Usage

From source file:com.intuit.tank.job.VMNodeBeanTest.java

/**
 * Run the boolean isPausable() method test.
 * /*from www. j a va  2 s .c  o m*/
 * @throws Exception
 * 
 * @generatedBy CodePro at 12/15/14 3:53 PM
 */
@Test
public void testIsPausable_1() throws Exception {
    CloudVmStatus cloudVmStatus = new CloudVmStatus("", "", "", JobStatus.Completed, VMImageType.AGENT,
            VMRegion.ASIA_1, VMStatus.pending, new ValidationStatus(), 1, 1, new Date(), new Date());
    cloudVmStatus.setTotalTps(1);
    cloudVmStatus.setUserDetails(new LinkedList());
    VMNodeBean fixture = new VMNodeBean(cloudVmStatus, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    boolean result = fixture.isPausable();

    // An unexpected exception was thrown in user code while executing this test:
    // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.VMImageType
    // at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    assertTrue(!result);
}

From source file:com.intuit.tank.job.ActJobNodeBeanTest.java

/**
 * Run the List<VMNodeBean> getSubNodes() method test.
 *
 * @throws Exception//from   ww w .j a  va2  s . c  o  m
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetSubNodes_1() throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    List<VMNodeBean> result = fixture.getSubNodes();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}

From source file:com.intuit.tank.job.VMNodeBeanTest.java

/**
 * Run the boolean isRampPausable() method test.
 * //  www .  j  a  v a  2 s .  co m
 * @throws Exception
 * 
 * @generatedBy CodePro at 12/15/14 3:53 PM
 */
@Test
public void testIsRampPausable_1() throws Exception {
    CloudVmStatus cloudVmStatus = new CloudVmStatus("", "", "", JobStatus.Completed, VMImageType.AGENT,
            VMRegion.ASIA_1, VMStatus.pending, new ValidationStatus(), 1, 1, new Date(), new Date());
    cloudVmStatus.setTotalTps(1);
    cloudVmStatus.setUserDetails(new LinkedList());
    VMNodeBean fixture = new VMNodeBean(cloudVmStatus, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    boolean result = fixture.isRampPausable();

    // An unexpected exception was thrown in user code while executing this test:
    // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.VMImageType
    // at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    assertTrue(!result);
}

From source file:com.tesora.dve.mysqlapi.repl.MyReplicationSlaveService.java

@Override
public void restart() throws PEException {
    stop();//from   w  ww. j a v  a2s  .c om

    // initiate reconnection on new thread to allow existing i/o thread to resume channel closed processing
    reconnectThread = new Thread(new Runnable() {

        @Override
        public void run() {
            FastDateFormat formatter = FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM,
                    FastDateFormat.MEDIUM);

            long retries = 0;
            long start = System.currentTimeMillis();
            long lastAttempt = start;

            logger.info("Replication slave lost connection on " + formatter.format(start)
                    + ".  Attempting to reconnect with the following parameters: "
                    + MyReplicationSlaveConfig.REPL_SLAVE_MASTER_RETRY_CONNECT + "="
                    + myConfig.getMasterConnectRetry() + " seconds" + ", "
                    + MyReplicationSlaveConfig.REPL_SLAVE_SLAVE_NET_TIMEOUT + "="
                    + myConfig.getSlaveNetTimeout() + " seconds" + ", "
                    + MyReplicationSlaveConfig.REPL_SLAVE_MASTER_RETRY_COUNT + "="
                    + myConfig.getMasterRetryCount());

            while (myClient == null || !myClient.isConnected()) {
                if (Thread.interrupted()) {
                    logger.info("Replication slave reconnection was terminated by STOP service command.");
                    reconnectThread = null;
                    break;
                }

                if (((retries > 0) && (retries >= myConfig.getMasterRetryCount()))
                        || ((lastAttempt - start) / 1000) > myConfig.getSlaveNetTimeout()) {
                    logger.warn(
                            "Replication slave was unable to reconnect and will stop replication.  Total attempts="
                                    + retries + ", Started=" + formatter.format(start) + ", Ended="
                                    + formatter.format(lastAttempt));
                    reconnectThread = null;
                    return;
                }

                try {
                    Thread.sleep(myConfig.getMasterConnectRetry() * 1000);
                } catch (Exception e) {
                    logger.info("Replication slave reconnection was terminated by STOP service command.");
                    reconnectThread = null;
                    return;
                }

                if (Thread.interrupted()) {
                    reconnectThread = null;
                    logger.info("Replication slave reconnection was terminated by STOP service command.");
                    break;
                }

                retries++;
                lastAttempt = System.currentTimeMillis();
                try {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Replication slave reconnect attempt #" + retries + " at "
                                + formatter.format(lastAttempt));
                    }
                    start(false);
                } catch (Exception e) {
                    // do nothing
                    if (logger.isDebugEnabled()) {
                        logger.debug("Replication slave reconnect attempt #" + retries + " failed.", e);
                    }
                }
            }

            if (myClient.isConnected()) {
                // successfully reconnected
                logger.info("Replication slave successfully reconnected on attempt " + retries + " on "
                        + formatter.format(lastAttempt));
            }
        }

    }, "ReplicationReconnect");
    reconnectThread.start();
}

From source file:com.intuit.tank.job.VMNodeBeanTest.java

/**
 * Run the boolean isRunnable() method test.
 * //w ww.  j ava 2 s . co m
 * @throws Exception
 * 
 * @generatedBy CodePro at 12/15/14 3:53 PM
 */
@Test
public void testIsRunnable_1() throws Exception {
    CloudVmStatus cloudVmStatus = new CloudVmStatus("", "", "", JobStatus.Completed, VMImageType.AGENT,
            VMRegion.ASIA_1, VMStatus.pending, new ValidationStatus(), 1, 1, new Date(), new Date());
    cloudVmStatus.setTotalTps(1);
    cloudVmStatus.setUserDetails(new LinkedList());
    VMNodeBean fixture = new VMNodeBean(cloudVmStatus, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    boolean result = fixture.isRunnable();

    // An unexpected exception was thrown in user code while executing this test:
    // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.VMImageType
    // at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    assertTrue(!result);
}

From source file:com.intuit.tank.job.ActJobNodeBeanTest.java

/**
 * Run the String getType() method test.
 *
 * @throws Exception//ww  w.ja  v a 2s .co m
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetType_1() throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    String result = fixture.getType();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}

From source file:com.intuit.tank.job.VMNodeBeanTest.java

/**
 * Run the boolean isStopable() method test.
 * /*from   www  .ja v a  2 s.  co  m*/
 * @throws Exception
 * 
 * @generatedBy CodePro at 12/15/14 3:53 PM
 */
@Test
public void testIsStopable_1() throws Exception {
    CloudVmStatus cloudVmStatus = new CloudVmStatus("", "", "", JobStatus.Completed, VMImageType.AGENT,
            VMRegion.ASIA_1, VMStatus.pending, new ValidationStatus(), 1, 1, new Date(), new Date());
    cloudVmStatus.setTotalTps(1);
    cloudVmStatus.setUserDetails(new LinkedList());
    VMNodeBean fixture = new VMNodeBean(cloudVmStatus, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    boolean result = fixture.isStopable();

    // An unexpected exception was thrown in user code while executing this test:
    // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.VMImageType
    // at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    assertTrue(!result);
}

From source file:com.intuit.tank.job.ActJobNodeBeanTest.java

/**
 * Run the List<VMNodeBean> getVmBeans() method test.
 *
 * @throws Exception//from  w  w  w  . j  a  v a2  s .  c  o m
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetVmBeans_1() throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    List<VMNodeBean> result = fixture.getVmBeans();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}

From source file:com.intuit.tank.job.VMNodeBeanTest.java

/**
 * Run the void reCalculate() method test.
 * //  w  w w.j a va 2 s. c o  m
 * @throws Exception
 * 
 * @generatedBy CodePro at 12/15/14 3:53 PM
 */
@Test
public void testReCalculate_1() throws Exception {
    CloudVmStatus cloudVmStatus = new CloudVmStatus("", "", "", JobStatus.Completed, VMImageType.AGENT,
            VMRegion.ASIA_1, VMStatus.pending, new ValidationStatus(), 1, 1, new Date(), new Date());
    cloudVmStatus.setTotalTps(1);
    cloudVmStatus.setUserDetails(new LinkedList());
    VMNodeBean fixture = new VMNodeBean(cloudVmStatus, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    fixture.reCalculate();

    // An unexpected exception was thrown in user code while executing this test:
    // java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.VMImageType
    // at sun.misc.Unsafe.ensureClassInitialized(Native Method)
}

From source file:com.intuit.tank.job.ActJobNodeBeanTest.java

/**
 * Run the boolean hasSubNodes() method test.
 *
 * @throws Exception//from w  w w.ja  v a 2  s  .com
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testHasSubNodes_1() throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true,
            FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    boolean result = fixture.hasSubNodes();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertTrue(!result);
}