protected void setUp() throws Exception {
    Log.log("TEST", "[" + getClassName() + ".setUp] Enter ");
    // do all your test environment initialisation here ....

    /** @todo initialise test data from test input file */
    PartnerTestHelper helper = (PartnerTestHelper) getEntityTestHelper();

    // prepare dependent embedded entity
    PartnerType partnerType = new PartnerType();
    partnerType.setName(PARTNER_TYPE);
    partnerType.setDescription(PARTNER_TYPE_DESCR);
    partnerType = helper.createPartnerType(partnerType);

    PartnerGroup partnerGroup = new PartnerGroup();
    partnerGroup.setName(PARTNER_GROUP);
    partnerGroup.setDescription(PARTNER_GROUP_DESCR);
    partnerGroup.setPartnerType(partnerType);
    partnerGroup = helper.createPartnerGroup(partnerGroup);

    // initialise default test data in test data set
    Partner entity = null;
    entity = new Partner();
    entity.setPartnerID(PARTNER_ID);
    entity.setName(NAME);
    entity.setDescription(DESCRIPTION);
    entity.setPartnerType(partnerType);
    entity.setPartnerGroup(partnerGroup);
    entity.setState(STATE);
    putTestData(DEFAULT_TESTDATA, entity);
    Log.log("TEST", "[" + getClassName() + ".setUp] Exit");
  }
  public void testImport() throws Exception {
    Log.log("TEST", "[DeleteGridDocumentActionTest.testDelete] Enter ");

    createTestData();
    _event = new DeleteGridDocumentEvent(_GDOC_UID);
    //    assertNotNull("event fileType UID is null", _event.getFileTypeUID());
    try {
      _response = performEvent(_event);
    } catch (Exception ex) {
      ex.printStackTrace();
      Log.err("TEST", "[DeleteGridDocumentActionTest.testDelete] Error Exit ", ex);
      assertTrue("Event Exception", false);
    }

    // check response
    assertNotNull("response is null", _response);
    assertTrue("event is not successful", _response.isEventSuccessful());
    assertEquals("Msg code incorrect", IErrorCode.NO_ERROR, _response.getMessageCode());

    Log.log("TEST", "[DeleteGridDocumentActionTest.testDelete] Exit ");
  }
  protected IEvent createTestEvent(IEntity entity) throws Exception {
    _entity = (Partner) entity;
    boolean state = (_entity.getState() == Partner.STATE_ENABLED) ? true : false;

    Log.log("TEST", new Long((_entity.getPartnerType()).getUId()));
    return new CreatePartnerEvent(
        _entity.getPartnerID(),
        _entity.getName(),
        _entity.getDescription(),
        new Long((_entity.getPartnerType()).getUId()),
        new Long((_entity.getPartnerGroup()).getUId()),
        state);
  }
  protected void setUp() throws java.lang.Exception {
    Log.log("TEST", "[DeleteGridDocumentActionTest.setUp] Enter");

    _sessionHome =
        (ISessionManagerHome)
            ServiceLookup.getInstance(ServiceLookup.CLIENT_CONTEXT)
                .getHome(ISessionManagerHome.class);
    assertNotNull("SessionHome is null", _sessionHome);
    _sessionRemote = _sessionHome.create();
    assertNotNull("SessionRemote is null", _sessionRemote);
    _sessionID = _sessionRemote.openSession();
    _sessionRemote.authSession(_sessionID, _userID);

    _home =
        (IDocumentManagerHome)
            ServiceLookup.getInstance(ServiceLookup.CLIENT_CONTEXT)
                .getHome(IDocumentManagerHome.class);
    assertNotNull("Home is null", _home);
    _remote = _home.create();
    assertNotNull("remote is null", _remote);

    Log.log("TEST", "[DeleteGridDocumentActionTest.setUp] Exit");
  }
  /**
   * Send the JMS message (under new transaction) with Retry mechanism enable when encounter JMS
   * related error. If the retry count has exceeded, that JMS will be stored into DB for later
   * retry.
   *
   * @param destName
   * @param msgObj
   * @param msgProps
   * @param jmsSendProps
   * @throws Throwable
   */
  public static void sendMessageWithPersist(
      String destName,
      Serializable msgObj,
      Hashtable msgProps,
      Hashtable<String, String> jmsSendProps)
      throws Throwable {
    boolean isRetryEnabled = _retryCount <= 0 ? false : true;
    int retryCount = _retryCount;
    Throwable th1 = null;

    do {
      try {
        getJMSMgr().sendMessage(jmsSendProps, destName, msgObj, msgProps);
        retryCount = -10;
      } catch (Throwable th) {
        if (isRetryableException(th) && isRetryEnabled) {
          Log.warn(
              Log.FRAMEWORK,
              "Send: JMS exception found. Reconnect after "
                  + _sleepFor / 1000
                  + " num retry left: "
                  + retryCount,
              th);

          try {
            Thread.sleep(_sleepFor);
          } catch (Exception ex) {

          }
          Log.debug(Log.FRAMEWORK, "Send: JMS exception catched: wake up !");
          th1 = th;

        } else {
          Log.warn(
              Log.FRAMEWORK,
              "Send: Non Retryable exception found. No retry will be performed.",
              th);
          throw th;
        }
      }
    } while (retryCount-- > 0);

    if (isRetryEnabled && retryCount == -1 && th1 != null) {
      Log.log(Log.FRAMEWORK, "Send: JMS retry exhausted. exception is: " + th1.getMessage(), th1);
      dumpFailedJMS(JMS_DEST_TYPE_QUEUE, jmsSendProps, destName, msgObj, msgProps);
    }
  }
  static {
    Configuration config = ConfigurationManager.getInstance().getConfig(FRAMEWORK_JMS_CONFIG);

    _retryCount = config.getInt(JMS_NUM_RETRY, 10);
    _sleepFor =
        config.getLong(JMS_RETRY_INTERVAL) == 0L ? 10000 : config.getLong(JMS_RETRY_INTERVAL);
    _isSendViaDefMode = config.getBoolean(JMS_DEF_SEND, true);

    Log.log(
        Log.FRAMEWORK,
        " Retrieve jms props from "
            + FRAMEWORK_JMS_CONFIG
            + " --> JMS Sending mode: "
            + (_isSendViaDefMode ? "Default" : "With Retry")
            + "Retry Count: "
            + _retryCount
            + " retry interval: "
            + _sleepFor
            + " ms");
  }
예제 #7
0
 public static void log(Object msg) {
   Log.log(CATEGORY, msg);
 }
  private void createTestData() {
    Log.log("TEST", "[DeleteGridDocumentActionTest.createTestData] Enter");

    Log.log("TEST", "[DeleteGridDocumentActionTest.createTestData] Exit");
  }
 protected void tearDown() throws java.lang.Exception {
   Log.log("TEST", "[DeleteGridDocumentActionTest.tearDown] Enter");
   Log.log("TEST", "[DeleteGridDocumentActionTest.tearDown] Exit");
 }