Java Code Examples for org.testng.annotations.Test

The following examples show how to use org.testng.annotations.Test. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, LocalDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
    if (strict) {
        LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
 
Example 2
Source Project: caffeine   Source File: ExpireAfterVarTest.java    License: Apache License 2.0 6 votes vote down vote up
@CacheSpec(implementation = Implementation.Caffeine,
    population = Population.FULL, expiry = CacheExpiry.MOCKITO)
@Test(dataProvider = "caches", expectedExceptions = ExpirationException.class)
public void put_update_expiryFails(Cache<Integer, Integer> cache, CacheContext context,
    VarExpiration<Integer, Integer> expireVariably) {
  OptionalLong duration = expireVariably.getExpiresAfter(context.firstKey(), NANOSECONDS);
  try {
    context.ticker().advance(1, TimeUnit.HOURS);
    when(context.expiry().expireAfterUpdate(any(), any(), anyLong(), anyLong()))
        .thenThrow(ExpirationException.class);
    cache.put(context.firstKey(), context.absentValue());
  } finally {
    context.ticker().advance(-1, TimeUnit.HOURS);
    assertThat(cache.asMap(), equalTo(context.original()));
    assertThat(expireVariably.getExpiresAfter(context.firstKey(), NANOSECONDS), is(duration));
  }
}
 
Example 3
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
    fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
 
Example 4
@Test
public void checkCompareToHeap() {
  byte[] arr1 = new byte[] {0, 1, 2, 3};
  byte[] arr2 = new byte[] {0, 1, 2, 4};
  byte[] arr3 = new byte[] {0, 1, 2, 3, 4};

  Buffer buf1 = Memory.wrap(arr1).asBuffer();
  Buffer buf2 = Memory.wrap(arr2).asBuffer();
  Buffer buf3 = Memory.wrap(arr3).asBuffer();

  int comp = buf1.compareTo(0, 3, buf2, 0, 3);
  assertEquals(comp, 0);
  comp = buf1.compareTo(0, 4, buf2, 0, 4);
  assertEquals(comp, -1);
  comp = buf2.compareTo(0, 4, buf1, 0, 4);
  assertEquals(comp, 1);
  //different lengths
  comp = buf1.compareTo(0, 4, buf3, 0, 5);
  assertEquals(comp, -1);
  comp = buf3.compareTo(0, 5, buf1, 0, 4);
  assertEquals(comp, 1);
}
 
Example 5
Source Project: picard   Source File: IlluminaFileUtilTest.java    License: MIT License 6 votes vote down vote up
@Test(expectedExceptions = PicardException.class, dataProvider = "missingCycleDataRanges")
public void perTilePerCycleFileUtilsMissingCycleTest(final List<Range> cycleRangesToMake) {
    final SupportedIlluminaFormat format = SupportedIlluminaFormat.Bcl;

    for (final Range range : cycleRangesToMake) {
        makeFiles(format, intensityDir, DEFAULT_LANE, DEFAULT_TILES, cycleRange(range), null);
    }

    final IlluminaFileUtil fileUtil = new IlluminaFileUtil(basecallDir, DEFAULT_LANE);
    final PerTilePerCycleFileUtil pcfu = (PerTilePerCycleFileUtil) fileUtil.getUtil(format);

    Assert.assertTrue(pcfu.filesAvailable());
    final int[] cycles = cycleRange(9, 16);
    final CycleIlluminaFileMap cfm = pcfu.getFiles(cycles);
    cfm.assertValid(DEFAULT_TILES, cycles);
}
 
Example 6
Source Project: openjdk-jdk9   Source File: Bug4966143.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test1() throws Exception {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    dbf.setValidating(true);
    dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
    dbf.setAttribute(SCHEMA_SOURCE, Bug4966143.class.getResource("Bug4966143.xsd").toExternalForm());

    Document document = dbf.newDocumentBuilder().parse(Bug4966143.class.getResource("Bug4966143.xml").toExternalForm());

    TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_LIST));
    Assert.assertFalse(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_RESTRICTION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_EXTENSION));
    Assert.assertTrue(type.isDerivedFrom("testNS", "Test", 0));
}
 
