org.junit.Test Java Examples

The following examples show how to use org.junit.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: PreparedStatement2IT.java    From snowflake-jdbc with Apache License 2.0 6 votes vote down vote up
/**
 * SNOW-31746
 */
@Test
public void testConstOptLimitBind() throws SQLException
{
  try (Connection connection = init())
  {
    String stmtStr = "select 1 limit ? offset ?";
    try (PreparedStatement prepStatement = connection.prepareStatement(stmtStr))
    {
      prepStatement.setInt(1, 10);
      prepStatement.setInt(2, 0);
      try (ResultSet resultSet = prepStatement.executeQuery())
      {
        resultSet.next();
        assertThat(resultSet.getInt(1), is(1));
        assertThat(resultSet.next(), is(false));
      }
    }
  }
}
 
Example #2
Source File: FileTest.java    From salt-netapi-client with MIT License 6 votes vote down vote up
@Test
public final void testIsLinkTrue() {
    // true response
    stubFor(any(urlMatching("/"))
            .willReturn(aResponse()
                    .withStatus(HttpURLConnection.HTTP_OK)
                    .withHeader("Content-Type", "application/json")
                    .withBody(JSON_TRUE_RESPONSE)));

    LocalCall<Boolean> call = File.isLink("/test/");
    assertEquals("file.is_link", call.getPayload().get("fun"));

    Map<String, Result<Boolean>> response = call.callSync(client,
            new MinionList("minion1"), AUTH).toCompletableFuture().join();
    assertTrue(response.get("minion1").result().get());
}
 
Example #3
Source File: WhereClauseOptimizerTest.java    From phoenix with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testKeyRangeExpression1() throws SQLException {
    String tenantId = "000000000000001";
    String keyPrefix1 = "002";
    String keyPrefix2= "004";
    String query = "select * from atable where organization_id='" + tenantId + "' and substr(entity_id,1,3) >= '" + keyPrefix1 + "' and substr(entity_id,1,3) < '" + keyPrefix2 + "'";
    Scan scan = new Scan();
    List<Object> binds = Collections.emptyList();
    compileStatement(query, scan, binds);
    assertNull(scan.getFilter());

    byte[] startRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(PDataType.VARCHAR.toBytes(keyPrefix1),15));
    assertArrayEquals(startRow, scan.getStartRow());
    byte[] stopRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(PDataType.VARCHAR.toBytes(keyPrefix2),15));
    assertArrayEquals(stopRow, scan.getStopRow());
}
 
Example #4
Source File: BusinessObjectDefinitionServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetBusinessObjectDefinitionsLowerCaseParameters()
{
    // Create and persist business object definition entities.
    for (BusinessObjectDefinitionKey key : businessObjectDefinitionDaoTestHelper.getTestBusinessObjectDefinitionKeys())
    {
        businessObjectDefinitionDaoTestHelper
            .createBusinessObjectDefinitionEntity(key.getNamespace(), key.getBusinessObjectDefinitionName(), DATA_PROVIDER_NAME, BDEF_DESCRIPTION,
                NO_ATTRIBUTES);
    }

    // Retrieve a list of business object definition keys for the specified namespace using lower case namespace value.
    BusinessObjectDefinitionKeys resultKeys = businessObjectDefinitionService.getBusinessObjectDefinitions(NAMESPACE.toLowerCase());

    // Validate the returned object.
    assertEquals(businessObjectDefinitionDaoTestHelper.getExpectedBusinessObjectDefinitionKeysForNamespace(), resultKeys.getBusinessObjectDefinitionKeys());
}
 
Example #5
Source File: PrintingResultHandlerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void modelAndView() throws Exception {
	BindException bindException = new BindException(new Object(), "target");
	bindException.reject("errorCode");

	ModelAndView mav = new ModelAndView("viewName");
	mav.addObject("attrName", "attrValue");
	mav.addObject(BindingResult.MODEL_KEY_PREFIX + "attrName", bindException);

	this.mvcResult.setMav(mav);
	this.handler.handle(this.mvcResult);

	assertValue("ModelAndView", "View name", "viewName");
	assertValue("ModelAndView", "View", null);
	assertValue("ModelAndView", "Attribute", "attrName");
	assertValue("ModelAndView", "value", "attrValue");
	assertValue("ModelAndView", "errors", bindException.getAllErrors());
}
 
