本文整理汇总了Java中org.assertj.core.api.Fail.failBecauseExceptionWasNotThrown方法的典型用法代码示例。如果您正苦于以下问题:Java Fail.failBecauseExceptionWasNotThrown方法的具体用法?Java Fail.failBecauseExceptionWasNotThrown怎么用?Java Fail.failBecauseExceptionWasNotThrown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.assertj.core.api.Fail
的用法示例。
在下文中一共展示了Fail.failBecauseExceptionWasNotThrown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryMapKeysMustBeStrings
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void queryMapKeysMustBeStrings() throws Exception {
server.enqueue(new MockResponse());
TestInterface api = new TestInterfaceBuilder().target("http://localhost:" + server.getPort());
Map<Object, String> queryMap = new LinkedHashMap<Object, String>();
queryMap.put(Integer.valueOf(42), "alice");
try {
api.queryMap((Map) queryMap);
Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException ex) {
assertThat(ex).hasMessage("QueryMap key must be a String: 42");
}
}
示例2: assertMultipleOutputValues
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
protected void assertMultipleOutputValues(DmnDecisionResultEntries result) {
assertThat(result.size()).isEqualTo(2);
String value = (String) result.get("firstOutput");
assertThat(value).isEqualTo("multipleValues1");
value = (String) result.get("secondOutput");
assertThat(value).isEqualTo("multipleValues2");
value = result.getFirstEntry();
assertThat(value).isEqualTo("multipleValues1");
try {
result.getSingleEntry();
Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
}
catch (DmnDecisionResultException e) {
assertThat(e)
.hasMessageStartingWith("DMN-01010")
.hasMessageContaining("multipleValues1")
.hasMessageContaining("multipleValues2");
}
}
示例3: assertMultipleOutputValues
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
protected void assertMultipleOutputValues(DmnDecisionRuleResult decisionRuleResult) {
assertThat(decisionRuleResult.size()).isEqualTo(2);
String value = (String) decisionRuleResult.get("firstOutput");
assertThat(value).isEqualTo("multipleValues1");
value = (String) decisionRuleResult.get("secondOutput");
assertThat(value).isEqualTo("multipleValues2");
value = decisionRuleResult.getFirstEntry();
assertThat(value).isEqualTo("multipleValues1");
try {
decisionRuleResult.getSingleEntry();
Fail.failBecauseExceptionWasNotThrown(DmnDecisionResultException.class);
}
catch (DmnDecisionResultException e) {
assertThat(e)
.hasMessageStartingWith("DMN-01007")
.hasMessageContaining("multipleValues1")
.hasMessageContaining("multipleValues2");
}
}
示例4: testAwsV4SignatureBadIdentity
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testAwsV4SignatureBadIdentity() throws Exception {
client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(
"bad-access-key", awsCreds.getAWSSecretKey())))
.withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
try {
client.putObject(containerName, "foo",
BYTE_SOURCE.openStream(), metadata);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("InvalidAccessKeyId");
}
}
示例5: testAwsV4SignatureBadCredential
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testAwsV4SignatureBadCredential() throws Exception {
client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(
awsCreds.getAWSAccessKeyId(),
"bad-secret-key")))
.withEndpointConfiguration(s3EndpointConfig)
.build();
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
try {
client.putObject(containerName, "foo",
BYTE_SOURCE.openStream(), metadata);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("SignatureDoesNotMatch");
}
}
示例6: testUpdateBlobXmlAcls
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testUpdateBlobXmlAcls() throws Exception {
assumeTrue(!Quirks.NO_BLOB_ACCESS_CONTROL.contains(blobStoreType));
String blobName = "testUpdateBlobXmlAcls-blob";
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
metadata);
AccessControlList acl = client.getObjectAcl(containerName, blobName);
acl.grantPermission(GroupGrantee.AllUsers, Permission.Read);
client.setObjectAcl(containerName, blobName, acl);
assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);
acl.revokeAllPermissions(GroupGrantee.AllUsers);
client.setObjectAcl(containerName, blobName, acl);
assertThat(client.getObjectAcl(containerName, blobName)).isEqualTo(acl);
acl.grantPermission(GroupGrantee.AllUsers, Permission.Write);
try {
client.setObjectAcl(containerName, blobName, acl);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
}
}
示例7: testPartNumberMarker
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testPartNumberMarker() throws Exception {
String blobName = "foo";
InitiateMultipartUploadResult result = client.initiateMultipartUpload(
new InitiateMultipartUploadRequest(containerName, blobName));
ListPartsRequest request = new ListPartsRequest(containerName,
blobName, result.getUploadId());
client.listParts(request.withPartNumberMarker(0));
try {
client.listParts(request.withPartNumberMarker(1));
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("NotImplemented");
}
}
示例8: testBlobRemove
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testBlobRemove() throws Exception {
String blobName = "blob";
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
metadata);
assertThat(client.getObjectMetadata(containerName, blobName))
.isNotNull();
client.deleteObject(containerName, blobName);
try {
client.getObjectMetadata(containerName, blobName);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("404 Not Found");
}
client.deleteObject(containerName, blobName);
}
示例9: onlyOneQueryMapAnnotationPermitted
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void onlyOneQueryMapAnnotationPermitted() throws Exception {
try {
parseAndValidateMetadata(QueryMapTestInterface.class, "multipleQueryMap", Map.class, Map.class);
Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException ex) {
assertThat(ex).hasMessage("QueryMap annotation was present on multiple parameters.");
}
}
示例10: queryMapMustBeInstanceOfMap
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void queryMapMustBeInstanceOfMap() throws Exception {
try {
parseAndValidateMetadata(QueryMapTestInterface.class, "nonMapQueryMap", String.class);
Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException ex) {
assertThat(ex).hasMessage("QueryMap parameter must be a Map: class java.lang.String");
}
}
示例11: onlyOneHeaderMapAnnotationPermitted
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void onlyOneHeaderMapAnnotationPermitted() throws Exception {
try {
parseAndValidateMetadata(HeaderMapInterface.class, "multipleHeaderMap", Map.class, Map.class);
Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException ex) {
assertThat(ex).hasMessage("HeaderMap annotation was present on multiple parameters.");
}
}
示例12: shouldNotWrapRuntimeException
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void shouldNotWrapRuntimeException() throws Exception {
final RuntimeException someException = new RuntimeException();
ExceptionThrower<Exception> et = new ExceptionThrower<Exception>(someException);
try {
callUglyCode(et);
Fail.failBecauseExceptionWasNotThrown(RuntimeException.class);
} catch (RuntimeException e) {
assertThat(e).isSameAs(someException);
}
}
示例13: shouldNotWrapRuntimeException_guava
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void shouldNotWrapRuntimeException_guava() throws Exception {
final RuntimeException someException = new RuntimeException();
ExceptionThrower<Exception> et = new ExceptionThrower<Exception>(someException);
try {
callUglyCode_guava(et);
Fail.failBecauseExceptionWasNotThrown(RuntimeException.class);
} catch (RuntimeException e) {
assertThat(e).isSameAs(someException);
}
}
示例14: testContainerExists
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testContainerExists() throws Exception {
client.headBucket(new HeadBucketRequest(containerName));
try {
client.headBucket(new HeadBucketRequest(
createRandomContainerName()));
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("404 Not Found");
}
}
示例15: testContainerCreateDelete
import org.assertj.core.api.Fail; //导入方法依赖的package包/类
@Test
public void testContainerCreateDelete() throws Exception {
String containerName2 = createRandomContainerName();
client.createBucket(containerName2);
try {
client.createBucket(containerName2);
client.deleteBucket(containerName2);
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
} catch (AmazonS3Exception e) {
assertThat(e.getErrorCode()).isEqualTo("BucketAlreadyOwnedByYou");
}
}