@Test
public void shouldThrowExceptionIfCreatingObjectNameThrowsMalformedObjectNameException() throws Exception {

    try {
        objectNameFactory.create("fred:fred", "type", "value");
        fail();
    } catch (final ObjectNameException expected) {
        assertThat(expected.getMessage(), is("Unable to create ObjectName: domain='fred:fred', key='type', value='value'"));
        assertThat(expected.getCause(), is(CoreMatchers.instanceOf(MalformedObjectNameException.class)));
    }
}