Esempio n. 1
0
  /** Path & edge are the same, directions are reverse, neg. to pos. */
  @Test
  public void testPathStateConvert7() {

    final Path startPath =
        TestUtils.makeTmpPath(
            graph,
            true,
            new Coordinate(20, -10),
            new Coordinate(10, -10),
            new Coordinate(10, 0),
            new Coordinate(0, 0));
    final Matrix covar =
        MatrixFactory.getDefault()
            .copyArray(new double[][] {new double[] {126.56, 8.44}, new double[] {8.44, 0.56}});
    final MultivariateGaussian startBelief =
        new AdjMultivariateGaussian(VectorFactory.getDefault().createVector2D(-2.5d, 1d), covar);
    final PathStateDistribution currentBelief = new PathStateDistribution(startPath, startBelief);

    final Path newPath =
        TestUtils.makeTmpPath(graph, false, new Coordinate(10, 0), new Coordinate(0, 0));

    final PathStateDistribution result = currentBelief.convertToPath(newPath);

    AssertJUnit.assertEquals("distance", 7.5d, result.getMean().getElement(0), 0d);
    AssertJUnit.assertEquals("velocity", 1d, result.getMean().getElement(1), 0d);
  }
Esempio n. 2
0
  @Test
  public void testPathStateConvert2() {
    final Path startPath =
        TestUtils.makeTmpPath(graph, false, new Coordinate(0, 0), new Coordinate(10, 0));

    final Matrix covar =
        MatrixFactory.getDefault()
            .copyArray(new double[][] {new double[] {126.56, 8.44}, new double[] {8.44, 0.56}});
    final MultivariateGaussian startBelief =
        new AdjMultivariateGaussian(VectorFactory.getDenseDefault().createVector2D(0d, 1d), covar);
    final PathStateDistribution currentBelief = new PathStateDistribution(startPath, startBelief);

    final Vector groundLoc =
        MotionStateEstimatorPredictor.getOg()
            .times(currentBelief.getGroundDistribution().getMean());
    AssertJUnit.assertEquals("initial state x", 0d, groundLoc.getElement(0), 0d);
    AssertJUnit.assertEquals("initial state y", 0d, groundLoc.getElement(1), 0d);

    final Path newPath =
        TestUtils.makeTmpPath(
            graph,
            true,
            new Coordinate(20, -10),
            new Coordinate(10, -10),
            new Coordinate(10, 0),
            new Coordinate(0, 0));

    final PathStateDistribution result = currentBelief.convertToPath(newPath);

    AssertJUnit.assertEquals("distance", -0d, result.getMean().getElement(0), 0d);
    AssertJUnit.assertEquals("velocity", -1d, result.getMean().getElement(1), 0d);
  }
  @Test
  public void test110ChangeModifyObject() throws Exception {
    final String TEST_NAME = "test110ChangeModifyObject";
    TestUtil.displayTestTile(this, TEST_NAME);

    OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    Set<Operation> changes = new HashSet<Operation>();

    changes.add(createAddAttributeChange("employeeNumber", "123123123"));
    changes.add(createReplaceAttributeChange("sn", "Smith007"));
    changes.add(createAddAttributeChange("street", "Wall Street"));
    changes.add(createDeleteAttributeChange("givenName", "John"));

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME);

    cc.modifyObject(accountDefinition, identifiers, changes, result);

    ResourceObjectIdentification identification =
        new ResourceObjectIdentification(accountDefinition, identifiers);
    PrismObject<ShadowType> shadow = cc.fetchObject(ShadowType.class, identification, null, result);
    ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow);

    AssertJUnit.assertNull(
        resObj.findAttribute(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName")));

    String addedEmployeeNumber =
        resObj
            .findAttribute(
                new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "employeeNumber"))
            .getValue(String.class)
            .getValue();
    String changedSn =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();
    String addedStreet =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "street"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();

    System.out.println("changed employee number: " + addedEmployeeNumber);
    System.out.println("changed sn: " + changedSn);
    System.out.println("added street: " + addedStreet);

    AssertJUnit.assertEquals("123123123", addedEmployeeNumber);
    AssertJUnit.assertEquals("Smith007", changedSn);
    AssertJUnit.assertEquals("Wall Street", addedStreet);
  }
  /**
   * Simple call to connector test() method.
   *
   * @throws Exception
   */
  @Test
  public void test310TestConnectionNegative() throws Exception {
    final String TEST_NAME = "test310TestConnectionNegative";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN

    OperationResult result = new OperationResult(TEST_NAME);

    ConnectorInstance badConnector =
        factory.createConnectorInstance(
            connectorType,
            ResourceTypeUtil.getResourceNamespace(badResourceType),
            "test connector");
    badConnector.configure(
        badResourceType.getConnectorConfiguration().asPrismContainerValue(), result);

    // WHEN

    badConnector.test(result);

    // THEN
    result.computeStatus("test failed");
    display("Test result (FAILURE EXPECTED)", result);
    AssertJUnit.assertNotNull(result);
    OperationResult connectorConnectionResult = result.getSubresults().get(1);
    AssertJUnit.assertNotNull(connectorConnectionResult);
    System.out.println(
        "Test \"connector connection\" result: "
            + connectorConnectionResult
            + " (FAILURE EXPECTED)");
    AssertJUnit.assertTrue(
        "Unexpected success of bad connector test", !connectorConnectionResult.isSuccess());
    AssertJUnit.assertTrue(!result.isSuccess());
  }
 /**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all ExchangeRateProvider instances returns valid ProviderContext.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ExchangeRateProvider prov = MonetaryConversions.getExchangeRateProvider(providerName);
     AssertJUnit.assertNotNull("Provider mot accessible: " + providerName, prov);
     ProviderContext ctx = prov.getContext();
     AssertJUnit.assertNotNull(
         "ExchangeProvider must return a valid ProviderContext, but returned null: "
             + providerName,
         ctx);
     AssertJUnit.assertEquals(
         "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
         providerName,
         ctx.getProviderName());
     AssertJUnit.assertNotNull(
         "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
             + providerName,
         ctx.getRateTypes());
     AssertJUnit.assertFalse(
         "ExchangeProvider's ProviderContext declares empty RateTypes to be returned: "
             + providerName,
         ctx.getRateTypes().isEmpty());
   }
 }
 public void multipleFlushTest() throws IOException {
   final String filename = "longFile.writtenInMultipleFlushes";
   final int bufferSize = 300;
   Cache cache = cacheManager.getCache();
   cache.clear();
   Directory dir =
       DirectoryBuilder.newDirectoryInstance(cache, cache, cache, INDEXNAME)
           .chunkSize(13)
           .create();
   byte[] manyBytes = fillBytes(bufferSize);
   IndexOutput indexOutput = dir.createOutput(filename);
   for (int i = 0; i < 10; i++) {
     indexOutput.writeBytes(manyBytes, bufferSize);
     indexOutput.flush();
   }
   indexOutput.close();
   IndexInput input = dir.openInput(filename);
   final int finalSize = (10 * bufferSize);
   AssertJUnit.assertEquals(finalSize, input.length());
   final byte[] resultingBuffer = new byte[finalSize];
   input.readBytes(resultingBuffer, 0, finalSize);
   int index = 0;
   for (int i = 0; i < 10; i++) {
     for (int j = 0; j < bufferSize; j++)
       AssertJUnit.assertEquals(resultingBuffer[index++], manyBytes[j]);
   }
 }
Esempio n. 7
0
  public void testAdded() throws Exception {
    prepareTestData();
    queryParser = createQueryParser("blurb");

    luceneQuery = queryParser.parse("eats");
    cacheQuery = Search.getSearchManager(cache2).getQuery(luceneQuery);
    List<Object> found = cacheQuery.list();

    AssertJUnit.assertEquals(2, found.size());
    assert found.contains(person2);
    assert found.contains(person3);
    assert !found.contains(person4) : "This should not contain object person4";

    person4 = new Person();
    person4.setName("Mighty Goat");
    person4.setBlurb("Also eats grass");

    cache1.put("mighty", person4);

    luceneQuery = queryParser.parse("eats");
    cacheQuery = Search.getSearchManager(cache2).getQuery(luceneQuery);
    found = cacheQuery.list();

    AssertJUnit.assertEquals(3, found.size());
    assert found.contains(person2);
    assert found.contains(person3);
    assert found.contains(person4) : "This should now contain object person4";
  }
 /**
  * Access and test different Currency Conversions for the provider in place.
  *
  * <p>Test TCK providers, but also test implementation providers. Doing the ladder it is not
  * possible to test the rates quality, just that rates are returned if necessary.
  */
 @Test(
     description =
         "4.3.1 Access Conversion by query to term currency XXX for all providers that support according "
             + "conversion, if"
             + "available a non-null CurrencyConversion must be provided.")
 @SpecAssertion(id = "431-A2", section = "4.3.1")
 public void testConversionsAreAvailableWithQuery() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ConversionQuery query =
         ConversionQueryBuilder.of().setTermCurrency("XXX").setProviderNames(providerName).build();
     try {
       if (MonetaryConversions.isConversionAvailable(query)) {
         CurrencyConversion conv = MonetaryConversions.getConversion(query);
         AssertJUnit.assertNotNull(
             "CurrencyConversion returned from MonetaryConversions.getConversion(ConversionQuery) must"
                 + " "
                 + "never be null: "
                 + providerName,
             conv);
         AssertJUnit.assertTrue(
             "CurrencyConversion is not flagged as available though it was returned from "
                 + "MonetaryConversions.getConversion(ConversionQuery): "
                 + providerName,
             MonetaryConversions.isConversionAvailable(query));
       }
     } catch (MonetaryException e) {
       // OK, possible!
       AssertJUnit.assertFalse(
           "CurrencyConversion is not flagged as not available, though it was not returned from "
               + "MonetaryConversions.getConversion(ConversionQuery): "
               + providerName,
           MonetaryConversions.isConversionAvailable(query));
     }
   }
 }
  @Test
  public void testAddGroupAdminRoleToAuthorizationGroup() throws Exception {
    String code = AUTH_GROUP_ID;
    AuthorizationGroupPE authGroup = createAuthGroupInDB(code);
    AssertJUnit.assertEquals(
        0,
        daoFactory
            .getRoleAssignmentDAO()
            .listRoleAssignmentsByAuthorizationGroup(authGroup)
            .size());

    GroupPE group = daoFactory.getGroupDAO().listGroups().get(0);
    RoleAssignmentPE roleAssignment = new RoleAssignmentPE();
    roleAssignment.setRole(RoleCode.ADMIN);
    roleAssignment.setGroup(group);
    roleAssignment.setRegistrator(getSystemPerson());

    authGroup.addRoleAssignment(roleAssignment);
    AssertJUnit.assertEquals(
        1,
        daoFactory
            .getRoleAssignmentDAO()
            .listRoleAssignmentsByAuthorizationGroup(authGroup)
            .size());
  }
 @Test
 public void select() {
   HTMLEditor htmlEditorNode =
       (HTMLEditor) getPrimaryStage().getScene().getRoot().lookup(".html-editor");
   Platform.runLater(
       () -> {
         htmlEditor.marathon_select("This html editor test");
       });
   try {
     new Wait("Waiting for html text to be set.") {
       @Override
       public boolean until() {
         String htmlText = htmlEditorNode.getHtmlText();
         return htmlText.equals(
             "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>");
       }
     };
   } catch (Throwable t) {
   }
   AssertJUnit.assertEquals(
       "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>",
       htmlEditor.getText());
   AssertJUnit.assertEquals(
       "<html dir=\"ltr\"><head></head><body contenteditable=\"true\">This html editor test</body></html>",
       htmlEditorNode.getHtmlText());
 }
  public void testBasicTargetRemoteDistributedCallable() throws Exception {
    long taskTimeout = TimeUnit.SECONDS.toMillis(15);
    EmbeddedCacheManager cacheManager1 = manager(0);
    final EmbeddedCacheManager cacheManager2 = manager(1);

    Cache<Object, Object> cache1 = cacheManager1.getCache();
    Cache<Object, Object> cache2 = cacheManager2.getCache();
    DistributedExecutorService des = null;

    try {
      des = new DefaultExecutorService(cache1);
      Address target = cache2.getAdvancedCache().getRpcManager().getAddress();

      DistributedTaskBuilder<Integer> builder =
          des.createDistributedTaskBuilder(new SimpleCallable())
              .failoverPolicy(DefaultExecutorService.RANDOM_NODE_FAILOVER)
              .timeout(taskTimeout, TimeUnit.MILLISECONDS);

      Future<Integer> future = des.submit(target, builder.build());
      AssertJUnit.assertEquals((Integer) 1, future.get());
    } catch (Exception ex) {
      AssertJUnit.fail("Task did not failover properly " + ex);
    } finally {
      des.shutdown();
    }
  }
 /**
  * Access and test different Currency Conversions for the provider in place.
  *
  * <p>Test TCK providers, but also test implementation providers. Doing the ladder it is not
  * possible to test the rates quality, just that rates are returned if necessary.
  */
 @Test(
     description =
         "4.3.1 Access Conversion to term currency code XXX for all providers that support according "
             + "conversion, if"
             + "available a non-null CurrencyConversion must be provided.")
 @SpecAssertion(id = "431-A2", section = "4.3.1")
 public void testConversionsAreAvailable() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     try {
       if (MonetaryConversions.isConversionAvailable("XXX", providerName)) {
         CurrencyConversion conv = MonetaryConversions.getConversion("XXX", providerName);
         AssertJUnit.assertNotNull(
             "CurrencyConversion returned from MonetaryConversions.getConversion(String, "
                 + "String...) should never be null: "
                 + providerName,
             conv);
         AssertJUnit.assertTrue(
             "CurrencyConversion is not flagged as available, "
                 + "though it was returned from MonetaryConversions.getConversion"
                 + "(String,"
                 + " String...): "
                 + providerName,
             MonetaryConversions.isConversionAvailable("XXX", providerName));
       }
     } catch (MonetaryException e) {
       AssertJUnit.assertFalse(
           "CurrencyConversion is not flagged as NOT available, though it is not accessible from "
               + "MonetaryConversions.getConversion(String, String...): "
               + providerName,
           MonetaryConversions.isConversionAvailable("XXX", providerName));
     }
   }
 }
 /**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by "
             + "ConversionQuery/CurrencyUnit.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata3WithContext() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     ConversionQuery query =
         ConversionQueryBuilder.of()
             .setTermCurrency(Monetary.getCurrency("XXX"))
             .setProviderName(providerName)
             .build();
     if (MonetaryConversions.isConversionAvailable(query)) {
       CurrencyConversion conv = MonetaryConversions.getConversion(query);
       ConversionContext ctx = conv.getContext();
       AssertJUnit.assertNotNull(
           "ExchangeProvider must return a valid ProviderContext, but returned null: "
               + providerName,
           ctx);
       AssertJUnit.assertEquals(
           "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
           providerName,
           ctx.getProviderName());
       AssertJUnit.assertNotNull(
           "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
               + providerName,
           ctx.getRateType());
     }
   }
 }
 /**
  * Test if all providers returns valid meta data.
  *
  * @see javax.money.convert.ProviderContext
  */
 @Test(
     description =
         "4.3.1 Test if all CurrencyConversion instances returns valid ConversionContext, accessed by "
             + "currency code.")
 @SpecAssertion(id = "431-A3", section = "4.3.1")
 public void testProviderMetadata2() {
   for (String providerName : MonetaryConversions.getConversionProviderNames()) {
     if (MonetaryConversions.isConversionAvailable("XXX", providerName)) {
       CurrencyConversion conv = MonetaryConversions.getConversion("XXX", providerName);
       ConversionContext ctx = conv.getContext();
       AssertJUnit.assertNotNull(
           "ExchangeProvider must return a valid ProviderContext, but returned null: "
               + providerName,
           ctx);
       AssertJUnit.assertEquals(
           "ExchangeProvider's ProviderContext returns invalid name: " + providerName,
           providerName,
           ctx.getProviderName());
       AssertJUnit.assertNotNull(
           "ExchangeProvider's ProviderContext declares invalid RateTypes to be returned (null): "
               + providerName,
           ctx.getRateType());
     }
   }
 }
 private void testOn(Directory dir, int writeSize, int readSize, Cache cache) throws IOException {
   if (cache != null)
     cache
         .clear(); // needed to make sure no chunks are left over in case of Infinispan
                   // implementation
   final String filename = "chunkTest";
   IndexOutput indexOutput = dir.createOutput(filename);
   byte[] toWrite = fillBytes(writeSize);
   indexOutput.writeBytes(toWrite, writeSize);
   indexOutput.close();
   if (cache != null) {
     AssertJUnit.assertEquals(
         writeSize,
         DirectoryIntegrityCheck.deepCountFileSize(new FileCacheKey(INDEXNAME, filename), cache));
   }
   AssertJUnit.assertEquals(writeSize, indexOutput.length());
   byte[] results = new byte[readSize];
   IndexInput openInput = dir.openInput(filename);
   try {
     openInput.readBytes(results, 0, readSize);
     for (int i = 0; i < writeSize && i < readSize; i++) {
       AssertJUnit.assertEquals(results[i], toWrite[i]);
     }
     if (readSize > writeSize)
       AssertJUnit.fail("should have thrown an IOException for reading past EOF");
   } catch (IOException ioe) {
     if (readSize <= writeSize)
       AssertJUnit.fail("should not have thrown an IOException" + ioe.getMessage());
   }
 }