Example #6
Source File: RulesEntityTest.java    From auth0-java with MIT License 6 votes vote down vote up
@Test
public void shouldCreateRule() throws Exception {
    Request<Rule> request = api.rules().create(new Rule("my-rule", "function(){}"));
    assertThat(request, is(notNullValue()));

    server.jsonResponse(MGMT_RULE, 200);
    Rule response = request.execute();
    RecordedRequest recordedRequest = server.takeRequest();

    assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/rules"));
    assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
    assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));

    Map<String, Object> body = bodyFromRequest(recordedRequest);
    assertThat(body.size(), is(2));
    assertThat(body, hasEntry("name", (Object) "my-rule"));
    assertThat(body, hasEntry("script", (Object) "function(){}"));

    assertThat(response, is(notNullValue()));
}
 
Example #7
Source File: BlueprintToBlueprintV4ResponseConverterTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Test
public void testConvertContainsExpectedMultipleKeyValuePairInTagsProperty() {
    String nameKey = "name";
    String nameValue = "test";
    String ageKey = "address";
    String ageValue = "something else";
    Blueprint source = createSource();
    source.setTags(JSON_TO_STRING.convertToEntityAttribute(String.format("{\"%s\":\"%s\", \"%s\":\"%s\"}", nameKey, nameValue, ageKey, ageValue)));

    BlueprintV4Response result = underTest.convert(source);

    Assert.assertNotNull(result.getTags());
    Assert.assertTrue(result.getTags().containsKey(nameKey));
    Assert.assertTrue(result.getTags().containsKey(ageKey));
    Assert.assertNotNull(result.getTags().get(nameKey));
    Assert.assertNotNull(result.getTags().get(ageKey));
    Assert.assertEquals(nameValue, result.getTags().get(nameKey));
    Assert.assertEquals(ageValue, result.getTags().get(ageKey));
}
 
Example #8
Source File: FbStatusTest.java    From takes with MIT License 6 votes vote down vote up
/**
 * FbStatus can send correct default response with text/plain
 * body consisting of a status code, status message and message
 * from an exception.
 * @throws Exception If some problem inside
 */
@Test
public void sendsCorrectDefaultResponse() throws Exception {
    final int code = HttpURLConnection.HTTP_NOT_FOUND;
    final RqFallback req = new RqFallback.Fake(
        code,
        new IOException("Exception message")
    );
    final RsPrint response = new RsPrint(
        new FbStatus(code).route(req).get()
    );
    MatcherAssert.assertThat(
        response.printBody(),
        Matchers.equalTo("404 Not Found: Exception message")
    );
    MatcherAssert.assertThat(
        response.printHead(),
        Matchers.both(
            Matchers.containsString("Content-Type: text/plain")
        ).and(Matchers.containsString("404 Not Found"))
    );
}
 
Example #9
Source File: ConfigBuilderTests.java    From pravega with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the with() method.
 */
@Test
public void testWith() {
    final String namespace = "ns";
    final int propertyCount = 10;
    val builder = new ConfigBuilder<TestConfig>(namespace, TestConfig::new);
    for (int i = 0; i < propertyCount; i++) {
        val result = builder.with(Property.named(Integer.toString(i)), i);
        Assert.assertEquals("with() did not return this instance.", builder, result);
    }

    TestConfig c = builder.build();
    for (int i = 0; i < propertyCount; i++) {
        val p = Property.<Integer>named(Integer.toString(i));
        val actual = c.getProperties().getInt(p);
        Assert.assertEquals("Unexpected value in result.", i, actual);
    }
}
 
