org.testng.annotations.Test Java Examples

The following examples show how to use org.testng.annotations.Test. 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 check out the related API usage on the sidebar.
Example #1
Source File: Bug4966143.java    From openjdk-jdk9 with 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 #2
Source File: ListDefaults.java    From openjdk-jdk8u with 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 #3
Source File: ZMSClientTest.java    From athenz with 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 #4
Source File: ConstructorReceiverTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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 #5
Source File: TestTSOClientRequestAndResponseBehaviours.java    From phoenix-omid with Apache License 2.0 6 votes vote down vote up
@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 #6
Source File: TCKIsoChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #7
Source File: TestJapaneseChronoImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 File: ValidatorTest.java    From validator-badge with 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 File: ExpireAfterVarTest.java    From caffeine with 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 #10
Source File: TCKMinguoChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 #11
Source File: DbxClientV1IT.java    From dropbox-sdk-java with 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 #12
Source File: WritableBufferImplTest.java    From incubator-datasketches-memory with Apache License 2.0 6 votes vote down vote up
@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 #13
Source File: DefaultRequestCoordinatorTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@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 #14
Source File: IlluminaFileUtilTest.java    From picard with 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 #15
Source File: TCKMinguoChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 #16
Source File: ConverterTest.java    From ConfigJSR with 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 #17
Source File: ActionTestControllerTest.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
/** Start Double Type Related Action Test */
@Test
public void callPublicMethodWithDoubleParam() {
    Assert.assertNull(controller.getModel().getDoubleValue());
    final double value = 10.0;
    controller.invoke(PUBLIC_WITH_DOUBLE_PARAM_ACTION, new Param(PARAM_NAME, value));
    Assert.assertEquals(controller.getModel().getDoubleValue().doubleValue(), value);
}
 
Example #18
Source File: TCKLocalDate.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="until")
public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) {
    LocalDate start = LocalDate.of(y1, m1, d1);
    LocalDate end = LocalDate.of(y2, m2, d2);
    Period test = start.until(end);
    assertEquals(test.getYears(), ye);
    assertEquals(test.getMonths(), me);
    assertEquals(test.getDays(), de);
}
 
Example #19
Source File: UpdateRefSerializerTest.java    From emodb with 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 #20
Source File: EnvironmentInfoTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Test
private void testInfo() {
    String infoUrl = getItContext().getContextParam(EnvironmentTest.ENVIRONMENT_SERVER_ROOT);
    Client client = ClientBuilder.newBuilder().build();
    WebTarget target = client.target(infoUrl).path("info");
    CBVersion cbVersion = target.request().get().readEntity(CBVersion.class);

    Assert.assertEquals(cbVersion.getApp().getName(), "environment");
    if (getTestParameter().get("target.cbd.version") != null) {
        LOGGER.warn("TARGET_CBD_VERSION is provided.");
        Assert.assertEquals(cbVersion.getApp().getVersion(), getTestParameter().get("target.cbd.version"));
    } else {
        LOGGER.warn("TARGET_CBD_VERSION is not provided!");
    }
}
 
Example #21
Source File: AuthenticationTlsHostnameVerificationTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #22
Source File: TestJapaneseChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="transitions")
public void test_transitions(JapaneseEra era, int yearOfEra, int month, int dayOfMonth, int gregorianYear) {
    assertEquals(JAPANESE.prolepticYear(era, yearOfEra), gregorianYear);

    JapaneseDate jdate1 = JapaneseDate.of(era, yearOfEra, month, dayOfMonth);
    JapaneseDate jdate2 = JapaneseDate.of(gregorianYear, month, dayOfMonth);
    assertEquals(jdate1, jdate2);
}
 
Example #23
Source File: DriverManagerTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register a driver and make sure you find it via its URL. Deregister the
 * driver and validate it is not longer registered
 *
 * @throws Exception
 */
@Test()
public void test15() throws Exception {
    DriverManager.registerDriver(new StubDriver());
    Driver d = DriverManager.getDriver(StubDriverURL);
    assertTrue(d != null);
    assertTrue(isDriverRegistered(d));
    DriverManager.deregisterDriver(d);
    assertFalse(isDriverRegistered(d));
}
 
