Java Code Examples for org.assertj.core.api.Fail#failBecauseExceptionWasNotThrown()
The following examples show how to use
org.assertj.core.api.Fail#failBecauseExceptionWasNotThrown() .
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: DmnDecisionTableResultTest.java From camunda-engine-dmn with Apache License 2.0 | 6 votes |
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"); } }
Example 2
Source File: DmnDecisionTableResultTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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"); } }
Example 3
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 6 votes |
@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"); } }
Example 5
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 6 votes |
@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"); } }
Example 6
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 6 votes |
@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"); } }
Example 7
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 6 votes |
@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"); } }
Example 8
Source File: DmnDecisionResultTest.java From camunda-engine-dmn with Apache License 2.0 | 6 votes |
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"); } }
Example 9
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Test public void testDeleteMultipleObjectsEmpty() throws Exception { DeleteObjectsRequest request = new DeleteObjectsRequest(containerName) .withKeys(); try { client.deleteObjects(request); Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class); } catch (AmazonS3Exception e) { assertThat(e.getErrorCode()).isEqualTo("MalformedXML"); } }
Example 10
Source File: DefaultContractTest.java From feign with Apache License 2.0 | 5 votes |
@Test public void bodyParamsAndformParam() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage("Body parameters cannot be used with form parameters."); parseAndValidateMetadata(FormParams.class, "bodyParamsAndformParam", String.class, String.class); Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class); }
Example 11
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 5 votes |
@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"); } }
Example 12
Source File: DefaultContractTest.java From feign with Apache License 2.0 | 5 votes |
@Test public void onlyOneHeaderMapAnnotationPermitted() throws Exception { try { parseAndValidateMetadata(HeaderMapInterface.class, "multipleHeaderMap", Map.class, Map.class); Fail.failBecauseExceptionWasNotThrown(IllegalStateException.class); } catch (final IllegalStateException ex) { assertThat(ex).hasMessage("HeaderMap annotation was present on multiple parameters."); } }
Example 13
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Test public void testGetBucketPolicy() throws Exception { try { client.getBucketPolicy(containerName); Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class); } catch (AmazonS3Exception e) { assertThat(e.getErrorCode()).isEqualTo("NoSuchPolicy"); } }
Example 14
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Test public void testUnknownParameter() throws Exception { try { client.setBucketLoggingConfiguration( new SetBucketLoggingConfigurationRequest( containerName, new BucketLoggingConfiguration())); Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class); } catch (AmazonS3Exception e) { assertThat(e.getErrorCode()).isEqualTo("NotImplemented"); } }
Example 15
Source File: JcloudsBucketsLiveTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Override @Test public void testBucketLogging() throws Exception { try { super.testBucketLogging(); Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class); } catch (AWSResponseException are) { assertThat(are.getError().getCode()).isEqualTo("NotImplemented"); throw new SkipException("bucket logging not supported", are); } }
Example 16
Source File: JcloudsBucketsLiveTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Override @Test public void testBucketPayer() throws Exception { try { super.testBucketPayer(); Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class); } catch (AWSResponseException are) { assertThat(are.getError().getCode()).isEqualTo("NotImplemented"); throw new SkipException("bucket payer not supported", are); } }
Example 17
Source File: ReadOnlyBlobStoreTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Test public void testPutBlob() throws Exception { try { readOnlyBlobStore.putBlob(containerName, null); Fail.failBecauseExceptionWasNotThrown( UnsupportedOperationException.class); } catch (UnsupportedOperationException ne) { // expected } }
Example 18
Source File: ReadOnlyBlobStoreTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Test public void testPutBlobOptions() throws Exception { try { readOnlyBlobStore.putBlob(containerName, null, new PutOptions()); Fail.failBecauseExceptionWasNotThrown( UnsupportedOperationException.class); } catch (UnsupportedOperationException ne) { // expected } }
Example 19
Source File: JcloudsBucketsLiveTest.java From s3proxy with Apache License 2.0 | 5 votes |
@Override @Test public void testUpdateBucketACL() throws Exception { try { super.testUpdateBucketACL(); Fail.failBecauseExceptionWasNotThrown(AWSResponseException.class); } catch (AWSResponseException are) { assertThat(are.getError().getCode()).isEqualTo("NotImplemented"); throw new SkipException("XML ACLs not supported", are); } }
Example 20
Source File: AwsSdkTest.java From s3proxy with Apache License 2.0 | 4 votes |
@Test public void testBlobStoreLocator() throws Exception { final BlobStore blobStore1 = context.getBlobStore(); final BlobStore blobStore2 = ContextBuilder .newBuilder(blobStoreType) .credentials("other-identity", "credential") .build(BlobStoreContext.class) .getBlobStore(); s3Proxy.setBlobStoreLocator(new BlobStoreLocator() { @Nullable @Override public Map.Entry<String, BlobStore> locateBlobStore( String identity, String container, String blob) { if (identity.equals(awsCreds.getAWSAccessKeyId())) { return Maps.immutableEntry(awsCreds.getAWSSecretKey(), blobStore1); } else if (identity.equals("other-identity")) { return Maps.immutableEntry("credential", blobStore2); } else { return null; } } }); // check first access key List<Bucket> buckets = client.listBuckets(); assertThat(buckets).hasSize(1); assertThat(buckets.get(0).getName()).isEqualTo(containerName); // check second access key client = AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider( new BasicAWSCredentials("other-identity", "credential"))) .withEndpointConfiguration(s3EndpointConfig) .build(); buckets = client.listBuckets(); assertThat(buckets).isEmpty(); // check invalid access key client = AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider( new BasicAWSCredentials("bad-identity", "credential"))) .withEndpointConfiguration(s3EndpointConfig) .build(); try { client.listBuckets(); Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class); } catch (AmazonS3Exception e) { assertThat(e.getErrorCode()).isEqualTo("InvalidAccessKeyId"); } }