Example #10
Source File: GenruleBuildableTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void throwsIfGetNonExistentLabel() {
  expectedThrownException.expect(HumanReadableException.class);
  expectedThrownException.expectMessage(
      "Cannot find output label [nonexistent] for target //example:genrule");

  GenruleBuildable buildable =
      ImmutableGenruleBuildableBuilder.builder()
          .setBuildTarget(BuildTargetFactory.newInstance("//example:genrule"))
          .setFilesystem(new FakeProjectFilesystem())
          .setBash("echo something")
          .setOuts(
              Optional.of(
                  ImmutableMap.of(
                      OutputLabel.of("label1"),
                      ImmutableSet.of("output1a", "output1b"),
                      OutputLabel.of("label2"),
                      ImmutableSet.of("output2a"))))
          .build()
          .toBuildable();

  buildable.getOutputs(OutputLabel.of("nonexistent"));
}
 
Example #11
Source File: TestCombinations.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void testHetero() {
  List<Foo> A_36 = Foo.range("A", 3, 6);
  List<Foo> A_48 = Foo.range("A", 4, 8);
  List<Foo> B_17 = Foo.range("B", 1, 7);
  
  // so, different types shouldn't get mingled
  List<Foo> A_36_B_17 = Foo.range("A", 3, 6);
  A_36_B_17.addAll(Foo.range("B", 1, 7));
  assertEquals(A_36_B_17, toList(Combinations.or(A_36.iterator(), B_17.iterator())));
  assertEquals(0, toList(Combinations.and(A_36.iterator(), B_17.iterator())).size());
  
  // but check that the same type does
  List<Foo> A_38 = Foo.range("A", 3, 8);
  assertEquals(A_38, toList(Combinations.or(A_36.iterator(), A_48.iterator())));
  
  Iterator<Foo> A_or_B = Combinations.or(A_48.iterator(), B_17.iterator());
  assertEquals(3, toList(Combinations.and(A_36.iterator(), A_or_B)).size());
}
 
Example #12
Source File: CustomerRestControllerUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenExistingCustomer_whenPatched_thenReturnPatchedCustomer() throws Exception {
    Map<String, Boolean> communicationPreferences = new HashMap<>();
    communicationPreferences.put("post", true);
    communicationPreferences.put("email", true);
    Customer customer = new Customer("1", "001-555-1234", asList("Milk", "Eggs"), communicationPreferences);

    given(mockCustomerService.findCustomer("1")).willReturn(of(customer));

    String patchInstructions = "[{\"op\":\"replace\",\"path\": \"/telephone\",\"value\":\"001-555-5678\"}]";
    mvc.perform(patch("/customers/1")
                        .contentType(APPLICATION_JSON_PATCH_JSON)
                        .content(patchInstructions))
       .andExpect(status().isOk())
       .andExpect(jsonPath("$.id", is("1")))
       .andExpect(jsonPath("$.telephone", is("001-555-5678")))
       .andExpect(jsonPath("$.favorites", is(asList("Milk", "Eggs"))))
       .andExpect(jsonPath("$.communicationPreferences", is(communicationPreferences)));
}
 
Example #13
Source File: WildCardRoutingTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testWildcardRoutingHashAndStar() throws Exception {
   SimpleString addressAB = new SimpleString("a.b.c");
   SimpleString addressAC = new SimpleString("a.c");
   SimpleString address = new SimpleString("#.b.*");
   SimpleString queueName1 = new SimpleString("Q1");
   SimpleString queueName2 = new SimpleString("Q2");
   SimpleString queueName = new SimpleString("Q");
   clientSession.createQueue(new QueueConfiguration(queueName1).setAddress(addressAB).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName2).setAddress(addressAC).setDurable(false));
   clientSession.createQueue(new QueueConfiguration(queueName).setAddress(address).setDurable(false));
   ClientProducer producer = clientSession.createProducer(addressAB);
   ClientProducer producer2 = clientSession.createProducer(addressAC);
   ClientConsumer clientConsumer = clientSession.createConsumer(queueName);
   clientSession.start();
   producer.send(createTextMessage(clientSession, "m1"));
   producer2.send(createTextMessage(clientSession, "m2"));
   ClientMessage m = clientConsumer.receive(500);
   Assert.assertNotNull(m);
   Assert.assertEquals("m1", m.getBodyBuffer().readString());
   m.acknowledge();
   m = clientConsumer.receiveImmediate();
   Assert.assertNull(m);
}
 
