Search in sources :

Example 6 with Descriptor

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();
}
Also used : ModuleService(org.alfresco.service.cmr.module.ModuleService) ThumbnailService(org.alfresco.service.cmr.thumbnail.ThumbnailService) TransactionService(org.alfresco.service.transaction.TransactionService) HashMap(java.util.HashMap) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) DefaultChildApplicationContextManager(org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager) SpringExtensionBundle(org.alfresco.traitextender.SpringExtensionBundle) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) ChildApplicationContextFactory(org.alfresco.repo.management.subsystems.ChildApplicationContextFactory) RepoUsageComponent(org.alfresco.repo.usage.RepoUsageComponent) WebDavService(org.alfresco.service.cmr.webdav.WebDavService) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) WorkflowAdminService(org.alfresco.service.cmr.workflow.WorkflowAdminService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) AuditService(org.alfresco.service.cmr.audit.AuditService) ServerModeProvider(org.alfresco.repo.mode.ServerModeProvider) Before(org.junit.Before)

Example 7 with Descriptor

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();
}
Also used : TransactionService(org.alfresco.service.transaction.TransactionService) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) CustomModelsInfo(org.alfresco.repo.dictionary.CustomModelsInfo) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) CustomModelService(org.alfresco.service.cmr.dictionary.CustomModelService) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) Before(org.junit.Before)

Example 8 with Descriptor

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);
}
Also used : Descriptor(org.alfresco.service.descriptor.Descriptor) ServiceRegistry(org.alfresco.service.ServiceRegistry) DescriptorService(org.alfresco.service.descriptor.DescriptorService) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Example 9 with Descriptor

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);
}
Also used : Descriptor(org.alfresco.service.descriptor.Descriptor) ServiceRegistry(org.alfresco.service.ServiceRegistry) DescriptorService(org.alfresco.service.descriptor.DescriptorService) BaseSpringTest(org.alfresco.util.BaseSpringTest) Test(org.junit.Test)

Example 10 with Descriptor

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.
        }
    }
}
Also used : Connection(java.sql.Connection) Descriptor(org.alfresco.service.descriptor.Descriptor) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

Descriptor (org.alfresco.service.descriptor.Descriptor)26 DescriptorService (org.alfresco.service.descriptor.DescriptorService)7 HeartBeatJobScheduler (org.alfresco.heartbeat.jobs.HeartBeatJobScheduler)6 DescriptorDAO (org.alfresco.repo.descriptor.DescriptorDAO)6 HBDataCollectorService (org.alfresco.service.cmr.repository.HBDataCollectorService)6 Before (org.junit.Before)6 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)5 ServiceRegistry (org.alfresco.service.ServiceRegistry)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 LicenseDescriptor (org.alfresco.service.license.LicenseDescriptor)4 BaseSpringTest (org.alfresco.util.BaseSpringTest)4 Test (org.junit.Test)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2