Example 7
@Test(dataProvider="RangeVersusCalendar")
public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) {
    Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese");
    assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale");

    Calendar cal = java.util.Calendar.getInstance(locale);
    assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type");

    JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate);

    // Convert to millis and set Japanese Calendar to that start date (at GMT)
    OffsetDateTime jodt = OffsetDateTime.of(isoStartDate, LocalTime.MIN, ZoneOffset.UTC);
    long millis = jodt.toInstant().toEpochMilli();
    cal.setTimeZone(TimeZone.getTimeZone("GMT+00"));
    cal.setTimeInMillis(millis);

    while (jDate.isBefore(isoEndDate)) {
        assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + ";  cal: " + cal);
        assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate);
        assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate);

        jDate = jDate.plus(1, ChronoUnit.DAYS);
        cal.add(Calendar.DAY_OF_MONTH, 1);
    }
}
 
Example 8
Source Project: validator-badge   Source File: ValidatorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
    public void testDebugValid20SpecByContent() throws Exception {
        final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
        final JsonNode rootNode = mapper.readTree(Files.readAllBytes(java.nio.file.Paths.get(getClass().getResource(VALID_20_YAML).toURI())));
        ValidatorController validator = new ValidatorController();
        ResponseContext response = validator.reviewByContent(new RequestContext(), rootNode);

        // since inflector 2.0.3 content type is managed by inflector according to request headers and spec
/*
        Assert.assertEquals(APPLICATION, response.getContentType().getType());
        Assert.assertEquals(JSON, response.getContentType().getSubtype());
*/
        ValidationResponse validationResponse = (ValidationResponse) response.getEntity();
        Assert.assertTrue(validationResponse.getMessages() == null || validationResponse.getMessages().size() == 0);
        Assert.assertTrue(validationResponse.getSchemaValidationMessages() == null || validationResponse.getSchemaValidationMessages().size() == 0);
    }
 
Example 9
Source Project: athenz   Source File: ZMSClientTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdatePrincipal() {
    String zmsUrl = getZMSUrl();
    ZMSClient client = new ZMSClient(zmsUrl);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    Domain domain = new Domain().setName("domain");
    Mockito.when(c.getDomain("domain")).thenReturn(domain);
    UserToken userToken = new UserToken().setHeader("Header").setToken("Token");
    Mockito.when(c.getUserToken("joe", null, true)).thenReturn(userToken);
    client.setZMSRDLGeneratedClient(c);
    assertNotNull(client);

    // add credentials

    Authority authority = new com.yahoo.athenz.auth.impl.UserAuthority();
    Principal p = SimplePrincipal.create("user", "joe", "v=U1;d=user;n=joe;s=signature",
            0, authority);

    client.addCredentials(p);
    assertNotNull(client.getDomain("domain"));
    assertNotNull(client.getDomain("domain"));
}
 
Example 10
@Test(dataProvider = "data")
public void testAnnotatedReturn(Class<?> toTest, Class<?> ctorParamType,
        Integer returnVal, Integer receiverVal) throws NoSuchMethodException {
    Constructor c;
    if (ctorParamType == null)
        c = toTest.getDeclaredConstructor();
    else
        c = toTest.getDeclaredConstructor(ctorParamType);

    AnnotatedType annotatedReturnType = c.getAnnotatedReturnType();
    Annotation[] returnAnnotations = annotatedReturnType.getAnnotations();

    assertEquals(returnAnnotations.length, 1, "expecting a 1 element array. Looking at 'length': ");
    assertEquals(((Annot)returnAnnotations[0]).value(), returnVal.intValue(), " wrong annotation found. Found " +
            returnAnnotations[0] +
            " should find @Annot with value=" +
            returnVal);
}
 
Example 11
@Test(dataProvider = "tenantDomainProvider")
public void testTenantDomainInAuthenticationContext(boolean isTenantQualifiedUrlModeEnabled,
                                                    String tenantDomainInThreadLocal,
                                                    String tenantDomainInRequestParam,
                                                    String expected) throws Exception {

    mockStatic(IdentityTenantUtil.class);
    when(IdentityTenantUtil.isTenantQualifiedUrlsEnabled()).thenReturn(isTenantQualifiedUrlModeEnabled);
    when(IdentityTenantUtil.getTenantDomainFromContext()).thenReturn(tenantDomainInThreadLocal);

    HttpServletRequest request = mock(HttpServletRequest.class);
    when(request.getParameter(TYPE)).thenReturn("oauth");
    when(request.getParameter(LOGOUT)).thenReturn("true");
    when(request.getParameter(TENANT_DOMAIN)).thenReturn(tenantDomainInRequestParam);

    HttpServletResponse response = mock(HttpServletResponse.class);

    AuthenticationContext context = requestCoordinator.initializeFlow(request, response);

    assertEquals(context.getTenantDomain(), expected);
}
 
