use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.
the class ProjectManagerReadTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
new File(root, "/fromFolder").mkdir();
new File(root, "/normal").mkdir();
new File(root, "/normal/module").mkdir();
List<ProjectConfig> projects = new ArrayList<>();
projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/normal").withName("project1Name").withType("primary1"));
projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/fromConfig").withName("").withType("primary1"));
projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/normal/module").withName("project1Name").withType("primary1"));
workspaceHolder = new TestWorkspaceHolder(projects);
ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
projectTypeRegistry.registerProjectType(new PT1());
projectTypeRegistry.registerProjectType(new PT3());
ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
projectRegistry.initProjects();
pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, null, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, fileWatcherManager);
pm.initWatcher();
}
use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry 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();
}
use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.
the class JavaDebuggerTest method initProjectApi.
@BeforeClass
protected void initProjectApi() throws Exception {
TestWorkspaceHolder workspaceHolder = new TestWorkspaceHolder(new ArrayList<>());
File root = new File("target/test-classes/workspace");
assertTrue(root.exists());
File indexDir = new File("target/fs_index");
assertTrue(indexDir.mkdirs());
Set<PathMatcher> filters = new HashSet<>();
filters.add(path -> true);
FSLuceneSearcherProvider sProvider = new FSLuceneSearcherProvider(indexDir, filters);
EventService eventService = new EventService();
LocalVirtualFileSystemProvider vfsProvider = new LocalVirtualFileSystemProvider(root, sProvider);
ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
projectTypeRegistry.registerProjectType(new JavaProjectType(new JavaValueProviderFactory()));
ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
ProjectRegistry projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
projectRegistry.initProjects();
ProjectImporterRegistry importerRegistry = new ProjectImporterRegistry(new HashSet<>());
FileWatcherNotificationHandler fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider);
FileTreeWatcher fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler);
ProjectManager projectManager = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, mock(FileWatcherManager.class));
ResourcesPlugin resourcesPlugin = new ResourcesPlugin("target/index", root.getAbsolutePath(), () -> projectRegistry, () -> projectManager);
resourcesPlugin.start();
JavaPlugin javaPlugin = new JavaPlugin(root.getAbsolutePath() + "/.settings", resourcesPlugin, projectRegistry);
javaPlugin.start();
projectRegistry.setProjectType("test", "java", false);
JavaModelManager.getDeltaState().initializeRoots(true);
events = new ArrayBlockingQueue<>(10);
Map<String, String> connectionProperties = ImmutableMap.of("host", "localhost", "port", System.getProperty("debug.port"));
JavaDebuggerFactory factory = new JavaDebuggerFactory();
debugger = factory.create(connectionProperties, events::add);
}
use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.
the class ProjectServiceTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
WorkspaceProjectsSyncer workspaceHolder = new WsAgentTestBase.TestWorkspaceHolder();
File root = new File(FS_PATH);
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 -> {
for (java.nio.file.Path pathElement : path) {
if (pathElement == null || EXCLUDE_SEARCH_PATH.equals(pathElement.toString())) {
return true;
}
}
return false;
});
FSLuceneSearcherProvider sProvider = new FSLuceneSearcherProvider(indexDir, filters);
vfsProvider = new LocalVirtualFileSystemProvider(root, sProvider);
final EventService eventService = new EventService();
// PTs for test
ProjectTypeDef chuck = new ProjectTypeDef("chuck_project_type", "chuck_project_type", true, false) {
{
addConstantDefinition("x", "attr description", new AttributeValue(Arrays.asList("a", "b")));
}
};
Set<ProjectTypeDef> projectTypes = new HashSet<>();
final LocalProjectType myProjectType = new LocalProjectType("my_project_type", "my project type");
projectTypes.add(myProjectType);
projectTypes.add(new LocalProjectType("module_type", "module type"));
projectTypes.add(chuck);
ptRegistry = new ProjectTypeRegistry(projectTypes);
phRegistry = new ProjectHandlerRegistry(new HashSet<>());
importerRegistry = new ProjectImporterRegistry(Collections.<ProjectImporter>emptySet());
projectServiceLinksInjector = new ProjectServiceLinksInjector();
projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, ptRegistry, phRegistry, eventService);
projectRegistry.initProjects();
FileWatcherNotificationHandler fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider);
FileTreeWatcher fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler);
pm = new ProjectManager(vfsProvider, ptRegistry, projectRegistry, phRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, fileWatcherManager);
pm.initWatcher();
HttpJsonRequest httpJsonRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
//List<ProjectConfigDto> modules = new ArrayList<>();
projects = new ArrayList<>();
addMockedProjectConfigDto(myProjectType, "my_project");
when(httpJsonRequestFactory.fromLink(any())).thenReturn(httpJsonRequest);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
when(workspaceConfigMock.getProjects()).thenReturn(projects);
// verify(httpJsonRequestFactory).fromLink(eq(DtoFactory.newDto(Link.class)
// .withHref(apiEndpoint + "/workspace/" + workspace + "/project")
// .withMethod(PUT)));
DependencySupplierImpl dependencies = new DependencySupplierImpl();
dependencies.addInstance(ProjectTypeRegistry.class, ptRegistry);
dependencies.addInstance(UserDao.class, userDao);
dependencies.addInstance(ProjectManager.class, pm);
dependencies.addInstance(ProjectImporterRegistry.class, importerRegistry);
dependencies.addInstance(ProjectHandlerRegistry.class, phRegistry);
dependencies.addInstance(EventService.class, eventService);
dependencies.addInstance(ProjectServiceLinksInjector.class, projectServiceLinksInjector);
ResourceBinder resources = new ResourceBinderImpl();
ProviderBinder providers = ProviderBinder.getInstance();
EverrestProcessor processor = new EverrestProcessor(new EverrestConfiguration(), dependencies, new RequestHandlerImpl(new RequestDispatcher(resources), providers), null);
launcher = new ResourceLauncher(processor);
processor.addApplication(new Application() {
@Override
public Set<Class<?>> getClasses() {
return java.util.Collections.<Class<?>>singleton(ProjectService.class);
}
@Override
public Set<Object> getSingletons() {
return new HashSet<>(Arrays.asList(new ApiExceptionMapper()));
}
});
ApplicationContext.setCurrent(anApplicationContext().withProviders(providers).build());
env = org.eclipse.che.commons.env.EnvironmentContext.getCurrent();
}
use of org.eclipse.che.api.project.server.type.ProjectTypeRegistry in project che by eclipse.
the class ExtensionCasesTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
new File(root, "/project1").mkdir();
List<ProjectConfig> projects = new ArrayList<>();
projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/project1").withName("project1Name").withType("primary1"));
workspaceHolder = new TestWorkspaceHolder(projects);
ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
projectTypeRegistry.registerProjectType(new PT1());
//projectTypeRegistry.registerProjectType(new PT3());
//ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
projectRegistry.initProjects();
pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, null, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, fileWatcherManager);
pm.initWatcher();
projectHandlerRegistry.register(new ProjectInitHandler() {
@Override
public void onProjectInitialized(ProjectRegistry registry, FolderEntry projectFolder) throws ServerException, NotFoundException, ConflictException, ForbiddenException {
projectFolder.createFile("generated", "test".getBytes());
projectFolder.createFolder("project2");
projectRegistry.setProjectType("/project1/project2", BaseProjectType.ID, false);
//System.out.println(">>S>>> "+projectRegistry);
}
@Override
public String getProjectType() {
return "primary1";
}
});
}
Aggregations