-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34090 from phillip-kruger/dev-ui-testing
Dev UI Testing
- Loading branch information
Showing
21 changed files
with
639 additions
and
65 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
.../io/quarkus/hibernate/orm/devui/DevUIHibernateOrmActiveFalseAndNamedPuActiveTrueTest.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,33 @@ | ||
package io.quarkus.hibernate.orm.devui; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.hibernate.orm.devui.namedpu.MyNamedPuEntity; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class DevUIHibernateOrmActiveFalseAndNamedPuActiveTrueTest extends DevUIHibernateOrmTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar.addAsResource( | ||
new StringAsset("quarkus.datasource.db-kind=h2\n" | ||
+ "quarkus.datasource.jdbc.url=jdbc:h2:mem:test\n" | ||
+ "quarkus.datasource.\"nameddatasource\".db-kind=h2\n" | ||
+ "quarkus.datasource.\"nameddatasource\".jdbc.url=jdbc:h2:mem:test2\n" | ||
// Hibernate ORM is inactive for the default PU | ||
+ "quarkus.hibernate-orm.active=false\n" | ||
+ "quarkus.hibernate-orm.datasource=<default>\n" | ||
+ "quarkus.hibernate-orm.packages=io.quarkus.test.devconsole\n" | ||
// ... but it's (implicitly) active for a named PU | ||
+ "quarkus.hibernate-orm.\"namedpu\".datasource=nameddatasource\n" | ||
+ "quarkus.hibernate-orm.\"namedpu\".packages=io.quarkus.hibernate.orm.devui.namedpu\n"), | ||
"application.properties") | ||
.addClasses(MyEntity.class) | ||
.addClasses(MyNamedPuEntity.class)); | ||
|
||
public DevUIHibernateOrmActiveFalseAndNamedPuActiveTrueTest() { | ||
super("namedpu", "MyNamedPuEntity", "io.quarkus.hibernate.orm.devui.namedpu.MyNamedPuEntity"); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...oyment/src/test/java/io/quarkus/hibernate/orm/devui/DevUIHibernateOrmActiveFalseTest.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,24 @@ | ||
package io.quarkus.hibernate.orm.devui; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class DevUIHibernateOrmActiveFalseTest extends DevUIHibernateOrmTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar.addAsResource( | ||
new StringAsset("quarkus.datasource.db-kind=h2\n" | ||
+ "quarkus.datasource.jdbc.url=jdbc:h2:mem:test\n" | ||
// Hibernate ORM is inactive: the dev console should be empty. | ||
+ "quarkus.hibernate-orm.active=false\n"), | ||
"application.properties") | ||
.addClasses(MyEntity.class)); | ||
|
||
public DevUIHibernateOrmActiveFalseTest() { | ||
super(0, 0); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...m/deployment/src/test/java/io/quarkus/hibernate/orm/devui/DevUIHibernateOrmSmokeTest.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,21 @@ | ||
package io.quarkus.hibernate.orm.devui; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class DevUIHibernateOrmSmokeTest extends DevUIHibernateOrmTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest test = new QuarkusDevModeTest() | ||
.withApplicationRoot((jar) -> jar.addAsResource( | ||
new StringAsset("quarkus.datasource.db-kind=h2\n" | ||
+ "quarkus.datasource.jdbc.url=jdbc:h2:mem:test\n"), | ||
"application.properties") | ||
.addClasses(MyEntity.class)); | ||
|
||
public DevUIHibernateOrmSmokeTest() { | ||
super("<default>", "MyEntity", "io.quarkus.hibernate.orm.devui.MyEntity"); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
...te-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/DevUIHibernateOrmTest.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,105 @@ | ||
package io.quarkus.hibernate.orm.devui; | ||
|
||
import java.util.Iterator; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import io.quarkus.devui.tests.DevUIJsonRPCTest; | ||
|
||
/** | ||
* All tests test the same api call, with different configuration and different expected results | ||
* This abstract class reduce the code in each test | ||
*/ | ||
public abstract class DevUIHibernateOrmTest extends DevUIJsonRPCTest { | ||
|
||
private String expectedPersistenceUnitName = null; | ||
private String expectedTableName = null; | ||
private String expectedClassName = null; | ||
private int expectedNumberOfEntityTypes = 1; | ||
private int expectedNumberOfPersistenceUnits = 1; | ||
|
||
public DevUIHibernateOrmTest(String expectedPersistenceUnitName, String expectedTableName, String expectedClassName) { | ||
super("io.quarkus.quarkus-hibernate-orm"); | ||
this.expectedPersistenceUnitName = expectedPersistenceUnitName; | ||
this.expectedTableName = expectedTableName; | ||
this.expectedClassName = expectedClassName; | ||
} | ||
|
||
public DevUIHibernateOrmTest(int expectedNumberOfEntityTypes, | ||
int expectedNumberOfPersistenceUnits) { | ||
super("io.quarkus.quarkus-hibernate-orm"); | ||
this.expectedNumberOfEntityTypes = expectedNumberOfEntityTypes; | ||
this.expectedNumberOfPersistenceUnits = expectedNumberOfPersistenceUnits; | ||
} | ||
|
||
@Test | ||
public void testGetInfo() throws Exception { | ||
JsonNode getInfoResponse = super.executeJsonRPCMethod("getInfo"); | ||
Assertions.assertNotNull(getInfoResponse); | ||
|
||
JsonNode persistenceUnits = getInfoResponse.get("persistenceUnits"); | ||
Assertions.assertNotNull(persistenceUnits); | ||
Assertions.assertTrue(persistenceUnits.isArray()); | ||
|
||
if (expectedPersistenceUnitName == null) { | ||
Assertions.assertEquals(0, persistenceUnits.size()); | ||
} else { | ||
Assertions.assertEquals(1, persistenceUnits.size()); | ||
Iterator<JsonNode> persistenceUnitsIterator = persistenceUnits.elements(); | ||
while (persistenceUnitsIterator.hasNext()) { | ||
JsonNode defaultPersistenceUnit = persistenceUnitsIterator.next(); | ||
JsonNode name = defaultPersistenceUnit.get("name"); | ||
Assertions.assertEquals(expectedPersistenceUnitName, name.asText()); | ||
|
||
JsonNode managedEntities = defaultPersistenceUnit.get("managedEntities"); | ||
Assertions.assertNotNull(managedEntities); | ||
Assertions.assertTrue(managedEntities.isArray()); | ||
|
||
Iterator<JsonNode> managedEntitiesIterator = managedEntities.elements(); | ||
while (managedEntitiesIterator.hasNext()) { | ||
JsonNode myEntity = managedEntitiesIterator.next(); | ||
Assertions.assertEquals(expectedNumberOfPersistenceUnits, persistenceUnits.size()); | ||
|
||
String tableName = myEntity.get("tableName").asText(); | ||
Assertions.assertEquals(expectedTableName, tableName); | ||
|
||
String className = myEntity.get("className").asText(); | ||
Assertions.assertEquals(expectedClassName, className); | ||
|
||
} | ||
|
||
JsonNode namedQueries = defaultPersistenceUnit.get("namedQueries"); | ||
Assertions.assertNotNull(namedQueries); | ||
Assertions.assertTrue(namedQueries.isArray()); | ||
|
||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testGetNumberOfPersistenceUnits() throws Exception { | ||
JsonNode getNumberOfPersistenceUnitsResponse = super.executeJsonRPCMethod("getNumberOfPersistenceUnits"); | ||
Assertions.assertNotNull(getNumberOfPersistenceUnitsResponse); | ||
Assertions.assertTrue(getNumberOfPersistenceUnitsResponse.isInt()); | ||
Assertions.assertEquals(expectedNumberOfPersistenceUnits, getNumberOfPersistenceUnitsResponse.asInt()); | ||
} | ||
|
||
@Test | ||
public void testGetNumberOfEntityTypes() throws Exception { | ||
JsonNode getNumberOfEntityTypesResponse = super.executeJsonRPCMethod("getNumberOfEntityTypes"); | ||
Assertions.assertNotNull(getNumberOfEntityTypesResponse); | ||
Assertions.assertTrue(getNumberOfEntityTypesResponse.isInt()); | ||
Assertions.assertEquals(expectedNumberOfEntityTypes, getNumberOfEntityTypesResponse.asInt()); | ||
} | ||
|
||
@Test | ||
public void testGetNumberOfNamedQueries() throws Exception { | ||
JsonNode getNumberOfNamedQueriesResponse = super.executeJsonRPCMethod("getNumberOfNamedQueries"); | ||
Assertions.assertNotNull(getNumberOfNamedQueriesResponse); | ||
Assertions.assertTrue(getNumberOfNamedQueriesResponse.isInt()); | ||
Assertions.assertEquals(0, getNumberOfNamedQueriesResponse.asInt()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...sions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/MyEntity.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,16 @@ | ||
package io.quarkus.hibernate.orm.devui; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
@Entity | ||
public class MyEntity { | ||
|
||
@Id | ||
Long id; | ||
|
||
@Column | ||
String field; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devui/namedpu/MyNamedPuEntity.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,14 @@ | ||
package io.quarkus.hibernate.orm.devui.namedpu; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
|
||
@Entity | ||
public class MyNamedPuEntity { | ||
|
||
@Id | ||
Long id; | ||
|
||
String field; | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
extensions/vertx-http/deployment/src/test/java/io/quarkus/devui/BuildMetricsTest.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,33 @@ | ||
package io.quarkus.devui; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import io.quarkus.devui.tests.DevUIJsonRPCTest; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class BuildMetricsTest extends DevUIJsonRPCTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest().withEmptyApplication(); | ||
|
||
public BuildMetricsTest() { | ||
super("devui-build-metrics"); | ||
} | ||
|
||
@Test | ||
public void testGetBuildStepsMetrics() throws Exception { | ||
JsonNode buildStepsMetricsResponse = super.executeJsonRPCMethod("getBuildStepsMetrics"); | ||
Assertions.assertNotNull(buildStepsMetricsResponse); | ||
|
||
int duration = buildStepsMetricsResponse.get("duration").asInt(); | ||
Assertions.assertTrue(duration > 0); | ||
|
||
boolean dependencyGraphsIncluded = buildStepsMetricsResponse.get("dependencyGraphs").isObject(); | ||
Assertions.assertTrue(dependencyGraphsIncluded); | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
extensions/vertx-http/deployment/src/test/java/io/quarkus/devui/ConfigurationTest.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 io.quarkus.devui; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import io.quarkus.devui.tests.DevUIJsonRPCTest; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class ConfigurationTest extends DevUIJsonRPCTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withEmptyApplication(); | ||
|
||
public ConfigurationTest() { | ||
super("devui-configuration"); | ||
} | ||
|
||
@Test | ||
public void testLogstreamHistory() throws Exception { | ||
|
||
JsonNode updatePropertyResponse = super.executeJsonRPCMethod("updateProperty", | ||
Map.of( | ||
"name", "quarkus.application.name", | ||
"value", "changedByTest")); | ||
Assertions.assertTrue(updatePropertyResponse.asBoolean()); | ||
|
||
// Get the properties to make sure it is changed | ||
JsonNode allPropertiesResponse = super.executeJsonRPCMethod("getAllValues"); | ||
String applicationName = allPropertiesResponse.get("quarkus.application.name").asText(); | ||
Assertions.assertEquals("changedByTest", applicationName); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
extensions/vertx-http/deployment/src/test/java/io/quarkus/devui/ExtensionsTest.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 io.quarkus.devui; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import io.quarkus.devui.tests.DevUIBuildTimeDataTest; | ||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class ExtensionsTest extends DevUIBuildTimeDataTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest().withEmptyApplication(); | ||
|
||
public ExtensionsTest() { | ||
super("devui"); | ||
} | ||
|
||
@Test | ||
public void testGetExtensions() throws Exception { | ||
JsonNode extensionsResponse = super.getBuildTimeData("extensions"); | ||
Assertions.assertNotNull(extensionsResponse); | ||
|
||
JsonNode activeExtensions = extensionsResponse.get("active"); | ||
Assertions.assertNotNull(activeExtensions); | ||
Assertions.assertTrue(activeExtensions.isArray()); | ||
|
||
JsonNode inactiveExtensions = extensionsResponse.get("inactive"); | ||
Assertions.assertNotNull(inactiveExtensions); | ||
Assertions.assertTrue(inactiveExtensions.isArray()); | ||
|
||
log.info(extensionsResponse.toPrettyString()); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.