Example 12
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
 
Example 13
Source Project: ConfigJSR   Source File: ConverterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDonaldConversionWithMultipleLambdaConverters() {
    // defines 2 config with the lambda converters defined in different orders.
    // Order must not matter, the lambda with the upper case must always be used as it has the highest priority
    Config config1 = ConfigProviderResolver.instance().getBuilder().addDefaultSources()
        .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase()))
        .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s))
        .build();
    Config config2 = ConfigProviderResolver.instance().getBuilder().addDefaultSources()
        .withConverter(Donald.class, 100, (s) -> Donald.iLikeDonald(s))
        .withConverter(Donald.class, 101, (s) -> Donald.iLikeDonald(s.toUpperCase()))
        .build();

    Donald donald = config1.getValue("tck.config.test.javaconfig.converter.donaldname", Donald.class);
    Assert.assertNotNull(donald);
    Assert.assertEquals(donald.getName(), "DUCK",
        "The converter with the highest priority (using upper case) must be used.");
    donald = config2.getValue("tck.config.test.javaconfig.converter.donaldname", Donald.class);
    Assert.assertNotNull(donald);
    Assert.assertEquals(donald.getName(), "DUCK",
        "The converter with the highest priority (using upper case) must be used.");
}
 
Example 14
Source Project: dropbox-sdk-java   Source File: DbxClientV1IT.java    License: MIT License 6 votes vote down vote up
@Test
public void testSearch() throws Exception {
    addFile(p("search - a.txt"), 100);
    client.createFolder(p("sub"));
    addFile(p("sub/search - b.txt"), 200);

    List<DbxEntry> results;

    results = client.searchFileAndFolderNames(p(), "search");
    assertEquals(results.size(), 2);

    results = client.searchFileAndFolderNames(p("sub"), "search");
    assertEquals(results.size(), 1);

    results = client.searchFileAndFolderNames(p(), "a.txt");
    assertEquals(results.size(), 1);
    assertEquals(results.get(0).name, "search - a.txt");
}
 
Example 15
@Test(timeOut = 30_000)
public void testDuplicateCommit() throws Exception {

    TSOClient client = TSOClient.newInstance(tsoClientConf);
    TSOClientOneShot clientOneShot = new TSOClientOneShot(TSO_SERVER_HOST, TSO_SERVER_PORT);

    long ts1 = client.getNewStartTimestamp().get();

    TSOProto.Response response1 = clientOneShot.makeRequest(createCommitRequest(ts1, false, testWriteSet));
    TSOProto.Response response2 = clientOneShot.makeRequest(createCommitRequest(ts1, true, testWriteSet));
    if (client.isLowLatency()) {
        assertTrue(response1.hasCommitResponse());
        assertTrue(response2.getCommitResponse().getAborted());
    } else
        assertEquals(response2.getCommitResponse().getCommitTimestamp(),
                response1.getCommitResponse().getCommitTimestamp(),
                "Commit timestamp should be the same");
}
 
Example 16
Source Project: openjdk-jdk8u   Source File: ListDefaults.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testRemoveIfThrowsCME() {
    @SuppressWarnings("unchecked")
    final CollectionSupplier<List<Integer>> supplier = new CollectionSupplier(LIST_CME_SUPPLIERS, SIZE);
    for (final CollectionSupplier.TestCase<List<Integer>> test : supplier.get()) {
        final List<Integer> list = test.collection;

        if (list.size() <= 1) {
            continue;
        }
        boolean gotException = false;
        try {
            // bad predicate that modifies its list, should throw CME
            list.removeIf(list::add);
        } catch (ConcurrentModificationException cme) {
            gotException = true;
        }
        if (!gotException) {
            fail("expected CME was not thrown from " + test);
        }
    }
}
 
Example 17
/**
 * This test verifies {@link DefaultHostnameVerifier} behavior and gives fair idea about host matching result
 *
 * @throws Exception
 */
