public void testArchiveLocationMemento() throws Exception { IVMInstall vm = JavaRuntime.getDefaultVMInstall(); IJavaSourceLocation location = new ArchiveSourceLocation( JavaRuntime.getLibraryLocations(vm)[0].getSystemLibraryPath().toOSString(), null); String memento = location.getMemento(); IJavaSourceLocation restored = new ArchiveSourceLocation(); restored.initializeFrom(memento); assertEquals("archive locations should be equal", location, restored); }
public void testJavaSourceLocatorMemento() throws Exception { IJavaSourceLocation location1 = new JavaProjectSourceLocation(get14Project()); File dir = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(); IJavaSourceLocation location2 = new DirectorySourceLocation(dir); IVMInstall vm = JavaRuntime.getDefaultVMInstall(); IJavaSourceLocation location3 = new ArchiveSourceLocation( JavaRuntime.getLibraryLocations(vm)[0].getSystemLibraryPath().toOSString(), null); JavaSourceLocator locator = new JavaSourceLocator(new IJavaSourceLocation[] {location1, location2, location3}); String memento = locator.getMemento(); JavaSourceLocator restored = new JavaSourceLocator(); restored.initializeFromMemento(memento); IJavaSourceLocation[] locations = restored.getSourceLocations(); assertEquals("wrong number of source locations", 3, locations.length); assertEquals("1st locations not equal", location1, locations[0]); assertEquals("2nd locations not equal", location2, locations[1]); assertEquals("3rd locations not equal", location3, locations[2]); }