Esempio n. 16
0
  @Test
  public void test() throws SQLException {

    LOGGER.info("Method test start");
    Throwable got = null;
    try {
      tf0();
    } catch (final Throwable throwable) {
      got = throwable;
    } finally {
      final DataSource dataSource = DataSource.class.cast(context.getBean("dataSource"));
      final Connection connection = dataSource.getConnection();
      final Map<String, Object> resultMap = new HashMap<String, Object>();
      try {
        JDBCHelper.executeQuery("select name from test", connection, resultMap);
      } finally {
        if (connection != null) {
          connection.close();
        }
      }
      AssertJUnit.assertTrue(resultMap.isEmpty());
    }
    AssertJUnit.assertNotNull(got);
    LOGGER.info("Method test end");
  }
Esempio n. 17
0
 @Override
 public void readBytes(byte[] b, int offset, int len) throws IOException {
   final long remainingFileSize = TEST_SIZE - position;
   final long expectedReadSize = Math.min(remainingFileSize, AUTO_BUFFER);
   AssertJUnit.assertEquals(expectedReadSize, b.length);
   AssertJUnit.assertEquals(0, offset);
   AssertJUnit.assertEquals(expectedReadSize, len);
 }
Esempio n. 18
0
 /** @throws Exception On test failure. */
 @AfterClass(groups = {"cache"})
 public void clear() throws Exception {
   fillCache();
   AssertJUnit.assertEquals(5, cache.size());
   cache.clear();
   AssertJUnit.assertEquals(0, cache.size());
   cache.close();
 }
 public void getLeftRightComponents() throws Throwable {
   driver = new JavaDriver();
   WebElement splitPaneLeft = driver.findElement(By.cssSelector("split-pane::left"));
   splitPaneLeft.findElement(By.cssSelector("list"));
   WebElement splitPaneTop = driver.findElement(By.cssSelector("split-pane::top"));
   AssertJUnit.assertEquals(splitPaneTop, splitPaneLeft);
   WebElement splitPaneRight = driver.findElement(By.cssSelector("split-pane::right"));
   WebElement splitPaneBottom = driver.findElement(By.cssSelector("split-pane::bottom"));
   AssertJUnit.assertEquals(splitPaneBottom, splitPaneRight);
 }
 @Test
 public void testFindFederalstatesFromCountryCountriesString() {
   Countries germany = countriesService.find("DE");
   List<Federalstates> federalstates =
       federalstatesService.findFederalstatesFromCountry(germany, "Hamburg");
   AssertJUnit.assertEquals(1, federalstates.size());
   Federalstates federalstate = federalstatesService.findFederalstate(germany, "Hamburg");
   AssertJUnit.assertNotNull(federalstate);
   AssertJUnit.assertEquals("Hamburg", federalstate.getName());
 }
 /** Verifies a file is divided in N chunks */
 private void assertHasNChunks(
     int expectedChunks, Cache cache, String index, String fileName, int bufferSize) {
   int i = 0;
   for (; i < expectedChunks; i++) {
     ChunkCacheKey key = new ChunkCacheKey(index, fileName, i, bufferSize);
     AssertJUnit.assertTrue("should contain key " + key, cache.containsKey(key));
   }
   ChunkCacheKey key = new ChunkCacheKey(index, fileName, i, bufferSize);
   AssertJUnit.assertFalse("should NOT contain key " + key, cache.containsKey(key));
 }
