Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 574f6fcbc1098ffd56e5fd0fa68057eff8c06336 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/****************************************************************************
 * Copyright (c) 2004 Composent, Inc. 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:
 *    Composent, Inc. - initial API and implementation
 *****************************************************************************/

package org.eclipse.ecf.tests.filetransfer;

import java.io.ByteArrayOutputStream;
import java.io.NotSerializableException;
import java.io.ObjectOutputStream;

import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.tests.ECFAbstractTestCase;

public class NamespaceTest extends ECFAbstractTestCase {

	private Namespace fixture;
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
		fixture = IDFactory.getDefault().getNamespaceByName("ecf.provider.filetransfer");
		assertNotNull(fixture);
	}
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
		fixture = null;
	}

	public void testNamespaceGetScheme() {
		String scheme = fixture.getScheme();
		assertNotNull(scheme);
	}
	
	public void testNamespaceGetName() {
		String name = fixture.getName();
		assertNotNull(name);
		assertTrue(name.equals("ecf.provider.filetransfer"));
	}
	
	public final void testSerializable() throws Exception {
		ByteArrayOutputStream buf = new ByteArrayOutputStream();
		ObjectOutputStream out = new ObjectOutputStream(buf);
		try {
			out.writeObject(fixture);
		} catch (NotSerializableException ex) {
			fail(ex.getLocalizedMessage());
		} finally {
			out.close();
		}
	}
	
	public final void testCreateID() throws Exception {
		ID newID = IDFactory.getDefault().createID(fixture, "http://www.news.com");
		assertNotNull(newID);
	}
	
	public final void testGetSupportedSchemes() throws Exception {
		String [] supportedSchemes = fixture.getSupportedSchemes();
		assertNotNull(supportedSchemes);
	}

	/*
	public final void testGetURLConnection() throws Exception {
		
		FileIDFactory.getDefault();
		URL anURL = new URL("foobar:http://slewis@lala.lala.com:3333/foo/bar/lala.txt?artifact=one&group=two");
		
		System.out.println("protocol="+anURL.getProtocol());
		System.out.println("auth="+anURL.getAuthority());
		System.out.println("defport="+anURL.getDefaultPort());
		System.out.println("port="+anURL.getPort());
		System.out.println("host="+anURL.getHost());
		System.out.println("file="+anURL.getFile());
		System.out.println("path="+anURL.getPath());
		System.out.println("ref="+anURL.getRef());
		System.out.println("query="+anURL.getQuery());
		System.out.println("userinfo="+anURL.getUserInfo());
		System.out.println("externalform="+anURL.toExternalForm());
		System.out.println("tostring="+anURL.toString());
		
		URLConnection connection = anURL.openConnection();
		assertNotNull(connection);
		
	}
	*/
}

Back to the top