@Test
public void testDefaultHostVerifier() throws Exception {
    log.info("-- Starting {} test --", methodName);
    Method matchIdentityStrict = DefaultHostnameVerifier.class.getDeclaredMethod("matchIdentityStrict",
            String.class, String.class, PublicSuffixMatcher.class);
    matchIdentityStrict.setAccessible(true);
    Assert.assertTrue((boolean) matchIdentityStrict.invoke(null, "pulsar", "pulsar", null));
    Assert.assertFalse((boolean) matchIdentityStrict.invoke(null, "pulsar.com", "pulsar", null));
    Assert.assertTrue((boolean) matchIdentityStrict.invoke(null, "pulsar-broker1.com", "pulsar*.com", null));
    // unmatched remainder: "1-broker." should not contain "."
    Assert.assertFalse((boolean) matchIdentityStrict.invoke(null, "pulsar-broker1.com", "pulsar*com", null));
    Assert.assertFalse((boolean) matchIdentityStrict.invoke(null, "pulsar.com", "*", null));
    log.info("-- Exiting {} test --", methodName);
}
 
Example 18
Source Project: brooklyn-server   Source File: JcloudsLocationTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCombinationOfInputstoIntPortArray() {
    Collection<Object> portInputs = Lists.newLinkedList();
    portInputs.add(1);
    portInputs.add("2");
    portInputs.add("3-100");
    portInputs.add("101,102,103");
    portInputs.add("[104,105,106]");
    portInputs.add(new int[] {107, 108, 109});
    portInputs.add(new String[] {"110", "111", "112"});
    portInputs.add(new Object[] {113, 114, 115});

    int[] intArray = Ints.toArray(ContiguousSet.create(Range.closed(1, 115), DiscreteDomain.integers()));
    Assert.assertEquals(intArray, JcloudsLocation.toIntPortArray(portInputs));
}
 
Example 19
Source Project: TencentKona-8   Source File: TCKChronology.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "calendarNameAndType")
public void test_required_calendars(String chronoId, String calendarSystemType) {
    Chronology chrono = Chronology.of(chronoId);
    assertNotNull(chrono, "Required calendar not found by ID: " + chronoId);
    chrono = Chronology.of(calendarSystemType);
    assertNotNull(chrono, "Required calendar not found by type: " + chronoId);
    Set<Chronology> cals = Chronology.getAvailableChronologies();
    assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars");
}
 
Example 20
Source Project: jdk8u60   Source File: TCKZonedDateTime.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_compareTo_time1() {
    ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100);
    ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0100);  // a is before b due to time
    assertEquals(a.compareTo(b) < 0, true);
    assertEquals(b.compareTo(a) > 0, true);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
}
 
Example 21
@Test
public void testVarArgs() throws ScriptException {
    // Sole NativeArray in vararg position becomes vararg array itself
    runTest("assertVarArg_42_17", "[42, 17]");
    // NativeArray in vararg position becomes an argument if there are more arguments
    runTest("assertVarArg_array_17", "[42], 18");
    // Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
    runTest("assertVarArg_function", "function() { return 'Hello' }");
}
 
Example 22
/**
 * CircuitBreaker is enabled on the method so the policy should be applied
 */
@Test
public void testCircuitBreaker() {
    // Always get TestException on first execution
    Assert.assertThrows(TestException.class, () -> disableClient.failWithCircuitBreaker());
    // Should get CircuitBreakerOpenException on second execution because CircuitBreaker is enabled
    Assert.assertThrows(CircuitBreakerOpenException.class, () -> disableClient.failWithCircuitBreaker());
}
 
Example 23
Source Project: emodb   Source File: MegabusConfigTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void ensureMegabusDefaultConfigDeserialization()
    throws IOException, URISyntaxException, ConfigurationException {
    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
    ObjectMapper mapper = CustomJsonObjectMapperFactory.build(new YAMLFactory());
    ConfigurationFactory configurationFactory = new ConfigurationFactory(MegabusConfiguration.class, validator, mapper, "dw");
    // Make sure that our config files are up to date
    configurationFactory.build(
        new File(MegabusConfiguration.class.getResource("/emodb-megabus-config.yaml").toURI()));
}
 
