コード例 #1
0
  @Override
  @Test
  public void multipleMaxConnectionOpenTest() throws Throwable {
    AsyncHttpClientConfig cg =
        new AsyncHttpClientConfig.Builder()
            .setAllowPoolingConnection(true)
            .setConnectionTimeoutInMs(5000)
            .setMaximumConnectionsTotal(1)
            .build();
    AsyncHttpClient c = getAsyncHttpClient(cg);

    String body = "hello there";

    // once
    Response response =
        c.preparePost(getTargetUrl()).setBody(body).execute().get(TIMEOUT, TimeUnit.SECONDS);

    assertEquals(response.getResponseBody(), body);

    // twice
    Exception exception = null;
    try {
      c.preparePost(String.format("http://127.0.0.1:%d/foo/test", port2))
          .setBody(body)
          .execute()
          .get(TIMEOUT, TimeUnit.SECONDS);
      fail("Should throw exception. Too many connections issued.");
    } catch (Exception ex) {
      ex.printStackTrace();
      exception = ex;
    }
    assertNotNull(exception);
    c.close();
  }
コード例 #2
0
  @Override
  @Test
  public void testMaxTotalConnectionsException() {
    AsyncHttpClient client =
        getAsyncHttpClient(
            new AsyncHttpClientConfig.Builder()
                .setAllowPoolingConnection(true)
                .setMaximumConnectionsTotal(1)
                .build());

    String url = getTargetUrl();
    int i;
    Exception exception = null;
    for (i = 0; i < 20; i++) {
      try {
        log.info("{} requesting url [{}]...", i, url);

        if (i < 5) {
          client.prepareGet(url).execute().get();
        } else {
          client.prepareGet(url).execute();
        }
      } catch (Exception ex) {
        exception = ex;
        break;
      }
    }
    assertNotNull(exception);
    assertNotNull(exception.getMessage());
  }