Esempio n. 22
0
  /**
   * Test fetching and translating resource schema.
   *
   * @throws Exception
   */
  @Test
  public void test400FetchResourceSchema() throws Exception {
    final String TEST_NAME = "test400FetchResourceSchema";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN

    // WHEN

    // The schema was fetched during test init. Now just check if it was OK.

    // THEN

    AssertJUnit.assertNotNull(resourceSchema);

    System.out.println(resourceSchema.debugDump());

    Document xsdSchema = resourceSchema.serializeToXsd();

    System.out.println(
        "-------------------------------------------------------------------------------------");
    System.out.println(DOMUtil.printDom(xsdSchema));
    System.out.println(
        "-------------------------------------------------------------------------------------");

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findObjectClassDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME));
    AssertJUnit.assertNotNull(accountDefinition);

    AssertJUnit.assertFalse(
        "No identifiers for account object class ", accountDefinition.getIdentifiers().isEmpty());

    PrismPropertyDefinition uidDefinition =
        accountDefinition.findAttributeDefinition(
            new QName(
                ResourceTypeUtil.getResourceNamespace(resourceType),
                ProvisioningTestUtil.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME));
    AssertJUnit.assertNotNull(uidDefinition);

    for (Definition def : resourceSchema.getDefinitions()) {
      if (def instanceof ResourceAttributeContainerDefinition) {
        ResourceAttributeContainerDefinition rdef = (ResourceAttributeContainerDefinition) def;
        assertNotEmpty("No type name in object class", rdef.getTypeName());
        assertNotEmpty(
            "No native object class for " + rdef.getTypeName(), rdef.getNativeObjectClass());

        // This is maybe not that important, but just for a sake of
        // completeness
        assertNotEmpty("No name for " + rdef.getTypeName(), rdef.getName());
      }
    }
  }
