-
Notifications
You must be signed in to change notification settings - Fork 55
/
WinPreferencesTest.java
62 lines (54 loc) · 1.94 KB
/
WinPreferencesTest.java
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
/*******************************************************************************
* Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.security.tests.storage;
import java.util.Map;
import org.eclipse.equinox.internal.security.tests.SecurityTestsActivator;
import org.junit.Before;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
* Tests Windows module, if available.
*/
public class WinPreferencesTest extends SecurePreferencesTest {
final private static String WIN_BUNDLE = "org.eclipse.equinox.security.win32";
@Before
public void setUp() {
org.junit.Assume.assumeTrue(hasBundle(WIN_BUNDLE));
}
/**
* Unique ID of the Windows module.
*/
static private final String WIN_64BIT_MODULE_ID = "org.eclipse.equinox.security.WindowsPasswordProvider64bit"; //$NON-NLS-1$
@Override
protected String getModuleID() {
return WIN_64BIT_MODULE_ID;
}
@Override
protected Map<String, Object> getOptions() {
// Don't specify default password when testing specific password provider
return getOptions(null);
}
static private boolean hasBundle(String symbolicID) {
BundleContext context = SecurityTestsActivator.getDefault().getBundleContext();
Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles) {
String bundleName = bundle.getSymbolicName();
if (!symbolicID.equals(bundleName))
continue;
int bundleState = bundle.getState();
return (bundleState != Bundle.INSTALLED) && (bundleState != Bundle.UNINSTALLED);
}
return false;
}
}