Example #14
Source File: ProcessDefinitionRestServiceInteractionTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testActivateProcessDefinitionThrowsAuthorizationException() {
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("suspended", false);

  String message = "expected exception";
  doThrow(new AuthorizationException(message)).when(repositoryServiceMock).activateProcessDefinitionById(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, false, null);

  given()
    .pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)
    .contentType(ContentType.JSON)
    .body(params)
  .then()
    .expect()
      .statusCode(Status.FORBIDDEN.getStatusCode())
      .body("type", is(AuthorizationException.class.getSimpleName()))
      .body("message", is(message))
    .when()
      .put(SINGLE_PROCESS_DEFINITION_SUSPENDED_URL);
}
 
Example #15
Source File: PluralRulesTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Test
public void testSamples() {
    String description = "one: n is 3 or f is 5 @integer  3,19, @decimal 3.50 ~ 3.53,   …; other:  @decimal 99.0~99.2, 999.0, …";
    PluralRules test = PluralRules.createRules(description);

    checkNewSamples(description, test, "one", PluralRules.SampleType.INTEGER, "@integer 3, 19", true,
            new FixedDecimal(3));
    checkNewSamples(description, test, "one", PluralRules.SampleType.DECIMAL, "@decimal 3.50~3.53, …", false,
            new FixedDecimal(3.5, 2));
    checkOldSamples(description, test, "one", SampleType.INTEGER, 3d, 19d);
    checkOldSamples(description, test, "one", SampleType.DECIMAL, 3.5d, 3.51d, 3.52d, 3.53d);

    checkNewSamples(description, test, "other", PluralRules.SampleType.INTEGER, "", true, null);
    checkNewSamples(description, test, "other", PluralRules.SampleType.DECIMAL, "@decimal 99.0~99.2, 999.0, …",
            false, new FixedDecimal(99d, 1));
    checkOldSamples(description, test, "other", SampleType.INTEGER);
    checkOldSamples(description, test, "other", SampleType.DECIMAL, 99d, 99.1, 99.2d, 999d);
}
 
Example #16
Source File: CreateDataCmdTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateString() {

	Address addr = addr(STRING_AREA);
	CreateDataCmd cmd = new CreateDataCmd(addr, new StringDataType());
	cmd.applyTo(program);

	Data d = listing.getDataAt(addr);
	assertNotNull(d);
	assertTrue(d.isDefined());
	assertTrue(d.getDataType() instanceof StringDataType);
	assertEquals(5, d.getLength());// "notepad.chm",00

	d = listing.getDataAt(addr(STRING_AREA + 12));
	assertNotNull(d);
	assertTrue(!d.isDefined());
}
 
Example #17
Source File: FastSineTransformerTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test of transformer for the sine function.
 */
@Test
public void testSinFunction() {
    UnivariateFunction f = new Sin();
    FastSineTransformer transformer;
    transformer = new FastSineTransformer(DstNormalization.STANDARD_DST_I);
    double min, max, result[], tolerance = 1E-12; int N = 1 << 8;

    min = 0.0; max = 2.0 * FastMath.PI;
    result = transformer.transform(f, min, max, N, TransformType.FORWARD);
    Assert.assertEquals(N >> 1, result[2], tolerance);
    for (int i = 0; i < N; i += (i == 1 ? 2 : 1)) {
        Assert.assertEquals(0.0, result[i], tolerance);
    }

    min = -FastMath.PI; max = FastMath.PI;
    result = transformer.transform(f, min, max, N, TransformType.FORWARD);
    Assert.assertEquals(-(N >> 1), result[2], tolerance);
    for (int i = 0; i < N; i += (i == 1 ? 2 : 1)) {
        Assert.assertEquals(0.0, result[i], tolerance);
    }
}
 
Example #18
Source File: LottieValueAnimatorUnitTest.java    From lottie-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultAnimator() {
  testAnimator(new VerifyListener() {
    @Override public void verify(InOrder inOrder) {
      inOrder.verify(spyListener, times(1)).onAnimationStart(animator, false);
      inOrder.verify(spyListener, times(1)).onAnimationEnd(animator, false);
      Mockito.verify(spyListener, times(0)).onAnimationCancel(animator);
      Mockito.verify(spyListener, times(0)).onAnimationRepeat(animator);
    }
  });
}
 
