use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.
the class ConfigurationDataCollectorTest method setUp.
@Before
public void setUp() {
smartFoldersBundle = mock(SpringExtensionBundle.class);
mockDescriptorDAO = mock(DescriptorDAO.class);
mockServerDescriptorDAO = mock(DescriptorDAO.class);
mockCollectorService = mock(HBDataCollectorService.class);
mockScheduler = mock(HeartBeatJobScheduler.class);
Descriptor mockDescriptor = mock(Descriptor.class);
when(mockDescriptor.getId()).thenReturn("mock_id");
when(mockServerDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
BasicDataSource mockBasicDataSource = mock(BasicDataSource.class);
RepoUsageComponent mockRepoUsageComponent = mock(RepoUsageComponent.class);
ServerModeProvider mockServerModeProvider = mock(ServerModeProvider.class);
when(mockServerModeProvider.getServerMode()).thenReturn(SERVER_MODE);
ChildApplicationContextFactory mockFileServerSubsystem = mock(ChildApplicationContextFactory.class);
WebDavService mockWebDavService = mock(WebDavService.class);
ThumbnailService mockThumbnailService = mock(ThumbnailService.class);
ChildApplicationContextFactory mockActivitiesFeedSubsystem = mock(ChildApplicationContextFactory.class);
WorkflowAdminService mockWorkflowAdminService = mock(WorkflowAdminService.class);
ChildApplicationContextFactory mockInboundSMTPSubsystem = mock(ChildApplicationContextFactory.class);
ChildApplicationContextFactory mockImapSubsystem = mock(ChildApplicationContextFactory.class);
ChildApplicationContextFactory mockReplication = mock(ChildApplicationContextFactory.class);
// mock modules and module service
ModuleService mockModuleService = mock(ModuleService.class);
ModuleDetails mockInstalledModule1 = mock(ModuleDetails.class);
when(mockInstalledModule1.getId()).thenReturn(INSTALLED_MODULE_ID_1);
when(mockInstalledModule1.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_1);
ModuleDetails mockInstalledModule2 = mock(ModuleDetails.class);
when(mockInstalledModule2.getId()).thenReturn(INSTALLED_MODULE_ID_2);
when(mockInstalledModule2.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_2);
ModuleDetails mockMissingModule = mock(ModuleDetails.class);
when(mockMissingModule.getId()).thenReturn(MISSING_MODULE_ID_1);
when(mockMissingModule.getModuleVersionNumber()).thenReturn(MISSING_MODULE_VERSION_1);
when(mockModuleService.getAllModules()).thenReturn(Arrays.asList(mockInstalledModule1, mockInstalledModule2));
when(mockModuleService.getMissingModules()).thenReturn(Arrays.asList(mockMissingModule));
// mock audit applications and audit service
AuditService mockAuditService = mock(AuditService.class);
AuditService.AuditApplication mockAuditApp = mock(AuditService.AuditApplication.class);
when(mockAuditApp.isEnabled()).thenReturn(AUDIT_APP_ENABLED);
Map<String, AuditService.AuditApplication> auditApps = new HashMap<>();
auditApps.put(AUDIT_APP_NAME, mockAuditApp);
TransactionService mockTransactionService = mock(TransactionService.class);
RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
// Mock transaction service calls
when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(// First call made by the collector to get the server readOnly value via transformation service
true).thenReturn(// Second call to get the audit applications
auditApps);
when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
// mock authentication chain
DefaultChildApplicationContextManager mockAuthenticationSubsystem = mock(DefaultChildApplicationContextManager.class);
configurationCollector = new ConfigurationDataCollector("acs.repository.configuration", "1.0", "0 0 0 ? * SUN", mockScheduler);
configurationCollector.setHbDataCollectorService(mockCollectorService);
configurationCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
configurationCollector.setSmartFoldersBundle(smartFoldersBundle);
configurationCollector.setDataSource(mockBasicDataSource);
configurationCollector.setTransactionService(mockTransactionService);
configurationCollector.setRepoUsageComponent(mockRepoUsageComponent);
configurationCollector.setServerModeProvider(mockServerModeProvider);
configurationCollector.setFileServersSubsystem(mockFileServerSubsystem);
configurationCollector.setWebdavService(mockWebDavService);
configurationCollector.setThumbnailService(mockThumbnailService);
configurationCollector.setActivitiesFeedSubsystem(mockActivitiesFeedSubsystem);
configurationCollector.setWorkflowAdminService(mockWorkflowAdminService);
configurationCollector.setInboundSMTPSubsystem(mockInboundSMTPSubsystem);
configurationCollector.setImapSubsystem(mockImapSubsystem);
configurationCollector.setReplicationSubsystem(mockReplication);
configurationCollector.setModuleService(mockModuleService);
configurationCollector.setAuditService(mockAuditService);
configurationCollector.setAuthenticationSubsystem(mockAuthenticationSubsystem);
collectedData = configurationCollector.collectData();
}
use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.
the class ModelUsageDataCollectorTest method setUp.
@Before
public void setUp() {
mockDescriptorDAO = mock(DescriptorDAO.class);
mockCollectorService = mock(HBDataCollectorService.class);
mockScheduler = mock(HeartBeatJobScheduler.class);
Descriptor mockDescriptor = mock(Descriptor.class);
when(mockDescriptor.getId()).thenReturn("mock_id");
when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
CustomModelsInfo mockCustomModelsInfo = mock(CustomModelsInfo.class);
CustomModelService customModelService = mock(CustomModelService.class);
when(customModelService.getCustomModelsInfo()).thenReturn(mockCustomModelsInfo);
TransactionService mockTransactionService = mock(TransactionService.class);
RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(mockCustomModelsInfo);
when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
usageModelCollector = new ModelUsageDataCollector("acs.repository.usage.model", "1.0", "0 0 0 ? * *", mockScheduler);
usageModelCollector.setHbDataCollectorService(mockCollectorService);
usageModelCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
usageModelCollector.setCustomModelService(customModelService);
usageModelCollector.setTransactionService(mockTransactionService);
collectedData = usageModelCollector.collectData();
}
use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.
the class DescriptorServiceTest method testCurrentRepositoryDescriptor.
/**
* Test current repository descriptor
*/
@Test
public void testCurrentRepositoryDescriptor() {
ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
DescriptorService descriptorService = registry.getDescriptorService();
Descriptor repoDescriptor = descriptorService.getCurrentRepositoryDescriptor();
String major = repoDescriptor.getVersionMajor();
String minor = repoDescriptor.getVersionMinor();
String revision = repoDescriptor.getVersionRevision();
String label = repoDescriptor.getVersionLabel();
String build = repoDescriptor.getVersionBuild();
String id = repoDescriptor.getId();
String version = major + "." + minor + "." + revision;
version = buildVersionString(version, label, build);
assertEquals(version, repoDescriptor.getVersion());
assertNotNull("repository id is null", id);
assertNotNull("major is null", major);
assertNotNull("minor is null", minor);
assertNotNull("revision is null", revision);
int schemaVersion = repoDescriptor.getSchema();
assertTrue("Repository schema version must be greater than -1", schemaVersion > -1);
}
use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.
the class DescriptorServiceTest method testInstalledRepositoryDescriptor.
// TODO : missing getLicenceDescriptor
/**
* Test installed repository descriptor
*/
@Test
public void testInstalledRepositoryDescriptor() {
ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
DescriptorService descriptorService = registry.getDescriptorService();
Descriptor repoDescriptor = descriptorService.getInstalledRepositoryDescriptor();
String major = repoDescriptor.getVersionMajor();
String minor = repoDescriptor.getVersionMinor();
String revision = repoDescriptor.getVersionRevision();
String label = repoDescriptor.getVersionLabel();
String build = repoDescriptor.getVersionBuild();
String version = major + "." + minor + "." + revision;
version = buildVersionString(version, label, build);
assertEquals(version, repoDescriptor.getVersion());
int schemaVersion = repoDescriptor.getSchema();
assertTrue("Repository schema version must be greater than -1", schemaVersion > -1);
}
use of org.alfresco.service.descriptor.Descriptor in project alfresco-repository by Alfresco.
the class ExportDb method execute.
public void execute() {
PropertyCheck.mandatory(this, "dataSource", dataSource);
PropertyCheck.mandatory(this, "dialect", dialect);
PropertyCheck.mandatory(this, "descriptorService", descriptorService);
Connection connection = null;
try {
connection = dataSource.getConnection();
connection.setAutoCommit(false);
Descriptor descriptor = descriptorService.getServerDescriptor();
int schemaVersion = descriptor.getSchema();
execute(connection, schemaVersion);
} catch (Exception e) {
throw new RuntimeException("Unable to execute export.", e);
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (Throwable e) {
// Little can be done at this stage.
}
}
}
Aggregations