本文整理匯總了Java中org.junit.Assert.assertThat方法的典型用法代碼示例。如果您正苦於以下問題:Java Assert.assertThat方法的具體用法?Java Assert.assertThat怎麽用?Java Assert.assertThat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.Assert
的用法示例。
在下文中一共展示了Assert.assertThat方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void create(@Mocked ConsumerSchemaFactory consumerSchemaFactory,
@Mocked SchemaListenerManager schemaListenerManager) {
String microserviceName = "app:ms";
String microserviceId = "id";
Microservice microservice = new Microservice();
microservice.setVersion("1.0.0");
new Expectations(RegistryUtils.class) {
{
RegistryUtils.getMicroservice(microserviceId);
result = microservice;
}
};
CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
CseContext.getInstance().setSchemaListenerManager(schemaListenerManager);
MicroserviceVersionMetaFactory factory = new MicroserviceVersionMetaFactory();
MicroserviceVersion microserviceVersion = factory.create(microserviceName, microserviceId);
Assert.assertThat(microserviceVersion, Matchers.instanceOf(MicroserviceVersionMeta.class));
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:22,代碼來源:TestMicroserviceVersionMetaFactory.java
示例2: testSetPredicate
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testSetPredicate() throws Exception {
PredicateBasedRuleSupport support = new PredicateBasedRuleSupport();
Assert.assertThat(support.getPredicate(), is(nullValue()));
support.setPredicate(predicate);
Assert.assertThat(support.getPredicate(), is(predicate));
}
示例3: testGetParameterValuesNormal
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGetParameterValuesNormal() {
Map<String, List<String>> queryParams = new HashMap<>();
queryParams.put("name", Arrays.asList("value"));
HttpServletRequest request = new CommonToHttpServletRequest(null, queryParams, null, null, false);
Assert.assertThat(request.getParameterValues("name"), Matchers.arrayContaining("value"));
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:9,代碼來源:TestCommonToHttpServletRequest.java
示例4: testGenerate_Number_WithRightAddon
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGenerate_Number_WithRightAddon() throws JsonProcessingException {
UiForm ui = UiFormSchemaGenerator.get().generate(NumberFormRight.class);
String json = new ObjectMapper().writeValueAsString(ui);
//Assert.assertThat(json, hasJsonPath("$.schema.properties.number.title",equalTo("Number")));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')]",hasSize(1)));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].description",hasItem("This is a number")));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].placeholder",hasItem("Number of children")));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].validationMessage",hasItem("this is a validation msg")));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].type",hasItem("number")));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].notitle",hasItem(true)));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].readonly",hasItem(true)));
Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].fieldAddonRight",hasItem("@")));
}
示例5: testAttributesBasic
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testAttributesBasic() {
Task task = createTask(2, "sample task");
Document document = mapper.toDocument(toResponse(task), createAdapter(Task.class));
Resource resource = document.getSingleData().get();
Assert.assertEquals("2", resource.getId());
Assert.assertEquals("tasks", resource.getType());
Assert.assertEquals("sample task", resource.getAttributes().get("name").asText());
Assert.assertThat(resource.getAttributes().get("writeOnlyValue"), CoreMatchers.nullValue());
}
示例6: fail_on_get_property
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void fail_on_get_property() throws Exception {
when(message.getPropertyNames()).thenReturn(Collections.enumeration(asList("1", "2", "3")));
when(message.getStringProperty("1")).thenReturn("1");
when(message.getStringProperty("2")).thenThrow(JMSException.class);
propagator.copyFromMessage(message);
verify(message).getStringProperty(eq("1"));
verify(message).getStringProperty(eq("2"));
verify(message, never()).getStringProperty(eq("3"));
Assert.assertThat(current().containsKey("1"), is(true));
Assert.assertThat(current().entrySet().size(), is(1));
}
開發者ID:enadim,項目名稱:spring-cloud-ribbon-extensions,代碼行數:13,代碼來源:AbstractPreservesMessagePropertiesTest.java
示例7: testPutSelfBasePathIfAbsent_WithUrlPrefix
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testPutSelfBasePathIfAbsent_WithUrlPrefix() {
System.setProperty(Const.URL_PREFIX, "/root/rest");
microservice.setPaths(new ArrayList<>());
loader.putSelfBasePathIfAbsent("perfClient", "/test");
Assert.assertThat(microservice.getPaths().size(), Matchers.is(1));
Assert.assertThat(microservice.getPaths().get(0).getPath(), Matchers.is("/root/rest/test"));
System.clearProperty(Const.URL_PREFIX);
}
示例8: reenqueue_should_return_false_when_no_update
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void reenqueue_should_return_false_when_no_update() throws Exception {
QueueLocation location = generateUniqueLocation();
Boolean reenqueueResult = executeInTransaction(() ->
queueActorDao.reenqueue(location, "...", Duration.ofHours(1L)));
Assert.assertThat(reenqueueResult, equalTo(false));
}
示例9: testAttribute
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testAttribute() {
String key = "a1";
String value = "abc";
request.setAttribute(key, value);
Assert.assertSame(value, request.getAttribute(key));
Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key));
request.setAttribute("a2", "v");
Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key, "a2"));
request.removeAttribute(key);
Assert.assertNull(request.getAttribute(key));
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:15,代碼來源:TestAbstractHttpServletRequest.java
示例10: shouldGetCustomMapClaim
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void shouldGetCustomMapClaim() throws Exception {
String token = "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjp7InN0cmluZyI6InZhbHVlIiwibnVtYmVyIjoxLCJib29sZWFuIjp0cnVlfX0.-8aIaXd2-rp1lLuDEQmCeisCBX9X_zbqdPn2llGxNoc";
JWT jwt = JWT.require(Algorithm.HMAC256("secret")).build();
DecodedJWT decodedJWT = jwt.decode(token);
Assert.assertThat(decodedJWT, is(notNullValue()));
Map<String, Object> map = decodedJWT.getClaim("name").asMap();
Assert.assertThat(map, hasEntry("string", (Object) "value"));
Assert.assertThat(map, hasEntry("number", (Object) 1));
Assert.assertThat(map, hasEntry("boolean", (Object) true));
}
示例11: testGetHeaderNames
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testGetHeaderNames() {
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
headers.add("name", "value");
new Expectations() {
{
vertxRequest.headers();
result = headers;
}
};
Assert.assertThat(Collections.list(request.getHeaderNames()), Matchers.contains("name"));
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:15,代碼來源:TestVertxServerRequestToHttpServletRequest.java
示例12: testIgnored
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testIgnored() {
// given
Wrapper wrapper = new Wrapper();
// when
Integer minMax = postprocess(wrapper, "ignored", Integer.class);
// then
Assert.assertThat(minMax, CoreMatchers.is(0));
}
示例13: testNoAnnotation
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testNoAnnotation() {
// given
Wrapper wrapper = new Wrapper();
// when
Float retVal = postprocess(wrapper, "aFloat", Float.class);
// then
Assert.assertThat(retVal, is(0f));
}
示例14: testClone
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testClone()
{
TopicSubscription topic = new TopicSubscription(TOPIC_FILTER, MqttQualityOfService.QOS_0);
TopicSubscription clone = topic.clone();
Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
topic.setSubscribed(true);
Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.not(clone.isSubscribed())));
clone = topic.clone();
Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
}
示例15: testMinMaxOnStringAnnotation
import org.junit.Assert; //導入方法依賴的package包/類
@Test
public void testMinMaxOnStringAnnotation() {
// given
Wrapper wrapper = new Wrapper();
wrapper.string = "abcdefghijklmon.......";
// when
String minMax = postprocess(wrapper, "string", String.class);
// then
Assert.assertThat(minMax.length(), OrderingComparison.greaterThan(2));
Assert.assertThat(minMax.length(), OrderingComparison.lessThanOrEqualTo(5));
}