Skip to content

Commit

Permalink
Merge pull request #851 from pedroigor/issue-850
Browse files Browse the repository at this point in the history
Allow running embedded server from IDE
  • Loading branch information
pedroigor committed Jun 14, 2024
2 parents 6255163 + 427369a commit cc6e498
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dataset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<version>2.15.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-junit5</artifactId>
<version>${keycloak.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2024 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed 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.keycloak.benchmark.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeoutException;

import org.keycloak.Keycloak;

public class KeycloakServer {

private static final String KEYCLOAK_VERSION = System.getProperty("keycloak.version", "999.0.0-SNAPSHOT");
private static final String PROJECT_VERSION = System.getProperty("project.version", "0.13-SNAPSHOT");

public static void main(String[] rawArgs) {
List<String> args = new ArrayList<>(Arrays.asList(rawArgs));

if (args.isEmpty()) {
args.add("start-dev");
}

new KeycloakServer().start(args.toArray(new String[0]));
}

public void start(String... args) {
Keycloak keycloak = Keycloak.builder()
.setVersion(KEYCLOAK_VERSION)
.addDependency("org.keycloak", "keycloak-benchmark-dataset", PROJECT_VERSION)
.start(args);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
keycloak.stop();
} catch (TimeoutException ignore) {
}
}));
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<keycloak.version>999.0.0-SNAPSHOT</keycloak.version>
<junit5.version>5.9.3</junit5.version>
<junit5.version>5.10.1</junit5.version>
<httpclient.version>4.5.14</httpclient.version>
<maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
Expand Down

0 comments on commit cc6e498

Please sign in to comment.