Search in sources :

Example 6 with PreferenceRecordImpl

use of org.apache.qpid.server.store.preferences.PreferenceRecordImpl in project qpid-broker-j by apache.

the class BDBPreferenceStoreTest method testUpdateOrCreate.

public void testUpdateOrCreate() throws Exception {
    _preferenceStore.openAndLoad(_updater);
    PreferenceRecord oldRecord = _testInitialRecords.get(0);
    Collection<PreferenceRecord> records = Arrays.<PreferenceRecord>asList(new PreferenceRecordImpl(oldRecord.getId(), Collections.<String, Object>singletonMap("name", "test2")), new PreferenceRecordImpl(UUID.randomUUID(), Collections.<String, Object>singletonMap("name", "test3")));
    _preferenceStore.updateOrCreate(records);
    _preferenceStore.close();
    Collection<PreferenceRecord> recovered = _preferenceStore.openAndLoad(_updater);
    List<PreferenceRecord> expected = new ArrayList<>(records);
    expected.add(_testInitialRecords.get(1));
    PreferenceTestHelper.assertRecords(expected, recovered);
}
Also used : PreferenceRecord(org.apache.qpid.server.store.preferences.PreferenceRecord) ArrayList(java.util.ArrayList) PreferenceRecordImpl(org.apache.qpid.server.store.preferences.PreferenceRecordImpl) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 7 with PreferenceRecordImpl

use of org.apache.qpid.server.store.preferences.PreferenceRecordImpl in project qpid-broker-j by apache.

the class DerbyPreferenceStoreTest method testReplace.

public void testReplace() throws Exception {
    populateTestData();
    _preferenceStore.openAndLoad(_updater);
    Collection<PreferenceRecord> testRecords = new ArrayList<>();
    testRecords.add(new PreferenceRecordImpl(UUID.randomUUID(), Collections.<String, Object>singletonMap("name", "newOne")));
    _preferenceStore.replace(Collections.singleton(_testRecords.get(0).getId()), testRecords);
    testRecords.add(_testRecords.get(1));
    _testConnection = DriverManager.getConnection(_connectionUrl);
    List<PreferenceRecord> records = getPreferenceRecords();
    assertRecords(testRecords, records);
}
Also used : PreferenceRecord(org.apache.qpid.server.store.preferences.PreferenceRecord) ArrayList(java.util.ArrayList) PreferenceRecordImpl(org.apache.qpid.server.store.preferences.PreferenceRecordImpl) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Aggregations

PreferenceRecordImpl (org.apache.qpid.server.store.preferences.PreferenceRecordImpl)7 PreferenceRecord (org.apache.qpid.server.store.preferences.PreferenceRecord)6 ArrayList (java.util.ArrayList)3 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 LinkedHashSet (java.util.LinkedHashSet)2 UUID (java.util.UUID)2 Cursor (com.sleepycat.je.Cursor)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 StoreException (org.apache.qpid.server.store.StoreException)1 MapBinding (org.apache.qpid.server.store.berkeleydb.tuple.MapBinding)1 UUIDTupleBinding (org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding)1 PreferenceStoreUpdater (org.apache.qpid.server.store.preferences.PreferenceStoreUpdater)1