blob: 96c4e66987dff52524a56d168251ec2351e30394 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.test;
import com.yahoo.jdisc.application.OsgiFramework;
import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import java.util.Collections;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Simon Thoresen Hult
*/
public class NonWorkingOsgiFrameworkTestCase {
@Test
void requireThatFrameworkCanStartAndStop() throws BundleException {
OsgiFramework osgi = new NonWorkingOsgiFramework();
osgi.start();
osgi.stop();
}
@Test
void requireThatFrameworkHasNoBundles() throws BundleException {
OsgiFramework osgi = new NonWorkingOsgiFramework();
assertTrue(osgi.bundles().isEmpty());
}
@Test
void requireThatFrameworkHasNoBundleContext() {
OsgiFramework osgi = new NonWorkingOsgiFramework();
assertNull(osgi.bundleContext());
}
@Test
void requireThatFrameworkThrowsOnInstallBundle() throws BundleException {
OsgiFramework osgi = new NonWorkingOsgiFramework();
try {
osgi.installBundle("file:bundle.jar");
fail();
} catch (UnsupportedOperationException e) {
// expected
}
}
@Test
void requireThatFrameworkThrowsOnStartBundles() throws BundleException {
OsgiFramework osgi = new NonWorkingOsgiFramework();
try {
osgi.startBundles(Collections.<Bundle>emptyList(), false);
fail();
} catch (UnsupportedOperationException e) {
// expected
}
}
@Test
void requireThatFrameworkThrowsOnRefreshPackages() throws BundleException, InterruptedException {
OsgiFramework osgi = new NonWorkingOsgiFramework();
try {
osgi.refreshPackages();
fail();
} catch (UnsupportedOperationException e) {
// expected
}
}
}
|