当前位置: 首页>>代码示例>>Java>>正文


Java Fail.failBecauseExceptionWasNotThrown方法代码示例

本文整理汇总了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");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:17,代码来源:FeignTest.java

示例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");
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:24,代码来源:DmnDecisionResultTest.java

示例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");
  }
}
 
开发者ID:camunda,项目名称:camunda-engine-dmn,代码行数:24,代码来源:DmnDecisionTableResultTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:21,代码来源:AwsSdkTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:22,代码来源:AwsSdkTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:27,代码来源:AwsSdkTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:18,代码来源:AwsSdkTest.java

示例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);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:21,代码来源:AwsSdkTest.java

示例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.");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:10,代码来源:DefaultContractTest.java

示例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");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:10,代码来源:DefaultContractTest.java

示例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.");
  }
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:10,代码来源:DefaultContractTest.java

示例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);
	}
}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:12,代码来源:ExceptionHandlingTest.java

示例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);
	}
}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:12,代码来源:ExceptionHandlingTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:12,代码来源:AwsSdkTest.java

示例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");
    }
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:13,代码来源:AwsSdkTest.java


注:本文中的org.assertj.core.api.Fail.failBecauseExceptionWasNotThrown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。