use of org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject in project linuxtools by eclipse.
the class CreaterepoProjectTest method testInitialize.
/**
* Test if initializing createrepo project is successful. This means that
* content folder is initialized but not created (done by wizard, import, or
* execute commands) and that .repo file exists.
*
* @throws CoreException
*/
@Test
public void testInitialize() throws CoreException {
CreaterepoProject createrepoProject = new CreaterepoProject(project, (IFile) project.findMember(ICreaterepoTestConstants.REPO_NAME));
// content folder is defined, but not created (wizard does that)
assertNotNull(createrepoProject.getContentFolder());
assertFalse(createrepoProject.getContentFolder().exists());
// repo file is found and exists
assertNotNull(createrepoProject.getRepoFile());
assertTrue(createrepoProject.getRepoFile().exists());
assertEquals(ICreaterepoTestConstants.REPO_NAME, createrepoProject.getRepoFile().getName());
}
use of org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject in project linuxtools by eclipse.
the class CreaterepoProjectTest method testImportRPM.
/**
* Test if importing RPMs from external source successfully saves into
* the "content" folder.
*
* @throws CoreException
* @throws IOException
*/
@Test
public void testImportRPM() throws CoreException, IOException {
CreaterepoProject createrepoProject = new CreaterepoProject(project);
// test for file
URL rpmURL = FileLocator.find(FrameworkUtil.getBundle(CreaterepoProjectTest.class), new Path(TEST_RPM_LOC1), null);
File rpmFile = new File(FileLocator.toFileURL(rpmURL).getPath());
createrepoProject.importRPM(rpmFile);
assertNotNull(createrepoProject.getContentFolder());
assertTrue(createrepoProject.getContentFolder().exists());
assertEquals(1, createrepoProject.getContentFolder().members().length);
assertTrue(createrepoProject.getContentFolder().findMember(ICreaterepoTestConstants.RPM1).exists());
// test for duplicate file
createrepoProject.importRPM(rpmFile);
assertEquals(1, createrepoProject.getContentFolder().members().length);
assertTrue(createrepoProject.getContentFolder().findMember(ICreaterepoTestConstants.RPM1).exists());
// test for new file
rpmURL = FileLocator.find(FrameworkUtil.getBundle(CreaterepoProjectTest.class), new Path(TEST_RPM_LOC2), null);
rpmFile = new File(FileLocator.toFileURL(rpmURL).getPath());
createrepoProject.importRPM(rpmFile);
assertEquals(2, createrepoProject.getContentFolder().members().length);
assertTrue(createrepoProject.getContentFolder().findMember(ICreaterepoTestConstants.RPM2).exists());
}
use of org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject in project linuxtools by eclipse.
the class CreaterepoCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// $NON-NLS-1$
final String executionType = event.getParameter("executionType");
try {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage();
IEditorInput editorInput = wbPage.getActiveEditor().getEditorInput();
IResource resource = ResourceUtil.getResource(editorInput);
final CreaterepoProject project = new CreaterepoProject(resource.getProject());
Job executeCreaterepo = new Job(Messages.Createrepo_jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.CreaterepoProject_executeCreaterepo, IProgressMonitor.UNKNOWN);
MessageConsoleStream os = CreaterepoUtils.findConsole(Messages.CreaterepoProject_consoleName).newMessageStream();
if (executionType.equals("refresh")) {
// $NON-NLS-1$
return project.update(os);
} else {
return project.createrepo(os);
}
} catch (CoreException e) {
Activator.logError(Messages.Createrepo_errorExecuting, e);
} finally {
monitor.done();
}
return null;
}
};
executeCreaterepo.setUser(true);
executeCreaterepo.schedule();
} catch (CoreException e) {
Activator.logError(Messages.CreaterepoProject_executeCreaterepo, e);
}
return null;
}
use of org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject in project linuxtools by eclipse.
the class RepoFormEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
IFile file = ResourceUtil.getFile(input);
setPartName(file.getName());
try {
project = new CreaterepoProject(file.getProject(), file);
} catch (CoreException e) {
Activator.logError(Messages.RepoFormEditor_errorInitializingProject, e);
}
resourceChangeListener = new CreaterepoResourceChangeListener(project);
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener);
}
use of org.eclipse.linuxtools.internal.rpm.createrepo.CreaterepoProject in project linuxtools by eclipse.
the class CreaterepoProjectTest method testSimpleExecute.
/**
* Simple test execution of createrepo. This checks to see if the "content" folder
* was created while executing and that the execution is successful if repomd.xml was created
* under the repodata folder.
*
* @throws CoreException
*/
@Test
@Ignore
public void testSimpleExecute() throws CoreException {
// assume that there is creatrepo version of >= 0.9.8
Assume.assumeTrue(Createrepo.isCorrectVersion().isOK());
CreaterepoProject createrepoProject = new CreaterepoProject(project);
// make sure that content folder doesn't exist
assertFalse(createrepoProject.getContentFolder().exists());
// $NON-NLS-1$
IStatus status = createrepoProject.createrepo(CreaterepoUtils.findConsole("test").newMessageStream());
// check if executing has an OK status and that content folder is created with the repodata contents
assertEquals(Status.OK_STATUS, status);
assertTrue(createrepoProject.getContentFolder().exists());
assertTrue(createrepoProject.getContentFolder().members().length > 0);
// check if the repodata folder exists and repomd.xml exists within it
assertTrue(createrepoProject.getContentFolder().findMember(ICreaterepoTestConstants.REPODATA_FOLDER).exists());
IFolder repodataFolder = (IFolder) createrepoProject.getContentFolder().findMember(ICreaterepoTestConstants.REPODATA_FOLDER);
// repodata should have at least more than 1 file: repomd.xml + archives
assertTrue(repodataFolder.members().length > 1);
assertTrue(repodataFolder.findMember(ICreaterepoTestConstants.REPO_MD_NAME).exists());
}
Aggregations