use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractConfiguredObjectTest method testIdAndTypeAreImmutableAttribute.
/**
* Id and Type are key attributes in the model and are thus worthy of test of their own
*/
public void testIdAndTypeAreImmutableAttribute() {
Map<String, Object> attributes = new HashMap<>();
attributes.put(ConfiguredObject.NAME, "myName");
final TestSingleton object = _model.getObjectFactory().create(TestSingleton.class, attributes, null);
UUID originalUuid = object.getId();
String originalType = object.getType();
try {
object.setAttributes(Collections.singletonMap(TestSingleton.ID, UUID.randomUUID()));
fail("Exception not thrown");
} catch (IllegalConfigurationException e) {
// PASS
}
assertEquals(originalUuid, object.getId());
try {
object.setAttributes(Collections.singletonMap(TestSingleton.TYPE, "newtype"));
fail("Exception not thrown");
} catch (IllegalConfigurationException e) {
// PASS
}
assertEquals(originalType, object.getType());
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testValidateOnCreateFails_ExistingDefaultVHN.
public void testValidateOnCreateFails_ExistingDefaultVHN() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = new HashMap<>();
attributes.put(TestVirtualHostNode.NAME, nodeName);
attributes.put(TestVirtualHostNode.DEFAULT_VIRTUAL_HOST_NODE, Boolean.TRUE);
VirtualHostNode existingDefault = mock(VirtualHostNode.class);
when(existingDefault.getName()).thenReturn("existingDefault");
when(_broker.findDefautVirtualHostNode()).thenReturn(existingDefault);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
try {
node.create();
fail("Exception not thrown");
} catch (IllegalConfigurationException e) {
assertTrue("Unexpected exception " + e.getMessage(), e.getMessage().startsWith("The existing virtual host node 'existingDefault' is already the default for the Broker"));
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class AbstractStandardVirtualHostNodeTest method testValidateOnCreateFails_StoreFails.
public void testValidateOnCreateFails_StoreFails() throws Exception {
String nodeName = getTestName();
Map<String, Object> attributes = Collections.<String, Object>singletonMap(TestVirtualHostNode.NAME, nodeName);
final DurableConfigurationStore store = mock(DurableConfigurationStore.class);
doThrow(new RuntimeException("Cannot open store")).when(store).init(any(ConfiguredObject.class));
AbstractStandardVirtualHostNode node = createTestStandardVirtualHostNode(attributes, store);
try {
node.create();
fail("Exception not thrown");
} catch (IllegalConfigurationException e) {
assertTrue("Unexpected exception " + e.getMessage(), e.getMessage().startsWith("Cannot open node configuration store"));
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method onCreate.
@Override
protected void onCreate() {
super.onCreate();
File passwordFile = new File(_path);
if (!passwordFile.exists()) {
try {
Path path = new FileHelper().createNewFile(passwordFile, getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS));
if (!Files.exists(path)) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path));
}
} catch (IOException e) {
throw new IllegalConfigurationException(String.format("Cannot create password file at '%s'", _path), e);
}
}
}
use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.
the class PrincipalDatabaseAuthenticationManager method validateOnCreate.
@Override
protected void validateOnCreate() {
super.validateOnCreate();
File passwordFile = new File(_path);
if (passwordFile.exists() && !passwordFile.canRead()) {
throw new IllegalConfigurationException(String.format("Cannot read password file '%s'. Please check permissions.", _path));
}
}
Aggregations