blob: b770245d1ee88e3bb38c5d2e8bef25f3e9690010 (
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
|
/*******************************************************************************
* Copyright (c) 2007 Versant Corp.
* 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:
* Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
******************************************************************************/
package org.eclipse.ecf.tests.provider.jslp;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer;
import org.eclipse.ecf.tests.discovery.DiscoveryTest;
public class JSLPDiscoveryTest extends DiscoveryTest {
static {
// we need SA functionality
assertFalse("jSLP tests require net.slp.uaonly to be set to false because they need SA functionality.", new Boolean(System.getProperty("net.slp.uaonly")).booleanValue());
// tests need root privileges to bind to slp port 427 in SA mode
int port;
try {
port = Integer.parseInt(System.getProperty("net.slp.port", "427"));
} catch (NumberFormatException e) {
port = 427;
}
if(port <= 1024) {
System.err.println("jSLP tests require root privileges to bind to port 427 (Alternatively the port can be set to a high port via -Dnet.slp.port=theHighPort");
}
}
public JSLPDiscoveryTest() {
super(JSLPDiscoveryContainer.NAME, JSLPDiscoveryContainer.REDISCOVER, new JSLPTestComparator());
}
/* (non-Javadoc)
* @see org.eclipse.ecf.tests.discovery.DiscoveryTest#testRegisterService()
*/
public void testRegisterService() {
testConnect();
registerService();
// SLP discovery doesn't search in all scopes and it is not possible to query for all reachable scopes, thus we need to pass the "local" scope
final IServiceInfo[] services = discoveryContainer.getServices(serviceInfo.getServiceID().getServiceTypeID());
assertTrue(services.length >= 1);
for (int i = 0; i < services.length; i++) {
final IServiceInfo service = services[i];
if (comparator.compare(service, serviceInfo) == 0) {
return;
}
}
fail("Self registered service not found");
}
/* (non-Javadoc)
* @see org.eclipse.ecf.tests.discovery.DiscoveryTest#testGetServices()
*/
public void testGetServices() {
testConnect();
registerService();
// SLP discovery doesn't search in all scopes and it is not possible to query for all reachable scopes, thus we need to pass the "local" scope
final IServiceInfo[] services = discoveryContainer.getServices(serviceInfo.getServiceID().getServiceTypeID());
assertTrue(services.length >= 1);
}
public void testJSLPLocatorNull() {
//Activator.getDefault().getLocator() == null always
fail("not yet implemented");
}
public void testJSLPAdvertiserNull() {
//Activator.getDefault().getAdvertiser() == null always
fail("not yet implemtend");
}
public void testJSLPBundleBecomesUnavailable() {
// dynamic OSGi!
fail("not yet implemtend");
}
}
|