[
https://issues.apache.org/jira/browse/KARAF-5839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16551625#comment-16551625
]
ASF GitHub Bot commented on KARAF-5839:
---------------------------------------
jbonofre closed pull request #575: [KARAF-5839] Expose more method in
KarafTestSupport and provide assertServiceAvailable()
URL: https://github.com/apache/karaf/pull/575
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
index 150ae67e0c..efa65ad05a 100644
--- a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
+++ b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
@@ -290,7 +290,7 @@ public static int getAvailablePort(int min, int max) {
* @param principals The principals (e.g. RolePrincipal objects) to run
the command under
* @return
*/
- protected String executeCommand(final String command, Principal ...
principals) {
+ public String executeCommand(final String command, Principal ...
principals) {
return executeCommand(command, COMMAND_TIMEOUT, false, principals);
}
@@ -304,7 +304,7 @@ protected String executeCommand(final String command,
Principal ... principals)
* @param principals The principals (e.g. RolePrincipal objects) to run
the command under
* @return
*/
- protected String executeCommand(final String command, final Long timeout,
final Boolean silent, final Principal ... principals) {
+ public String executeCommand(final String command, final Long timeout,
final Boolean silent, final Principal ... principals) {
waitForCommandService(command);
String response;
@@ -356,17 +356,28 @@ protected String executeCommand(final String command,
final Long timeout, final
return response;
}
+ public void assertServiceAvailable(Class type) {
+ Assert.assertNotNull(getOsgiService(type));
+ }
+
+ public void assertServiceAvailable(Class type, long timeout) {
+ Assert.assertNotNull(getOsgiService(type, timeout));
+ }
+
+ public void assertServiceAvailable(Class type, String filter, long
timeout) {
+ Assert.assertNotNull(getOsgiService(type, filter, timeout));
+ }
- protected <T> T getOsgiService(Class<T> type, long timeout) {
+ public <T> T getOsgiService(Class<T> type, long timeout) {
return getOsgiService(type, null, timeout);
}
- protected <T> T getOsgiService(Class<T> type) {
+ public <T> T getOsgiService(Class<T> type) {
return getOsgiService(type, null, SERVICE_TIMEOUT);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
- protected <T> T getOsgiService(Class<T> type, String filter, long timeout)
{
+ public <T> T getOsgiService(Class<T> type, String filter, long timeout) {
ServiceTracker tracker = null;
try {
String flt;
@@ -438,7 +449,7 @@ private void waitForCommandService(String command) {
}
}
- protected void waitForService(String filter, long timeout) throws
InvalidSyntaxException, InterruptedException {
+ public void waitForService(String filter, long timeout) throws
InvalidSyntaxException, InterruptedException {
ServiceTracker<Object, Object> st = new
ServiceTracker<>(bundleContext, bundleContext.createFilter(filter), null);
try {
st.open();
@@ -448,7 +459,7 @@ protected void waitForService(String filter, long timeout)
throws InvalidSyntaxE
}
}
- protected Bundle waitBundleState(String symbolicName, int state) {
+ public Bundle waitBundleState(String symbolicName, int state) {
long endTime = System.currentTimeMillis() + BUNDLE_TIMEOUT;
while (System.currentTimeMillis() < endTime) {
Bundle bundle = findBundleByName(symbolicName);
@@ -586,15 +597,15 @@ public void assertContainsNot(String expectedPart, String
actual) {
Assert.assertFalse("Should not contain '" + expectedPart + "' but was
: " + actual, actual.contains(expectedPart));
}
- protected void assertBundleInstalled(String name) {
+ public void assertBundleInstalled(String name) {
Assert.assertNotNull("Bundle " + name + " should be installed",
findBundleByName(name));
}
- protected void assertBundleNotInstalled(String name) {
+ public void assertBundleNotInstalled(String name) {
Assert.assertNull("Bundle " + name + " should not be installed",
findBundleByName(name));
}
- protected Bundle findBundleByName(String symbolicName) {
+ public Bundle findBundleByName(String symbolicName) {
for (Bundle bundle : bundleContext.getBundles()) {
if (bundle.getSymbolicName().equals(symbolicName)) {
return bundle;
@@ -603,16 +614,16 @@ protected Bundle findBundleByName(String symbolicName) {
return null;
}
- protected void installAndAssertFeature(String feature) throws Exception {
+ public void installAndAssertFeature(String feature) throws Exception {
featureService.installFeature(feature, NO_AUTO_REFRESH);
assertFeatureInstalled(feature);
}
- protected void installAssertAndUninstallFeature(String feature, String
version) throws Exception {
+ public void installAssertAndUninstallFeature(String feature, String
version) throws Exception {
installAssertAndUninstallFeatures(feature + "/" + version);
}
- protected void installAssertAndUninstallFeatures(String... feature) throws
Exception {
+ public void installAssertAndUninstallFeatures(String... feature) throws
Exception {
boolean success = false;
Set<String> features = new HashSet<>(Arrays.asList(feature));
try {
@@ -641,7 +652,7 @@ protected void installAssertAndUninstallFeatures(String...
feature) throws Excep
* @param featuresBefore
* @throws Exception
*/
- protected void uninstallNewFeatures(Set<Feature> featuresBefore) throws
Exception {
+ public void uninstallNewFeatures(Set<Feature> featuresBefore) throws
Exception {
Feature[] features = featureService.listInstalledFeatures();
Set<String> uninstall = new HashSet<>();
for (Feature curFeature : features) {
@@ -657,7 +668,7 @@ protected void uninstallNewFeatures(Set<Feature>
featuresBefore) throws Exceptio
}
}
- protected void close(Closeable closeAble) {
+ public void close(Closeable closeAble) {
if (closeAble != null) {
try {
closeAble.close();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add assertServiceAvailable() in KarafTestSupport
> ------------------------------------------------
>
> Key: KARAF-5839
> URL: https://issues.apache.org/jira/browse/KARAF-5839
> Project: Karaf
> Issue Type: Improvement
> Components: karaf-test
> Reporter: Jean-Baptiste Onofré
> Assignee: Jean-Baptiste Onofré
> Priority: Major
> Fix For: 4.2.1
>
>
> In order to simplify the services test in user space itests, it would be
> great to "expose" {{assertServiceAvailable()}} in {{KarafTestSupport}}.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)