Example #19
Source File: ServiceDefinitionTests.java    From conjure with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseEnum_withObjectDocs() throws IOException {
    assertThat(mapper.readValue(
                    multiLineString("docs: Test", "values:", " - A", " - B"), BaseObjectTypeDefinition.class))
            .isEqualTo(EnumTypeDefinition.builder()
                    .addValues(EnumValueDefinition.builder().value("A").build())
                    .addValues(EnumValueDefinition.builder().value("B").build())
                    .docs("Test")
                    .build());
}
 
Example #20
Source File: BigNumberFormatTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void TestExponent() {
    DecimalFormatSymbols US = new DecimalFormatSymbols(Locale.US);
    DecimalFormat fmt1 = new DecimalFormat("0.###E0", US);
    DecimalFormat fmt2 = new DecimalFormat("0.###E+0", US);
    Number n = new Long(1234);
    expect(fmt1, n, "1.234E3");
    expect(fmt2, n, "1.234E+3");
    expect(fmt1, "1.234E3", n);
    expect(fmt1, "1.234E+3", n); // Either format should parse "E+3"
    expect(fmt2, "1.234E+3", n);
}
 
Example #21
Source File: UpdateMarketplaceBeanTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void selectedMarketplaceChanged_NotFound() throws Exception {
    // given
    String mpId = "fake id";
    umpb.getModel().setMarketplaceId(mpId);
    ObjectNotFoundException e = new ObjectNotFoundException(
            ClassEnum.MARKETPLACE, mpId);
    when(msmock.getMarketplaceById(anyString())).thenThrow(e);
    ArgumentCaptor<ObjectNotFoundException> onfe = ArgumentCaptor
            .forClass(ObjectNotFoundException.class);

    // when
    umpb.marketplaceChanged();

    // then
    Marketplace model = umpb.getModel();
    assertNotNull(model);
    assertTrue(model.isEditDisabled());

    verify(ui, times(1)).handleException(onfe.capture());
    assertEquals(ClassEnum.MARKETPLACE, onfe.getValue()
            .getDomainObjectClassEnum());
    assertEquals(mpId, onfe.getValue().getMessageParams()[0]);

    List<SelectItem> list = umpb.getSelectableMarketplaces();
    assertNotNull(list);

    verify(msmock, times(1)).getMarketplacesOwned();
}
 
Example #22
Source File: CompoundWriteTest.java    From firebase-admin-java with Apache License 2.0 5 votes vote down vote up
@Test
public void childMergeLooksIntoUpdateNode() {
  CompoundWrite compoundWrite = CompoundWrite.emptyWrite();
  Node update =
      NodeUtilities.NodeFromJSON(
          new MapBuilder().put("foo", "foo-value").put("bar", "bar-value").build());
  compoundWrite = compoundWrite.addWrite(Path.getEmptyPath(), update);
  Assert.assertEquals(
      NodeUtilities.NodeFromJSON("foo-value"),
      compoundWrite.childCompoundWrite(new Path("foo")).apply(EmptyNode.Empty()));
}
 
Example #23
Source File: BufUnwrapperTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void readableNioBuffers_worksWithNormal() {
  ByteBuf buf = alloc.buffer(1).writeByte('a');
  try (BufUnwrapper unwrapper = new BufUnwrapper()) {
    ByteBuffer[] internalBufs = unwrapper.readableNioBuffers(buf);
    Truth.assertThat(internalBufs).hasLength(1);

    assertEquals('a', internalBufs[0].get(0));
  } finally {
    buf.release();
  }
}
 
Example #24
Source File: SplitHandlerTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testRandomSplitRecommendations() throws Exception {
  Random rand = random();
  for (int i=0; i<10000; i++) { // 1M takes ~ 1 sec
    doRandomSplitRecommendation(rand);
  }
}
 
Example #25
Source File: QueryParserTest.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Test
public void testRowValueConstructorQuery() throws Exception {
    String sql = (
            (
                    "select a_integer FROM aTable where (x_integer, y_integer) > (3, 4)"));
    parseQuery(sql);
}
 
