forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes keycloak#30616. Added database suppliers.
Signed-off-by: Miquel Simon <[email protected]>
- Loading branch information
Showing
12 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
test-poc/framework/src/main/java/org/keycloak/test/framework/KeycloakTestDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.keycloak.test.framework; | ||
|
||
import org.keycloak.test.framework.database.DatabaseConfig; | ||
import org.keycloak.test.framework.injection.LifeCycle; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.FIELD) | ||
public @interface KeycloakTestDatabase { | ||
|
||
Class<? extends DatabaseConfig> config() default DatabaseConfig.class; | ||
|
||
LifeCycle lifecycle() default LifeCycle.GLOBAL; | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
test-poc/framework/src/main/java/org/keycloak/test/framework/database/DatabaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public interface DatabaseConfig { | ||
|
||
default String vendor() { | ||
return ""; | ||
} | ||
|
||
default String containerImage() { | ||
return ""; | ||
} | ||
|
||
default String urlHost() { | ||
return ""; | ||
} | ||
|
||
default String username() { | ||
return ""; | ||
} | ||
|
||
default String password() { | ||
return ""; | ||
} | ||
|
||
default boolean isExternal() { | ||
return false; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
test-poc/framework/src/main/java/org/keycloak/test/framework/database/DatabaseSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
import org.keycloak.test.framework.KeycloakTestDatabase; | ||
import org.keycloak.test.framework.injection.InstanceWrapper; | ||
import org.keycloak.test.framework.injection.Registry; | ||
import org.keycloak.test.framework.injection.Supplier; | ||
|
||
public abstract class DatabaseSupplier implements Supplier<TestDatabase, KeycloakTestDatabase> { | ||
|
||
protected static TestDatabase testDatabase; | ||
|
||
@Override | ||
public Class<KeycloakTestDatabase> getAnnotationClass() { | ||
return KeycloakTestDatabase.class; | ||
} | ||
|
||
@Override | ||
public Class<TestDatabase> getValueType() { | ||
return TestDatabase.class; | ||
} | ||
|
||
@Override | ||
public InstanceWrapper<TestDatabase, KeycloakTestDatabase> getValue(Registry registry, KeycloakTestDatabase annotation) { | ||
InstanceWrapper<TestDatabase, KeycloakTestDatabase> wrapper = new InstanceWrapper<>(this, annotation); | ||
testDatabase = registry.getDependency(TestDatabase.class, wrapper); | ||
testDatabase.start(); | ||
return wrapper; | ||
} | ||
|
||
@Override | ||
public boolean compatible(InstanceWrapper<TestDatabase, KeycloakTestDatabase> a, InstanceWrapper<TestDatabase, KeycloakTestDatabase> b) { | ||
return true; | ||
} | ||
|
||
public TestDatabase getTestDatabase() { | ||
return testDatabase; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...c/framework/src/main/java/org/keycloak/test/framework/database/DefaultDatabaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class DefaultDatabaseConfig implements DatabaseConfig { | ||
} |
4 changes: 4 additions & 0 deletions
4
...framework/src/main/java/org/keycloak/test/framework/database/DefaultDatabaseSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class DefaultDatabaseSupplier extends DatabaseSupplier { | ||
} |
22 changes: 22 additions & 0 deletions
22
test-poc/framework/src/main/java/org/keycloak/test/framework/database/TestDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class TestDatabase { | ||
|
||
private DatabaseConfig databaseConfig; | ||
|
||
public TestDatabase(DatabaseConfig config) { | ||
databaseConfig = config; | ||
} | ||
|
||
public void start() { | ||
|
||
} | ||
|
||
public void stop() { | ||
|
||
} | ||
|
||
public DatabaseConfig getDatabaseConfig() { | ||
return databaseConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...work/src/main/java/org/keycloak/test/framework/server/DistributionKeycloakTestServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
test-poc/framework/src/main/java/org/keycloak/test/framework/server/KeycloakTestServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
.../framework/src/main/java/org/keycloak/test/framework/server/RemoteKeycloakTestServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters