use of com.enonic.xp.internal.blobstore.MemoryBlobStore in project xp by enonic.
the class AbstractNodeTest method setUpNode.
@BeforeEach
protected void setUpNode() throws Exception {
eventPublisher = Mockito.mock(EventPublisher.class);
deleteAllIndices();
final RepoConfiguration repoConfig = Mockito.mock(RepoConfiguration.class);
Mockito.when(repoConfig.getSnapshotsDir()).thenReturn(this.temporaryFolder.resolve("repo").resolve("snapshots"));
System.setProperty("xp.home", temporaryFolder.toFile().getPath());
System.setProperty("mapper.allow_dots_in_name", "true");
ContextAccessor.INSTANCE.set(ctxDefault());
this.blobStore = new MemoryBlobStore();
this.binaryService = new BinaryServiceImpl();
this.binaryService.setBlobStore(blobStore);
storageDao = new StorageDaoImpl();
storageDao.setClient(client);
this.searchDao = new SearchDaoImpl();
this.searchDao.setClient(client);
this.indexServiceInternal = new IndexServiceInternalImpl();
this.indexServiceInternal.setClient(client);
// Branch and version-services
this.branchService = new BranchServiceImpl();
this.branchService.setStorageDao(storageDao);
this.branchService.setSearchDao(this.searchDao);
this.versionService = new VersionServiceImpl();
this.versionService.setStorageDao(storageDao);
this.commitService = new CommitServiceImpl();
this.commitService.setStorageDao(storageDao);
// Storage-service
this.nodeDao = new NodeVersionServiceImpl();
this.nodeDao.setBlobStore(blobStore);
this.indexedDataService = new IndexDataServiceImpl();
this.indexedDataService.setStorageDao(storageDao);
this.storageService = new NodeStorageServiceImpl();
this.storageService.setVersionService(this.versionService);
this.storageService.setBranchService(this.branchService);
this.storageService.setCommitService(this.commitService);
this.storageService.setNodeVersionService(this.nodeDao);
this.storageService.setIndexDataService(this.indexedDataService);
// Search-service
this.searchService = new NodeSearchServiceImpl();
this.searchService.setSearchDao(this.searchDao);
setUpRepositoryServices();
indexService = new IndexServiceImpl();
indexService.setIndexDataService(this.indexedDataService);
indexService.setIndexServiceInternal(this.indexServiceInternal);
indexService.setNodeSearchService(this.searchService);
indexService.setNodeVersionService(this.nodeDao);
indexService.setRepositoryEntryService(this.repositoryEntryService);
bootstrap();
createTestRepository();
}
use of com.enonic.xp.internal.blobstore.MemoryBlobStore in project xp by enonic.
the class AbstractBlobVacuumTaskTest method setUp.
public void setUp() throws Exception {
this.blobStore = new MemoryBlobStore();
this.nodeService = Mockito.mock(NodeService.class);
Mockito.when(nodeService.findVersions(Mockito.any(NodeVersionQuery.class))).thenAnswer((invocation) -> {
final NodeVersionQuery query = invocation.getArgument(0);
final ValueFilter valueFilter = (ValueFilter) query.getQueryFilters().first();
if (valueFilter.getValues().contains(ValueFactory.newString(createBlobKey('a').toString()))) {
return NodeVersionQueryResult.empty(1);
}
return NodeVersionQueryResult.empty(0);
});
}
use of com.enonic.xp.internal.blobstore.MemoryBlobStore in project xp by enonic.
the class CachedBlobStoreTest method lastModified_updated.
@Test
public void lastModified_updated() throws Exception {
final MemoryBlobStore memoryBlobStore = new MemoryBlobStore();
final ByteSource source = ByteSource.wrap("abc".getBytes());
final BlobRecord record = memoryBlobStore.addRecord(this.segment, source);
this.cachedBlobStore = CachedBlobStore.create().blobStore(memoryBlobStore).memoryCapacity(100).sizeTreshold(10).build();
// Cache this
this.cachedBlobStore.getRecord(this.segment, record.getKey());
// Add same record again
final BlobRecord updatedRecord = this.cachedBlobStore.addRecord(this.segment, source);
// Only single entry added
final List<BlobRecord> cached = this.cachedBlobStore.list(this.segment).collect(Collectors.toList());
assertEquals(1, cached.size());
final BlobRecord retrievedAfterStore = this.cachedBlobStore.getRecord(this.segment, record.getKey());
assertNotNull(retrievedAfterStore);
assertEquals(updatedRecord.lastModified(), retrievedAfterStore.lastModified());
}
use of com.enonic.xp.internal.blobstore.MemoryBlobStore in project xp by enonic.
the class SecurityServiceImplTest method setUp.
@BeforeEach
public void setUp() throws Exception {
deleteAllIndices();
final MemoryBlobStore blobStore = new MemoryBlobStore();
final BinaryServiceImpl binaryService = new BinaryServiceImpl();
binaryService.setBlobStore(blobStore);
final StorageDaoImpl storageDao = new StorageDaoImpl();
storageDao.setClient(client);
final SearchDaoImpl searchDao = new SearchDaoImpl();
searchDao.setClient(client);
final BranchServiceImpl branchService = new BranchServiceImpl();
branchService.setStorageDao(storageDao);
branchService.setSearchDao(searchDao);
final VersionServiceImpl versionService = new VersionServiceImpl();
versionService.setStorageDao(storageDao);
final NodeVersionServiceImpl nodeDao = new NodeVersionServiceImpl();
nodeDao.setBlobStore(blobStore);
this.indexServiceInternal = new IndexServiceInternalImpl();
this.indexServiceInternal.setClient(client);
final NodeSearchServiceImpl searchService = new NodeSearchServiceImpl();
searchService.setSearchDao(searchDao);
IndexDataServiceImpl indexedDataService = new IndexDataServiceImpl();
indexedDataService.setStorageDao(storageDao);
final NodeStorageServiceImpl storageService = new NodeStorageServiceImpl();
storageService.setBranchService(branchService);
storageService.setVersionService(versionService);
storageService.setNodeVersionService(nodeDao);
storageService.setIndexDataService(indexedDataService);
final NodeRepositoryServiceImpl nodeRepositoryService = new NodeRepositoryServiceImpl();
nodeRepositoryService.setIndexServiceInternal(this.indexServiceInternal);
final RepositoryEntryServiceImpl repositoryEntryService = new RepositoryEntryServiceImpl();
repositoryEntryService.setIndexServiceInternal(this.indexServiceInternal);
repositoryEntryService.setNodeStorageService(storageService);
repositoryEntryService.setEventPublisher(Mockito.mock(EventPublisher.class));
this.repositoryService = new RepositoryServiceImpl(repositoryEntryService, this.indexServiceInternal, nodeRepositoryService, storageService, searchService);
this.repositoryService.initialize();
this.eventPublisher = Mockito.mock(EventPublisher.class);
this.nodeService = new NodeServiceImpl();
this.nodeService.setIndexServiceInternal(indexServiceInternal);
this.nodeService.setNodeSearchService(searchService);
this.nodeService.setNodeStorageService(storageService);
this.nodeService.setBinaryService(binaryService);
this.nodeService.setRepositoryService(repositoryService);
this.nodeService.setEventPublisher(this.eventPublisher);
this.nodeService.initialize();
IndexServiceImpl indexService = new IndexServiceImpl();
indexService.setNodeSearchService(searchService);
indexService.setIndexServiceInternal(this.indexServiceInternal);
AuditLogConfig auditLogConfig = Mockito.mock(AuditLogConfig.class);
Mockito.when(auditLogConfig.isEnabled()).thenReturn(true);
Mockito.when(auditLogConfig.isOutputLogs()).thenReturn(true);
AuditLogService auditLogService = new AuditLogServiceImpl(auditLogConfig, indexService, repositoryService, nodeService);
SecurityConfig securityConfig = Mockito.mock(SecurityConfig.class);
Mockito.when(securityConfig.auditlog_enabled()).thenReturn(true);
SecurityAuditLogSupportImpl securityAuditLogSupport = new SecurityAuditLogSupportImpl(auditLogService);
securityAuditLogSupport.activate(securityConfig);
securityService = new SecurityServiceImpl(this.nodeService, indexService, securityAuditLogSupport);
runAsAdmin(() -> securityService.initialize());
}
Aggregations