Esempio n. 23
0
 /**
  * Test method for {@link
  * edu.psu.iam.cpr.core.database.tables.validate.ValidateUserComment#validateGetUserCommentsParameters(Database,
  * long, java.lang.String)}.
  *
  * @throws Exception
  * @throws Exception
  */
 @Test
 public final void testValidateUserCommentParameters37() throws Exception {
   openDbConnection();
   UserCommentTable userCommentTable =
       ValidateUserComment.validateGetUserCommentsParameters(
           db, 100000, "cpruser", "USER_COMMENT_MISUSE", "Y", null);
   AssertJUnit.assertTrue(userCommentTable.isReturnHistoryFlag());
   AssertJUnit.assertEquals(
       userCommentTable.getUserCommentType(), UserCommentType.USER_COMMENT_MISUSE);
   db.closeSession();
 }
 public void loggingWorks() {
   LoggingPreferences prefs = new LoggingPreferences();
   prefs.enable(LogType.DRIVER, Level.INFO);
   DesiredCapabilities caps = JavaDriver.defaultCapabilities();
   caps.setCapability(CapabilityType.LOGGING_PREFS, prefs);
   driver = new JavaDriver(caps, caps);
   LogEntries logEntries = driver.manage().logs().get(LogType.DRIVER);
   List<LogEntry> all = logEntries.getAll();
   AssertJUnit.assertEquals(2, all.size());
   AssertJUnit.assertTrue(all.get(0).getMessage().contains("A new session created. sessionID = "));
 }
 /** Access the conversion using the default conversion chain. */
 @Test(description = "4.3.1 Access and test conversion using the default provider chain.")
 @SpecAssertion(id = "431-A5", section = "4.3.1")
 public void testDefaultConversion() {
   ConversionQuery query =
       ConversionQueryBuilder.of().setTermCurrency(Monetary.getCurrency("USD")).build();
   CurrencyConversion conv = MonetaryConversions.getConversion(query);
   AssertJUnit.assertNotNull("No default CurrencyConversion returned for USD.", conv);
   query = ConversionQueryBuilder.of().setTermCurrency(Monetary.getCurrency("EUR")).build();
   conv = MonetaryConversions.getConversion(query);
   AssertJUnit.assertNotNull("No default CurrencyConversion returned for EUR.", conv);
 }
 /** @throws Exception On test failure. */
 @Test(groups = {"passtest"})
 public void resolveMessage() throws Exception {
   final Rule rule = new RepeatCharacterRegexRule();
   final RuleResult result = rule.validate(new PasswordData(new Password("p4&&&&&#n65")));
   for (RuleResultDetail detail : result.getDetails()) {
     AssertJUnit.assertEquals(
         String.format("Password matches the illegal sequence '%s'.", "&&&&&"),
         DEFAULT_RESOLVER.resolve(detail));
     AssertJUnit.assertNotNull(EMPTY_RESOLVER.resolve(detail));
   }
 }
  /**
   * Used to verify that IndexInput.readByte method reads correctly the whole file content comparing
   * the result with the expected sequence of bytes
   *
   * @param dir The Directory containing the file to verify
   * @param fileName The file name to read
   * @param contentFileSizeExpected The size content file expected
   * @throws IOException
   */
  private void assertReadByteWorkingCorrectly(
      Directory dir, String fileName, final int contentFileSizeExpected) throws IOException {
    IndexInput indexInput = dir.openInput(fileName);
    AssertJUnit.assertEquals(contentFileSizeExpected, indexInput.length());
    RepeatableLongByteSequence bytesGenerator = new RepeatableLongByteSequence();

    for (int i = 0; i < contentFileSizeExpected; i++) {
      AssertJUnit.assertEquals(bytesGenerator.nextByte(), indexInput.readByte());
    }
    indexInput.close();
  }
  /**
   * Test method for {@link edu.ltu.stringreporter.StringReporter#getWordLength(java.lang.String)} .
   */
  @Test
  public void testGetWordLength() {
    String w = "kiran";
    int wLength = w.trim().length();

    // Test that length is same
    AssertJUnit.assertEquals(wLength, StringReporter.getWordLength("kiran"));

    // Test that length is correct for hyphenated words
    AssertJUnit.assertEquals(13, StringReporter.getWordLength("computer-aided"));
  }
 @Test(dependsOnMethods = "testRunningOnMultipleCaches")
 public void verifyIntendedChunkCachesUsage() {
   int chunks = 0;
   for (Object key : chunkCache.keySet()) {
     chunks++;
     AssertJUnit.assertEquals(ChunkCacheKey.class, key.getClass());
     Object value = chunkCache.get(key);
     AssertJUnit.assertEquals(byte[].class, value.getClass());
   }
   assert chunks != 0;
 }
  @Test
  public void pojoTest()
      throws ObjectContextDeserializationException, JsonParseException, IOException {
    Tweet tweet = new Tweet();
    tweet.setUser("aloiscochard");
    tweet.setMessage("#ElasticSearch: You know, for search !");
    tweet.setDate(new Date());

    context.add(Tweet.class);

    try {
      // Create
      node.client().admin().indices().prepareCreate("twitter").execute().actionGet();
    } catch (RemoteTransportException e) {
      // (AGR) Ignore 'Index already exists'
    }

    // Mapping
    node.client()
        .admin()
        .indices()
        .preparePutMapping("twitter")
        .setType(TEST_TYPE)
        .setSource(context.getMapping(Tweet.class))
        .execute()
        .actionGet();
    // Add
    node.client()
        .prepareIndex("twitter", "tweet", "1")
        .setSource(context.write(tweet))
        .execute()
        .actionGet();
    // Refresh
    node.client().admin().indices().prepareRefresh("twitter").execute().actionGet();
    // Search
    SearchResponse searchResponse =
        node.client()
            .prepareSearch("twitter")
            .setSearchType(SearchType.DFS_QUERY_AND_FETCH)
            .setQuery(QueryBuilders.termQuery("user", "aloiscochard"))
            .setExplain(true)
            .execute()
            .actionGet();
    for (SearchHit hit : searchResponse.getHits()) {
      Tweet t = context.read(hit);
      AssertJUnit.assertNotNull(t);
      AssertJUnit.assertEquals(tweet.getUser(), t.getUser());
      AssertJUnit.assertEquals(tweet.getMessage(), t.getMessage());
      AssertJUnit.assertEquals(tweet.getDate(), t.getDate());
      return;
    }
    Assert.fail("Expecting *one* match, but got " + searchResponse.getHits().hits().length);
  }