Example 24
Source Project: bdt   Source File: MiscTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckValueInvalidComparison() throws Exception {
    ThreadProperty.set("class", this.getClass().getCanonicalName());
    CommonG commong = new CommonG();
    MiscSpec misc = new MiscSpec(commong);

    assertThatExceptionOfType(Exception.class).isThrownBy(() -> misc.checkValue("BlaBlaBla", "not valid comparison", "BleBleBle")).withMessageContaining("Not a valid comparison. Valid ones are: is | matches | is higher than | is higher than or equal to | is lower than | is lower than or equal to | contains | does not contain | is different from");
}
 
Example 25
@Test(description = "Testing get devices with correct request when unable to get devices.")
public void testGetDeviceTypesByUserException() throws DeviceManagementException {
    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService"))
            .toReturn(this.deviceManagementProviderService);
    PowerMockito.stub(PowerMockito.method(CarbonContext.class, "getThreadLocalCarbonContext"))
            .toReturn(Mockito.mock(CarbonContext.class, Mockito.RETURNS_MOCKS));
    Mockito.when(this.deviceManagementProviderService.getDevicesOfUser(Mockito.any(PaginationRequest.class)))
            .thenThrow(new DeviceManagementException());

    Response response = this.deviceManagementService.getDeviceByUser(true, 10, 5);
    Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
 
Example 26
Source Project: openjdk-8   Source File: LongNodeTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "nodes")
public void testTruncate(long[] array, Node.OfLong n) {
    int[] nums = new int[] { 0, 1, array.length / 2, array.length - 1, array.length };
    for (int start : nums)
        for (int end : nums) {
            if (start < 0 || end < 0 || end < start || end > array.length)
                continue;
            Node.OfLong slice = n.truncate(start, end, Long[]::new);
            long[] asArray = slice.asPrimitiveArray();
            for (int k = start; k < end; k++)
                assertEquals(array[k], asArray[k - start]);
        }
}
 
Example 27
Source Project: emodb   Source File: UpdateRefSerializerTest.java    License: Apache License 2.0 5 votes vote down vote up
/** By default, serialized Astyanax Composite objects use a lot of memory (8192 bytes). */
@Test
public void testCapacity() {
    UpdateRef ref = new UpdateRef("test-table", "test-key", TimeUUIDs.newUUID(), ImmutableSet.of("aaaignore","aaaignore","aaaignore"));
    ByteBuffer buf = UpdateRefSerializer.toByteBuffer(ref);

    assertTrue(buf.capacity() < 128, Integer.toString(buf.capacity()));
}
 
Example 28
@Test
public void test_adjacent_lenient_firstVariableWidth_fails() throws Exception {
    // fails because literal is a number and variable width parse greedily absorbs it
    DateTimeFormatter f = builder.parseLenient().appendValue(HOUR_OF_DAY).appendValue(MINUTE_OF_HOUR, 2).appendLiteral('9').toFormatter(Locale.UK);
    ParsePosition pp = new ParsePosition(0);
    TemporalAccessor parsed = f.parseUnresolved("12309", pp);
    assertEquals(pp.getErrorIndex(), 5);
    assertEquals(parsed, null);
}
 
Example 29
@Test(dataProvider = "trueFalse")
public void test40(Boolean b) throws Exception {
    rsmd.setAutoIncrement(1, b);
    rsmd.setCaseSensitive(1, b);
    rsmd.setCurrency(1, b);
    rsmd.setSearchable(1, b);
    rsmd.setSigned(1, b);
    assertTrue(rsmd.isAutoIncrement(1) == b);
    assertTrue(rsmd.isCaseSensitive(1) == b);
    assertTrue(rsmd.isCurrency(1) == b);
    assertTrue(rsmd.isSearchable(1) == b);
    assertTrue(rsmd.isSigned(1) == b);
}
 
Example 30
@Test(description = "This test case tests the Notification Management APIs")
public void NotificationManagementTest() throws AutomationFrameworkException {
    URL url = Thread.currentThread().getContextClassLoader()
            .getResource("jmeter-scripts" + File.separator + "NotificationManagementAPI.jmx");
    JMeterTest script = new JMeterTest(new File(url.getPath()));
    JMeterTestManager manager = new JMeterTestManager();
    log.info("Running notification management api test cases using jmeter scripts");
    manager.runTest(script);
}