Example #26
Source File: HFCAClientIT.java    From fabric-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeleteAffiliationNoForce() throws Exception {

    if (testConfig.isRunningAgainstFabric10()) {
        return; // needs v1.1
    }

    HFCAAffiliation aff = client.newHFCAAffiliation("org6");
    aff.create(admin);
    HFCAAffiliationResp resp = aff.delete(admin);

    assertEquals("Incorrect status code", new Integer(200), new Integer(resp.getStatusCode()));
    assertEquals("Failed to delete affiliation", "org6", aff.getName());
}
 
Example #27
Source File: PropertyDataSourceTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void checkSinglePartitionedOrderedSource5() {

	ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment();
	env.setParallelism(DEFAULT_PARALLELISM);

	DataSource<Tuple3<Long, SomePojo, String>> data = env.fromCollection(tuple3PojoData, tuple3PojoType);

	data.getSplitDataProperties()
		.splitsPartitionedBy("f1.intField")
		.splitsOrderedBy("f0; f1.intField", new Order[]{Order.ASCENDING, Order.DESCENDING});

	data.output(new DiscardingOutputFormat<Tuple3<Long, SomePojo, String>>());

	Plan plan = env.createProgramPlan();

	// submit the plan to the compiler
	OptimizedPlan oPlan = compileNoStats(plan);

	// check the optimized Plan
	SinkPlanNode sinkNode = oPlan.getDataSinks().iterator().next();
	SourcePlanNode sourceNode = (SourcePlanNode) sinkNode.getPredecessor();

	GlobalProperties gprops = sourceNode.getGlobalProperties();
	LocalProperties lprops = sourceNode.getLocalProperties();

	Assert.assertTrue((new FieldSet(gprops.getPartitioningFields().toArray())).equals(new FieldSet(2)));
	Assert.assertTrue(gprops.getPartitioning() == PartitioningProperty.ANY_PARTITIONING);
	Assert.assertTrue(new FieldSet(lprops.getGroupedFields().toArray()).equals(new FieldSet(0,2)));
	Assert.assertTrue(lprops.getOrdering() == null);

}
 
Example #28
Source File: MailTest.java    From sso with MIT License 5 votes vote down vote up
@Test
    public void connect() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(mail);
        message.setTo(mail); //自己给自己发送邮件
        message.setSubject("主题:测试邮件");
        message.setText("测试邮件内容");

        //可以进行测试
//        mailSender.send(message);
    }
 
Example #29
Source File: ChronicleSetBuilderTest.java    From Chronicle-Map with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {

    try (ChronicleSet<Integer> integers = ChronicleSet.of(Integer.class).entries(10).create()) {
        for (int i = 0; i < 10; i++) {
            integers.add(i);
        }

        Assert.assertTrue(integers.contains(5));
        Assert.assertEquals(10, integers.size());
    }
}
 
Example #30
Source File: ClientLineEndingTest.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Test
public void testClientLineEndUnixSpecForLF() throws IOException {

    IClientSummary.ClientLineEnd lineEnd = IClientSummary.ClientLineEnd.UNIX;
    List<IFileSpec> syncFiles = null;
    String currFileVer = null;
    boolean fileCreated = false;

    try {
        currFileVer = getTestFileVer();
        String[] fNameList = {
                new File(clientFilePath, "LineEndingFile_LF"
                        + currFileVer).toString()
        };

        fileCreated = createFileWithSpecifiedLineEnding(fNameList[0], CLETEST_FTYPE_LF);

        syncFiles = taskAddSubmitSyncTestFiles(fNameList, lineEnd);
        assertFalse("Syncfiles unexpectedly returned Empty.", syncFiles.isEmpty());

        String syncFileEnd = fileLineEndingType(syncFiles.get(0).getClientPathString());
        assertEquals("Files end should be the same.", "CLETEST_STR_LF", syncFileEnd);

    } catch (Exception exc) {
        fail("Unexpected Exception: " + exc + " - " + exc.getLocalizedMessage());
    }

}