Search in sources :

Example 1 with ProjectRegistry

use of org.eclipse.che.api.project.server.ProjectRegistry in project che by eclipse.

the class BaseTest method initProjectApi.

@BeforeMethod
protected void initProjectApi() throws Exception {
    mavenServerManager = new MavenServerManager(mavenServerPath);
    workspaceHolder = new TestWorkspaceHolder();
    if (root == null)
        root = new File(wsPath);
    if (root.exists()) {
        IoUtil.deleteRecursive(root);
    }
    root.mkdir();
    File indexDir = new File(INDEX_PATH);
    if (indexDir.exists()) {
        IoUtil.deleteRecursive(indexDir);
    }
    indexDir.mkdir();
    Set<PathMatcher> filters = new HashSet<>();
    filters.add(path -> true);
    FSLuceneSearcherProvider sProvider = new FSLuceneSearcherProvider(indexDir, filters);
    vfsProvider = new LocalVirtualFileSystemProvider(root, sProvider);
    projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
    projectTypeRegistry.registerProjectType(new TestProjectType());
    projectTypeRegistry.registerProjectType(new JavaProjectType(new JavaValueProviderFactory()));
    projectTypeRegistry.registerProjectType(new MavenProjectType(new MavenValueProviderFactory()));
    projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
    projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
    projectRegistry.initProjects();
    importerRegistry = new ProjectImporterRegistry(new HashSet<>());
    fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider);
    fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler);
    pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, new TestWorkspaceHolder(new ArrayList<>()), mock(FileWatcherManager.class));
    plugin = new ResourcesPlugin("target/index", wsPath, () -> projectRegistry, () -> pm);
    plugin.start();
    javaPlugin.start();
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) MavenProjectType(org.eclipse.che.plugin.maven.server.projecttype.MavenProjectType) ProjectHandlerRegistry(org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry) JavaValueProviderFactory(org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory) ProjectImporterRegistry(org.eclipse.che.api.project.server.importer.ProjectImporterRegistry) LocalVirtualFileSystemProvider(org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider) ProjectManager(org.eclipse.che.api.project.server.ProjectManager) PathMatcher(java.nio.file.PathMatcher) DefaultFileWatcherNotificationHandler(org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) FileTreeWatcher(org.eclipse.che.api.vfs.impl.file.FileTreeWatcher) File(java.io.File) JavaProjectType(org.eclipse.che.plugin.java.server.projecttype.JavaProjectType) HashSet(java.util.HashSet) FSLuceneSearcherProvider(org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider) MavenValueProviderFactory(org.eclipse.che.plugin.maven.server.projecttype.MavenValueProviderFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with ProjectRegistry

use of org.eclipse.che.api.project.server.ProjectRegistry in project che by eclipse.

the class PomReconcilerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    File localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    projectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    ClasspathManager classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, projectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(projectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with ProjectRegistry

use of org.eclipse.che.api.project.server.ProjectRegistry in project che by eclipse.

the class WorkspaceTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = new MavenTerminal() {

        @Override
        public void print(int level, String message, Throwable throwable) throws RemoteException {
            System.out.println(message);
            if (throwable != null) {
                throwable.printStackTrace();
            }
        }
    };
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier), eventService, new EclipseWorkspaceProvider());
}
Also used : ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ArrayList(java.util.ArrayList) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with ProjectRegistry

use of org.eclipse.che.api.project.server.ProjectRegistry in project che by eclipse.

the class ClasspathManagerTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
    when(projectRegistryProvider.get()).thenReturn(projectRegistry);
    MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
    MavenTerminal terminal = (level, message, throwable) -> {
        System.out.println(message);
        if (throwable != null) {
            throwable.printStackTrace();
        }
    };
    localRepository = new File(new File("target/localRepo").getAbsolutePath());
    localRepository.mkdirs();
    mavenServerManager.setLocalRepository(localRepository);
    MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
    mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
    classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
    mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {

        @Override
        public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
        }

        @Override
        public void sendNotification(NotificationMessage message) {
            System.out.println(message.toString());
        }

        @Override
        public void send(JsonObject object, MessageType type) {
        }
    }, classpathManager, eventService, new EclipseWorkspaceProvider());
}
Also used : MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) JsonObject(com.google.gson.JsonObject) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Assert.assertNull(org.testng.Assert.assertNull) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) Mock(org.mockito.Mock) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) AfterMethod(org.testng.annotations.AfterMethod) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) IProject(org.eclipse.core.resources.IProject) BaseTest(org.eclipse.che.plugin.maven.server.BaseTest) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaCore(org.eclipse.jdt.core.JavaCore) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Assert.assertNotNull(org.testng.Assert.assertNotNull) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) File(java.io.File) IoUtil(org.eclipse.che.commons.lang.IoUtil) IType(org.eclipse.jdt.core.IType) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) List(java.util.List) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Assert.assertTrue(org.testng.Assert.assertTrue) Collections(java.util.Collections) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Set(java.util.Set) JsonObject(com.google.gson.JsonObject) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) Provider(com.google.inject.Provider) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) List(java.util.List) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) File(java.io.File) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with ProjectRegistry

use of org.eclipse.che.api.project.server.ProjectRegistry in project che by eclipse.

the class WorkspaceRoot method getProjects.

@Override
public IProject[] getProjects() {
    ProjectRegistry projectRegistry = workspace.getProjectRegistry();
    List<IProject> projects = new ArrayList<>();
    List<RegisteredProject> rootProjects = projectRegistry.getProjects();
    for (RegisteredProject rootProject : rootProjects) {
        Project project = new Project(new Path(rootProject.getPath()), workspace);
        projects.add(project);
    }
    return projects.toArray(new IProject[projects.size()]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IProject(org.eclipse.core.resources.IProject) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) ArrayList(java.util.ArrayList) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) IProject(org.eclipse.core.resources.IProject)

Aggregations

ProjectRegistry (org.eclipse.che.api.project.server.ProjectRegistry)9 File (java.io.File)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 JsonObject (com.google.gson.JsonObject)3 Provider (com.google.inject.Provider)3 PathMatcher (java.nio.file.PathMatcher)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 ProjectManager (org.eclipse.che.api.project.server.ProjectManager)3 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)3 ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)3 ProjectImporterRegistry (org.eclipse.che.api.project.server.importer.ProjectImporterRegistry)3 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)3 DefaultFileWatcherNotificationHandler (org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler)3 FileTreeWatcher (org.eclipse.che.api.vfs.impl.file.FileTreeWatcher)3 LocalVirtualFileSystemProvider (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider)3 FSLuceneSearcherProvider (org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider)3