Search in sources :

Example 6 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQueryTest method testNoClauses_SingleResult.

public void testNoClauses_SingleResult() {
    final UUID objectUuid = UUID.randomUUID();
    final String objectName = "obj1";
    ConfiguredObject obj1 = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, objectUuid);
            put(ConfiguredObject.NAME, objectName);
        }
    });
    _objects.add(obj1);
    _query = new ConfiguredObjectQuery(_objects, null, null);
    final List<String> headers = _query.getHeaders();
    assertEquals("Unexpected headers", Lists.newArrayList(ConfiguredObject.ID, ConfiguredObject.NAME), headers);
    List<List<Object>> results = _query.getResults();
    assertEquals("Unexpected number of results", 1, results.size());
    List<Object> row = results.iterator().next();
    assertEquals("Unexpected row", Lists.newArrayList(objectUuid, objectName), row);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID)

Example 7 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQueryTest method testLimitWithoutOffset.

public void testLimitWithoutOffset() {
    int numberOfTestObjects = 3;
    for (int i = 0; i < numberOfTestObjects; i++) {
        final String name = "test-" + i;
        ConfiguredObject object = createCO(new HashMap<String, Object>() {

            {
                put("name", name);
            }
        });
        _objects.add(object);
    }
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "0");
    assertQueryResults(new Object[][] { { "test-0" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "1");
    assertQueryResults(new Object[][] { { "test-1" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "3");
    assertQueryResults(new Object[0][1], _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "1");
    assertQueryResults(new Object[][] { { "test-1" }, { "test-2" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "-4");
    assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "-2");
    assertQueryResults(new Object[][] { { "test-1" }, { "test-2" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", "invalidLimit", "invalidOffset");
    assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
    _query = new ConfiguredObjectQuery(_objects, "name", null, "name", null, null);
    assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 8 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQueryTest method testSingleOrderByClause.

public void testSingleOrderByClause() {
    final int NUMBER_OF_OBJECTS = 3;
    for (int i = 0; i < NUMBER_OF_OBJECTS; ++i) {
        final int foo = (i + 1) % NUMBER_OF_OBJECTS;
        ConfiguredObject object = createCO(new HashMap<String, Object>() {

            {
                put("foo", foo);
            }
        });
        _objects.add(object);
    }
    ConfiguredObject object = createCO(new HashMap<String, Object>() {

        {
            put("foo", null);
        }
    });
    _objects.add(object);
    List<List<Object>> results;
    _query = new ConfiguredObjectQuery(_objects, "foo", null, "foo ASC");
    results = _query.getResults();
    assertQueryResults(new Object[][] { { null }, { 0 }, { 1 }, { 2 } }, results);
    _query = new ConfiguredObjectQuery(_objects, "foo", null, "foo DESC");
    results = _query.getResults();
    assertQueryResults(new Object[][] { { 2 }, { 1 }, { 0 }, { null } }, results);
    // if not specified order should be ASC
    _query = new ConfiguredObjectQuery(_objects, "foo", null, "foo");
    results = _query.getResults();
    assertQueryResults(new Object[][] { { null }, { 0 }, { 1 }, { 2 } }, results);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQueryTest method testNoClauses_TwoResult.

public void testNoClauses_TwoResult() {
    final UUID object1Uuid = UUID.randomUUID();
    final String object1Name = "obj1";
    final UUID object2Uuid = UUID.randomUUID();
    final String object2Name = "obj2";
    ConfiguredObject obj1 = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, object1Uuid);
            put(ConfiguredObject.NAME, object1Name);
            put("foo", "bar");
        }
    });
    ConfiguredObject obj2 = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, object2Uuid);
            put(ConfiguredObject.NAME, object2Name);
        }
    });
    _objects.add(obj1);
    _objects.add(obj2);
    _query = new ConfiguredObjectQuery(_objects, null, null);
    List<List<Object>> results = _query.getResults();
    assertEquals("Unexpected number of results", 2, results.size());
    final Iterator<List<Object>> iterator = results.iterator();
    List<Object> row1 = iterator.next();
    assertEquals("Unexpected row", Lists.newArrayList(object1Uuid, object1Name), row1);
    List<Object> row2 = iterator.next();
    assertEquals("Unexpected row", Lists.newArrayList(object2Uuid, object2Name), row2);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID)

Example 10 with ConfiguredObject

use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.

the class ConfiguredObjectQueryTest method testSelectClause_NonExistingColumn.

public void testSelectClause_NonExistingColumn() {
    ConfiguredObject obj = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, UUID.randomUUID());
        }
    });
    _objects.add(obj);
    _query = new ConfiguredObjectQuery(_objects, "foo", null);
    List<List<Object>> results = _query.getResults();
    assertEquals("Unexpected number of results", 1, results.size());
    assertEquals("Unexpected headers", Collections.singletonList("foo"), _query.getHeaders());
    assertEquals("Unexpected row", Collections.singletonList(null), results.get(0));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)91 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)28 List (java.util.List)23 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)22 LinkedHashMap (java.util.LinkedHashMap)20 UUID (java.util.UUID)20 Map (java.util.Map)18 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)12 ManagedObject (org.apache.qpid.server.model.ManagedObject)11 Date (java.util.Date)7 TreeMap (java.util.TreeMap)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)6 State (org.apache.qpid.server.model.State)6 Collection (java.util.Collection)5 ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)5 Model (org.apache.qpid.server.model.Model)5 Preference (org.apache.qpid.server.model.preferences.Preference)5 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)4