Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 260416
Collapse All | Expand All

(-)src/org/eclipse/osgi/tests/services/datalocation/BasicLocationTests.java (+27 lines)
Lines 148-153 Link Here
148
		}
148
		}
149
	}
149
	}
150
150
151
	public void testCreateLocation05() {
152
		Location configLocation = LocationManager.getConfigurationLocation();
153
		File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testCreateLocation01");
154
		Location testLocation = configLocation.createLocation(null, null, false);
155
		try {
156
			testLocation.set(testLocationFile.toURL(), false);
157
		} catch (Throwable t) {
158
			fail("Failed to set location", t);
159
		}
160
		try {
161
			assertTrue("Could not lock location", testLocation.lock());
162
			assertFalse("Could lock a secend time", testLocation.lock());
163
			assertFalse("Could lock a third time", testLocation.lock());
164
		} catch (IOException e) {
165
			fail("Failed to lock location", e);
166
		} finally {
167
			testLocation.release();
168
		}
169
		try {
170
			assertTrue("Could not lock location", testLocation.lock());
171
		} catch (IOException e) {
172
			fail("Failed to lock location", e);
173
		} finally {
174
			testLocation.release();
175
		}
176
	}
177
151
	public void testSetLocationWithEmptyLockFile() {
178
	public void testSetLocationWithEmptyLockFile() {
152
		Location configLocation = LocationManager.getConfigurationLocation();
179
		Location configLocation = LocationManager.getConfigurationLocation();
153
		File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testSetLocationWithEmptyLockFile"); //$NON-NLS-1$
180
		File testLocationFile = OSGiTestsActivator.getContext().getDataFile("testLocations/testSetLocationWithEmptyLockFile"); //$NON-NLS-1$
(-)supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java (-1 / +2 lines)
Lines 190-196 Link Here
190
				throw new IOException(NLS.bind(EclipseAdaptorMsg.location_notFileProtocol, locationValue));
190
				throw new IOException(NLS.bind(EclipseAdaptorMsg.location_notFileProtocol, locationValue));
191
			throw new IllegalStateException(EclipseAdaptorMsg.location_noLockFile); // this is really unexpected
191
			throw new IllegalStateException(EclipseAdaptorMsg.location_noLockFile); // this is really unexpected
192
		}
192
		}
193
193
		if (isLocked())
194
			return false;
194
		File parentFile = new File(lock.getParent());
195
		File parentFile = new File(lock.getParent());
195
		if (!parentFile.exists())
196
		if (!parentFile.exists())
196
			if (!parentFile.mkdirs())
197
			if (!parentFile.mkdirs())

Return to bug 260416