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
11 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
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; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
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,37 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
import org.keycloak.test.framework.injection.InstanceWrapper; | ||
import org.keycloak.test.framework.injection.LifeCycle; | ||
import org.keycloak.test.framework.injection.Registry; | ||
import org.keycloak.test.framework.injection.Supplier; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
public abstract class DatabaseSupplier implements Supplier<TestDatabase, Annotation> { | ||
|
||
protected static TestDatabase testDatabase = new TestDatabase(new DevMemDatabaseConfig()); | ||
|
||
@Override | ||
public Class<Annotation> getAnnotationClass() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Class<TestDatabase> getValueType() { | ||
return TestDatabase.class; | ||
} | ||
|
||
@Override | ||
public InstanceWrapper<TestDatabase, Annotation> getValue(Registry registry, Annotation annotation) { | ||
return new InstanceWrapper<>(this, annotation, testDatabase, LifeCycle.GLOBAL); | ||
} | ||
|
||
@Override | ||
public boolean compatible(InstanceWrapper<TestDatabase, Annotation> a, InstanceWrapper<TestDatabase, Annotation> b) { | ||
return true; | ||
} | ||
|
||
public TestDatabase getTestDatabase() { | ||
return testDatabase; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...oc/framework/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseConfig.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 DevMemDatabaseConfig implements DatabaseConfig { | ||
} |
4 changes: 4 additions & 0 deletions
4
.../framework/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.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 DevMemDatabaseSupplier extends DatabaseSupplier { | ||
} |
8 changes: 8 additions & 0 deletions
8
.../framework/src/main/java/org/keycloak/test/framework/database/ExternalDatabaseConfig.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,8 @@ | ||
package org.keycloak.test.framework.database; | ||
|
||
public class ExternalDatabaseConfig implements DatabaseConfig { | ||
@Override | ||
public boolean isExternal() { | ||
return true; | ||
} | ||
} |
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
4 changes: 3 additions & 1 deletion
4
...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