Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAXEXAM-940] Enable run multiple karaf containers at once #1074

Open
wants to merge 1 commit into
base: v4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.ExportException;
import java.rmi.server.UnicastRemoteObject;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -229,7 +230,7 @@ private int openRegistryOnFreePort(String host, int minPort, int maxPort) throws
LOGGER.info("Created RMI registry server on {}:{}", host, port);
return port;
} catch (RemoteException ex) {
if (ex.detail instanceof BindException) {
if (ex instanceof ExportException || ex.detail instanceof BindException) {
LOGGER.trace("Tried to open RMI registry on {}: {} but failed.", host, port, ex);
if (port >= maxPort) {
throw ex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.ops4j.pax.exam.karaf.container;

import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;

import java.io.File;

import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;

@ExamReactorStrategy(PerClass.class)
public class Karaf4MultipleTestContainersITest extends Karaf4TestContainerITest {

private final MavenArtifactUrlReference KARAF_URL = maven("org.apache.karaf", "apache-karaf").type("zip");

@Configuration
public Option[] config() {
String karafVersion = karafVersion();
return new Option[] {
karafDistributionConfiguration()
.frameworkUrl(KARAF_URL.version(karafVersion))
.karafVersion(karafVersion)
.useDeployFolder(false)
.unpackDirectory(new File("target/paxexam/unpack/")),
karafDistributionConfiguration()
.frameworkUrl(KARAF_URL.version(karafVersion))
.karafVersion(karafVersion)
.useDeployFolder(false)
.unpackDirectory(new File("target/paxexam/unpack/second/")),
configureConsole().startLocalConsole().ignoreRemoteShell(),
logLevel(LogLevelOption.LogLevel.INFO)
};
}
}