Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d870193e127879b9e9feb8f85b7aaab62cdcff3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.osgi.tests.eclipseadaptor;

import org.eclipse.osgi.framework.util.FilePath;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.tests.OSGiTest;

public class FilePathTest extends OSGiTest {

	public static Test suite() {
		return new TestSuite(FilePathTest.class);
	}

	public FilePathTest(String name) {
		super(name);
	}

	public void testColonOnPath() {
		FilePath path = new FilePath("/c:b/a");
		if (Platform.getOS().equals(Platform.OS_WIN32)) {
			// Windows-specific testing
			assertTrue("1.0", !path.isAbsolute());
			assertEquals("2.0", "c:", path.getDevice());
			String[] segments = path.getSegments();
			assertEquals("3.0", 2, segments.length);
			assertEquals("3.1", "b", segments[0]);
			assertEquals("3.2", "a", segments[1]);
			return;
		}
		// this runs on non-Windows platforms		
		assertTrue("1.0", path.isAbsolute());
		assertNull("2.0", path.getDevice());
		String[] segments = path.getSegments();
		assertEquals("3.0", 2, segments.length);
		assertEquals("3.1", "c:b", segments[0]);
		assertEquals("3.2", "a", segments[1]);
	}

}

Back to the top