Refine search
@Test @SuppressWarnings("resource") public void testPackagePrivateExtensionCantBeExposed() { this.thrown.expect(InvalidMetadataException.class); this.thrown.expectMessage(PackagePrivateTestBean.class.getName()); this.thrown.expectMessage("must be public"); new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class); }
@Test public void loadIndexWithException() throws IOException { final IOException cause = new IOException("test exception"); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Unable to load indexes"); this.thrown.expectCause(is(cause)); CandidateComponentsIndexLoader.loadIndex(new CandidateComponentsTestClassLoader( getClass().getClassLoader(), cause)); }
@Test public void stateWithFalseExpressionAndMessageSupplier() { thrown.expect(IllegalStateException.class); thrown.expectMessage("enigma"); Assert.state(false, () -> "enigma"); }
@Test public void hasLengthWithNull() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.hasLength(null, "enigma"); }
@Test public void hasLengthWithNullAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.hasLength(null, () -> "enigma"); }
@Test public void notEmptyArrayWithNullArrayAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.notEmpty((Object[]) null, () -> "enigma"); }
@Test public void notEmptyMapWithNullMap() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.notEmpty((Map<?, ?>) null, "enigma"); }
@Test public void isInstanceOfWithNullType() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Type to check against must not be null"); Assert.isInstanceOf(null, "foo", "enigma"); }
@Test public void isInstanceOfWithTypeMismatchAndCustomMessage() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Custom message: java.lang.Long"); Assert.isInstanceOf(String.class, 42L, "Custom message"); }
@Test public void isInstanceOfWithTypeMismatchAndCustomMessageWithSpace() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Custom message for java.lang.Long"); Assert.isInstanceOf(String.class, 42L, "Custom message for "); }
@Test public void isInstanceOfWithNullInstanceAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma: null"); Assert.isInstanceOf(String.class, null, () -> "enigma"); }
@Test public void isInstanceOfWithTypeMismatchAndNullMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Object of class [java.lang.Long] must be an instance of class java.lang.String"); Assert.isInstanceOf(String.class, 42L, (Supplier<String>) null); }
@Test public void isInstanceOfWithTypeMismatchAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma: java.lang.Long"); Assert.isInstanceOf(String.class, 42L, () -> "enigma"); }
@Test public void isTrueWithFalse() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.isTrue(false, "enigma"); }
@Test public void hasTextWithNullAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.hasText(null, () -> "enigma"); }
@Test public void notEmptyArrayWithEmptyArrayAndMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("enigma"); Assert.notEmpty(new String[] {}, () -> "enigma"); }
@Test public void hasTextWithNullAndNullMessageSupplier() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(equalTo(null)); Assert.hasText(null, (Supplier<String>) null); }
@Test public void synthesizeAnnotationWithAttributeAliasForAttributeOfDifferentType() throws Exception { AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass.class.getAnnotation(AliasForAttributeOfDifferentType.class); exception.expect(AnnotationConfigurationException.class); exception.expectMessage(startsWith("Misconfigured aliases")); exception.expectMessage(containsString(AliasForAttributeOfDifferentType.class.getName())); exception.expectMessage(containsString("attribute 'foo'")); exception.expectMessage(containsString("attribute 'bar'")); exception.expectMessage(containsString("same return type")); synthesizeAnnotation(annotation); }
@Test public void synthesizeAnnotationWithAttributeAliasForWithMissingDefaultValues() throws Exception { AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass.class.getAnnotation(AliasForWithMissingDefaultValues.class); exception.expect(AnnotationConfigurationException.class); exception.expectMessage(startsWith("Misconfigured aliases")); exception.expectMessage(containsString(AliasForWithMissingDefaultValues.class.getName())); exception.expectMessage(containsString("attribute 'foo' in annotation")); exception.expectMessage(containsString("attribute 'bar' in annotation")); exception.expectMessage(containsString("default values")); synthesizeAnnotation(annotation); }
@Test public void stateWithFalseExpressionAndNullMessageSupplier() { thrown.expect(IllegalStateException.class); thrown.expectMessage(equalTo(null)); Assert.state(false, (Supplier<String>) null); }