コード例 #3
0
  public List<String> getResourceSetList(final Token p_pat, String p_umaRegisterResourcePath) {
    final List<String> result = new ArrayList<String>();
    try {
      new ResourceRequestEnvironment.ResourceRequest(
          new ResourceRequestEnvironment(m_baseTest),
          ResourceRequestEnvironment.Method.GET,
          p_umaRegisterResourcePath) {
        @Override
        protected void prepareRequest(EnhancedMockHttpServletRequest request) {
          super.prepareRequest(request);

          request.addHeader("Accept", UmaConstants.JSON_MEDIA_TYPE);
          request.addHeader("Authorization", "Bearer " + p_pat.getAccessToken());
        }

        @Override
        protected void onResponse(EnhancedMockHttpServletResponse response) {
          super.onResponse(response);
          BaseTest.showResponse("UMA : TRegisterResourceSet.getResourceSetList() : ", response);

          assertEquals(response.getStatus(), 200, "Unexpected response code.");

          List<String> list = TUma.readJsonValue(response.getContentAsString(), List.class);
          if (list != null) {
            result.addAll(list);
          }
        }
      }.run();
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
    return result;
  }
コード例 #4
0
  public void deleteResourceSet(final Token p_pat, String p_umaRegisterResourcePath, String p_id) {
    String path = p_umaRegisterResourcePath + "/" + p_id + "/";
    try {
      new ResourceRequestEnvironment.ResourceRequest(
          new ResourceRequestEnvironment(m_baseTest),
          ResourceRequestEnvironment.Method.DELETE,
          path) {

        @Override
        protected void prepareRequest(EnhancedMockHttpServletRequest request) {
          super.prepareRequest(request);

          // request.addHeader("Accept", UmaConstants.RESOURCE_SET_STATUS_MEDIA_TYPE);
          request.addHeader("Authorization", "Bearer " + p_pat.getAccessToken());
        }

        @Override
        protected void onResponse(EnhancedMockHttpServletResponse response) {
          super.onResponse(response);
          BaseTest.showResponse("UMA : TRegisterResourceSet.deleteResourceSet() : ", response);

          assertEquals(
              response.getStatus(),
              Response.Status.NO_CONTENT.getStatusCode(),
              "Unexpected response code.");
        }
      }.run();
    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
  }
コード例 #5
0
ファイル: MainIT.java プロジェクト: difi/oxalis
  @Test(enabled = true)
  public void sendToDifiTest() throws URISyntaxException {

    OperationalMode modeOfOperation = globalConfiguration.getModeOfOperation();
    assertEquals(modeOfOperation, OperationalMode.TEST, "This test may only be run in TEST mode");

    URL resource = MainIT.class.getClassLoader().getResource("BII04_T10_EHF-v2.0_invoice.xml");
    URI uri = resource.toURI();
    File testFile = new File(uri);
    assertTrue(testFile.canRead(), "Can not locate " + testFile);

    String[] args = {
      "-f", testFile.toString(),
      "-r", WellKnownParticipant.DIFI_TEST.toString(),
      "-s", WellKnownParticipant.U4_TEST.toString(),
      "-t", "true",
      "-e", "/tmp" // current directory
    };

    // Executes the outbound message sender
    try {
      Main.main(args);
    } catch (Exception e) {
      fail("Failed " + e.getMessage(), e);
    }
  }
コード例 #6
0
ファイル: MainIT.java プロジェクト: difi/oxalis
  @Test(enabled = false)
  public void sendToEspapTest() throws URISyntaxException {

    OperationalMode modeOfOperation = globalConfiguration.getModeOfOperation();
    assertEquals(modeOfOperation, OperationalMode.TEST, "This test may only be run in TEST mode");

    URL resource = MainIT.class.getClassLoader().getResource("BII04_T10_EHF-v2.0_invoice.xml");
    URI uri = resource.toURI();
    File testFile = new File(uri);
    assertTrue(testFile.canRead(), "Can not locate " + testFile);

    String[] args = {
      "-f", testFile.toString(),
      "-r", "9946:ESPAP",
      "-s", WellKnownParticipant.DIFI_TEST.toString(),
      "-t", "true",
      "-u", "https://ap1.espap.pt/oxalis/as2",
      "-m", "AS2",
      "-i", "APP_1000000222"
    };

    // Executes the outbound message sender
    try {
      Main.main(args);
    } catch (Exception e) {
      fail("Failed " + e.getMessage());
    }
  }
コード例 #7
0
  public void searchContent() {
    SearchResultsBean bean = null;

    try {
      boolean searchSuccess = false;
      // Retrying until test passes
      log.info("### Content search retry cycle started .. ");
      for (int i = 0; i < RERTY_CYCLES; i++) {
        log.info("#### Content search cycle # " + i);
        bean =
            contentSearchAdminServiceStub.getContentSearchResults(
                "ArrayOftCountrySelectedTopScorer");
        if (bean.getResourceDataList() != null) {
          bean.setResourceDataList(new ResourceData[0]);
          searchSuccess = true;
          log.info("#### Content search PASSED .. in seconds : " + i * 15);
          break;

        } else {
          doSleep();
        }
      }
      if (!searchSuccess) {
        fail("# MetaData search test failed .. ");
        log.info("# MetaData search test failed .. ");
        log.error("# MetaData search test failed .. ");
      }

    } catch (Exception e) {
      fail("Content search failed: " + e);
      log.error("Content search failed: " + e.getMessage());
      String msg = "Failed to get search results from the search service. " + e.getMessage();
      log.error(msg, e);
    }
  }
コード例 #8
0
 public ResourceSetStatus registerResourceSet(
     final Token p_pat, String umaRegisterResourcePath, ResourceSet p_resourceSet) {
   try {
     m_registerStatus = registerResourceSetInternal(p_pat, umaRegisterResourcePath, p_resourceSet);
   } catch (Exception e) {
     e.printStackTrace();
     fail();
   }
   UmaTestUtil.assert_(m_registerStatus);
   return m_registerStatus;
 }
コード例 #9
0
 /**
  * Invalid conversion cases for COMPOUND to: BOOL, TEXT, INT, LONG, DECIMAL, XREF, CATEGORICAL,
  * EMAIL, HYPERLINK, HTML, ENUM, DATE, DATE_TIME, MREF, CATEGORICAL_MREF, FILE, ONE_TO_MANY
  *
  * @param valueToConvert The value that will be converted
  * @param typeToConvertTo The type to convert to
  * @param exceptionClass The expected class of the exception that will be thrown
  * @param exceptionMessage The expected exception message
  */
 @Test(dataProvider = "invalidConversionTestCases")
 public void testInvalidConversion(
     String valueToConvert,
     AttributeType typeToConvertTo,
     Class exceptionClass,
     String exceptionMessage) {
   try {
     testTypeConversion(valueToConvert, typeToConvertTo);
     fail("Conversion should have failed");
   } catch (Exception exception) {
     assertTrue(exception.getClass().isAssignableFrom(exceptionClass));
     assertEquals(exception.getMessage(), exceptionMessage);
   }
 }
コード例 #10
0
 /**
  * Test show persistent result set.
  *
  * @param qCom the q com
  * @throws Exception the exception
  */
 private void testShowPersistentResultSet(LensQueryCommands qCom) throws Exception {
   System.out.println("@@PERSISTENT_RESULT_TEST-------------");
   client.setConnectionParam("lens.query.enable.persistent.resultset.indriver", "true");
   String query = "cube select id,name from test_dim";
   try {
     String result = qCom.executeQuery(query, false, "testQuery3");
     System.out.println("@@ RESULT " + result);
     assertNotNull(result);
     assertFalse(result.contains("Failed to get resultset"));
   } catch (Exception exc) {
     log.error("Exception not expected while getting resultset.", exc);
     fail("Exception not expected: " + exc.getMessage());
   }
   System.out.println("@@END_PERSISTENT_RESULT_TEST-------------");
 }
コード例 #11
0
  // @Test(groups = "standalone")
  public void redirected302InvalidTest() throws Exception {
    isSet.getAndSet(false);
    Exception e = null;

    try (AsyncHttpClient c = asyncHttpClient()) {
      c.preparePost(getTargetUrl())
          .setFollowRedirect(true)
          .setHeader("X-redirect", String.format("http://localhost:%d/", port2))
          .execute()
          .get();
    } catch (ExecutionException ex) {
      e = ex;
    }

    assertNotNull(e);
    Throwable cause = e.getCause();
    assertTrue(cause instanceof ConnectException);
    assertTrue(cause.getMessage().contains(":" + port2));
  }
コード例 #12
0
  public void addResource() {

    try {
      String resource =
          frameworkPath
              + File.separator
              + ".."
              + File.separator
              + ".."
              + File.separator
              + ".."
              + File.separator
              + "src"
              + File.separator
              + "test"
              + File.separator
              + "java"
              + File.separator
              + "resources"
              + File.separator
              + resourceName;

      resourceAdminServiceStub.addResource(
          wsdlPath + resourceName,
          "application/wsdl+xml",
          "test resource",
          new DataHandler(new URL("file:///" + resource)),
          null,
          null);

    } catch (Exception e) {
      fail("Unable to get file content: " + e);
      log.error("Unable to get file content: " + e.getMessage());
    }

    try {
      Thread.sleep(15000);
    } catch (InterruptedException e) {
    }
  }
コード例 #13
0
  @Test(groups = {"standalone", "default_provider"})
  public void testInvalidConnectionsPool() {

    ConnectionsPool<String, Connection> cp =
        new ConnectionsPool<String, Connection>() {

          public boolean offer(String key, Connection connection) {
            return false;
          }

          public Connection poll(String connection) {
            return null;
          }

          public boolean removeAll(Connection connection) {
            return false;
          }

          public boolean canCacheConnection() {
            return false;
          }

          public void destroy() {}
        };

    AsyncHttpClient client =
        getAsyncHttpClient(new AsyncHttpClientConfig.Builder().setConnectionsPool(cp).build());

    Exception exception = null;
    try {
      client.prepareGet(getTargetUrl()).execute().get(TIMEOUT, TimeUnit.SECONDS);
    } catch (Exception ex) {
      ex.printStackTrace();
      exception = ex;
    }
    assertNotNull(exception);
    client.close();
  }
コード例 #14
0
  /**
   * Test purged finished result set.
   *
   * @param qCom the q com
   */
  private void testPurgedFinishedResultSet(LensQueryCommands qCom) {
    System.out.println("@@START_FINISHED_PURGED_RESULT_TEST-------------");
    client.setConnectionParam("lens.server.max.finished.queries", "0");
    client.setConnectionParam("lens.query.enable.persistent.resultset", "true");
    String query = "cube select id,name from test_dim";
    try {
      String qh = qCom.executeQuery(query, true, "testQuery");
      while (!client.getQueryStatus(qh).finished()) {
        Thread.sleep(5000);
      }
      assertTrue(qCom.getStatus(qh).contains("Status : SUCCESSFUL"));

      String result = qCom.getQueryResults(qh, null, true);
      System.out.println("@@ RESULT " + result);
      assertNotNull(result);

      // This is to check for positive processing time
      assertFalse(result.contains("(-"));
    } catch (Exception exc) {
      log.error("Exception not expected while purging resultset.", exc);
      fail("Exception not expected: " + exc.getMessage());
    }
    System.out.println("@@END_FINISHED_PURGED_RESULT_TEST-------------");
  }
コード例 #15
0
ファイル: TestCount.java プロジェクト: Timon2180/MavenTest
  @Test
  public void TestStart() throws ExceptFailTest {

    System.out.println("Start @Test");
    try {
      pageLoginStargate.GetWriterLog(wLog); // отдали лог
      pageLoginStargate.OpenPage();
      pageLoginStargate.CheckElements();
      pageLoginStargate.TypeLoginPassword();
      pageStargate = pageLoginStargate.EnterStargate();
      pageStargate.GetWriterLog(wLog);

      if (Proper.GetProperty("typeAdvert").equals("premium"))
        pageStargate.OpenFormCreatePremiumAuto();
      else pageStargate.OpenFormCreateAdvertAuto();
      pageStargate.InputDataAuto();

      if (Proper.GetProperty("typeAdvert").equals("premium"))
        pageStargate.OpenFormCreatePremiumFree();
      else pageStargate.OpenFormCreateAdvertFree();
      pageStargate.InputDataFree();

      pageIrr.GetWriterLog(wLog);
      pageIrr.OpenPage();
      pageIrr.OpenFormAuthorization();
      pageIrrPrOf = pageIrr.LoginOn();
      pageIrrPrOf.GetWriterLog(wLog);

      pageIrrPrOf.CheckCountAndVisibleAdvert();
      pageIrrPrOf.CheckCurrentCategory();
      pageIrrPrOf.GetCurrentStatus();
      pageIrrPrOf.GetCurrentCategory();
      pageIrrPrOf.DeactivateAllAdvert();
      pageIrrPrOf.CheckCountAndVisibleAdvert();
      pageIrrPrOf.CheckCurrentCategory();
      pageIrrPrOf.CheckOldAndNewStatus(1);
      pageIrrPrOf.CheckOldAndNewCategory(1);
      pageIrrPrOf.DeleteAllAdvert();
      pageIrrPrOf.CheckCountAndVisibleAdvert();
      pageIrrPrOf.CheckCurrentCategory();
      pageIrrPrOf.CheckOldAndNewStatus(2);

      clStatusAdvert = pageIrrPrOf.SendStatus();
      clStatusAdvertCategory = pageIrrPrOf.SendCategory();
      pageIrrPrOf.LogOutFromIrr();

      pageLoginStargate.OpenPage();
      pageLoginStargate.CheckElements();
      pageLoginStargate.TypeLoginPassword();
      pageStargate = pageLoginStargate.EnterStargate();
      pageStargate.GetWriterLog(wLog);

      if (Proper.GetProperty("typeAdvert").equals("premium"))
        pageStargate.OpenFormCreatePremiumAuto();
      else pageStargate.OpenFormCreateAdvertAuto();
      pageStargate.InputDataAuto();

      if (Proper.GetProperty("typeAdvert").equals("premium"))
        pageStargate.OpenFormCreatePremiumFree();
      else pageStargate.OpenFormCreateAdvertFree();
      pageStargate.InputDataFree();

      pageIrr.OpenPage();
      pageIrr.OpenFormAuthorization();
      pageIrrPrOf = pageIrr.LoginOn();
      pageIrrPrOf.GetWriterLog(wLog);

      pageIrrPrOf.GetStatusForLastLogin(clStatusAdvert, clStatusAdvertCategory);

      pageIrrPrOf.CheckCountAndVisibleAdvert();
      pageIrrPrOf.CheckCurrentCategory();

      pageIrrPrOf.CheckOldAndNewStatus(3);
      pageIrrPrOf.CheckOldAndNewCategory(2);
      System.out.println("Тест завершен успешно");
      wLog.WriteString(1, "Тест завершен успешно");
    } catch (ExceptFailTest exc) {
      System.out.println("Что то случилось непредвиденное 2" + exc.toString());
      wLog.WriteString(2, "Что то случилось непредвиденное 2: " + exc.toString());
      fail("some error here2");
      // testR.SetFlag(false);
    } catch (Exception exc) {
      System.out.println("Что то случилось непредвиденное" + exc.toString());
      wLog.WriteString(2, "Что то случилось непредвиденное: " + exc.toString());
      fail("some error here");
      // testR.SetFlag(false);
      // throw new ExceptFailTest(exc.toString());
    } finally {
      CaptureScreenshot();
      wLog.CloseFile();
      driver.quit();
    }
    System.out.println("End @Test");
  }