Example #24
Source File: NotificationManagementAPIJMeterTestCase.java    From product-iots with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: ContextImplTest.java    From cryptotrader with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testClose() throws Exception {

    target.close();

    verify(contexts.get("c1")).close();
    verify(contexts.get("c2")).close();
    verify(contexts.get("c3")).close();
    verify(contexts.get("c4")).close();

}
 
Example #26
Source File: RowSetMetaDataTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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 #27
Source File: TCKJapaneseChronology.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_Japanese_badEras() {
    int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000};
    for (int badEra : badEras) {
        try {
            Era era = JapaneseChronology.INSTANCE.eraOf(badEra);
            fail("JapaneseChronology.eraOf returned " + era + " + for invalid eraValue " + badEra);
        } catch (DateTimeException ex) {
            // ignore expected exception
        }
    }
}
 
Example #28
Source File: SheetTest.java    From SODS with Apache License 2.0 5 votes vote down vote up
@Test
public void testClone() throws Exception {
    Sheet sheet = generateASheet();
    Sheet other = (Sheet) sheet.clone();

    assertEquals(sheet, other);
}
 
Example #29
Source File: HashRangeExclusiveStickyKeyConsumerSelectorTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleRangeConflict() throws BrokerServiceException.ConsumerAssignException {
    HashRangeExclusiveStickyKeyConsumerSelector selector = new HashRangeExclusiveStickyKeyConsumerSelector(10);
    Consumer consumer1 = mock(Consumer.class);
    PulsarApi.KeySharedMeta keySharedMeta1 = PulsarApi.KeySharedMeta.newBuilder()
            .setKeySharedMode(PulsarApi.KeySharedMode.STICKY)
            .addHashRanges(PulsarApi.IntRange.newBuilder().setStart(2).setEnd(5).build())
            .build();
    when(consumer1.getKeySharedMeta()).thenReturn(keySharedMeta1);
    Assert.assertEquals(consumer1.getKeySharedMeta(), keySharedMeta1);
    selector.addConsumer(consumer1);
    Assert.assertEquals(selector.getRangeConsumer().size(),2);

    final List<PulsarApi.IntRange> testRanges = new ArrayList<>();
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(4).setEnd(6).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(1).setEnd(3).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(2).setEnd(2).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(5).setEnd(5).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(1).setEnd(5).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(2).setEnd(6).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(2).setEnd(5).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(1).setEnd(6).build());
    testRanges.add(PulsarApi.IntRange.newBuilder().setStart(8).setEnd(6).build());

    for (PulsarApi.IntRange testRange : testRanges) {
        Consumer consumer = mock(Consumer.class);
        PulsarApi.KeySharedMeta keySharedMeta = PulsarApi.KeySharedMeta.newBuilder()
                .setKeySharedMode(PulsarApi.KeySharedMode.STICKY)
                .addHashRanges(testRange)
                .build();
        when(consumer.getKeySharedMeta()).thenReturn(keySharedMeta);
        Assert.assertEquals(consumer.getKeySharedMeta(), keySharedMeta);
        try {
            selector.addConsumer(consumer);
            Assert.fail("should be failed");
        } catch (BrokerServiceException.ConsumerAssignException ignore) {
        }
        Assert.assertEquals(selector.getRangeConsumer().size(),2);
    }
}
 
Example #30
Source File: DeviceTaskManagerServiceTest.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@Test(groups = "Device Task Manager Service Test Group", dependsOnMethods = "testUpdateUnscheduledTask",
        expectedExceptions = {DeviceMgtTaskException.class })
public void testStartTaskWhenFailedToRegisterTaskType()
        throws DeviceMgtTaskException, TaskException {
    TaskService taskService = Mockito.mock(TestTaskServiceImpl.class);
    Mockito.doThrow(new TaskException("Unable to register task type", TaskException.Code.UNKNOWN)).when(taskService)
            .registerTaskType(TASK_TYPE);
    DeviceManagementDataHolder.getInstance().setTaskService(taskService);
    this.deviceTaskManagerService.startTask(TestDataHolder.TEST_DEVICE_TYPE,
            TestDataHolder.generateMonitoringTaskConfig(true, 60000, 2));
}