Skip to content

Commit

Permalink
fix for sequence generator not found test failures.
Browse files Browse the repository at this point in the history
Signed-off-by: Gurunandan Rao <[email protected]>
  • Loading branch information
gurunrao committed Nov 15, 2023
1 parent 16e3795 commit 9c08aa5
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 60 deletions.
29 changes: 26 additions & 3 deletions glassfish-runner/jpa-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<executions>
<execution>
<id>stop-database</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${exec.asadmin}</executable>
<arguments>
<argument>stop-database</argument>
</arguments>
<successCodes>
<successCode>0</successCode>
<successCode>1</successCode>
</successCodes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -255,9 +278,9 @@
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/*enerator*/**/*.*</include>
</includes>
<!--
<test>com.sun.ts.tests.jpa.se.entityManagerFactory.ClientIT#createEntityManagerFactoryNoBeanValidatorTest</test>
-->
<excludes>
<exclude>**/jpa/ee/**/*.*</exclude>
</excludes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,60 +451,6 @@ public void queryTest44() throws Exception {
}
}

/*
* @testName: queryTest55
*
* @assertion_ids: PERSISTENCE:SPEC:358; PERSISTENCE:SPEC:1712;
* PERSISTENCE:SPEC:1713
*
* @test_Strategy: The LIKE expression uses an input parameter for the
* condition. Verify the results were accurately returned.
*
*/
@SetupMethod(name = "setupPhoneData")
@Test
public void queryTest55() throws Exception {
boolean pass = false;
String expectedPKs[];

CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder();

try {
getEntityTransaction().begin();
logger.log(Logger.Level.TRACE, "determine which customers have an area code beginning with 9");
CriteriaQuery<Customer> cquery = cbuilder.createQuery(Customer.class);
Root<Customer> customer = cquery.from(Customer.class);
Join<Address, Phone> p = customer.join(Customer_.home).join(Address_.phones);
cquery.where(cbuilder.like(p.get(Phone_.area), cbuilder.parameter(String.class, "area")));
cquery.select(customer);
TypedQuery<Customer> tquery = getEntityManager().createQuery(cquery);
tquery.setParameter("area", "9%");
tquery.setMaxResults(customerRef.length);
List<Customer> clist = tquery.getResultList();

expectedPKs = new String[3];
expectedPKs[0] = "3";
expectedPKs[1] = "12";
expectedPKs[2] = "16";

if (!checkEntityPK(clist, expectedPKs)) {
logger.log(Logger.Level.ERROR,
"Did not get expected results. Expected 3 references, got: " + clist.size());
} else {
logger.log(Logger.Level.TRACE, "Expected results received");
pass = true;
}
getEntityTransaction().commit();
} catch (Exception e) {
logger.log(Logger.Level.ERROR, "Caught unexpected exception:", e);

}

if (!pass) {
throw new Exception("queryTest55 failed");
}
}

/*
* @testName: queryTest68
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Vector;

import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -134,7 +135,7 @@ public void uni1XMTest1() throws Exception {
}
}

@BeforeEach
@AfterEach
public void cleanup() throws Exception {
logger.log(Logger.Level.TRACE, "cleanup");
removeTestData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public class Client extends PMClientBase {
public Client() {
}

protected void createSequenceGenerator() {
try {
getEntityTransaction().begin();
getEntityManager().createNativeQuery("CREATE SEQUENCE SEQGENERATOR START WITH 10").executeUpdate();
getEntityTransaction().commit();
} catch (Exception e) {
logger.log(Logger.Level.ERROR, "Exception encountered while creating seq:", e);
}

}

@AfterEach
public void cleanup() throws Exception {
logger.log(Logger.Level.TRACE, "Cleanup data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void setup() throws Exception {
supports_sequence = Boolean.parseBoolean(s);
logger.log(Logger.Level.INFO, "db.supports.sequence:" + supports_sequence);
if (supports_sequence) {
createSequenceGenerator();
removeTestData();
createTestData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void setupDataTypes2() throws Exception {
supports_sequence = Boolean.parseBoolean(s);
logger.log(Logger.Level.INFO, "db.supports.sequence:" + supports_sequence);
if (supports_sequence) {
createSequenceGenerator();
removeTestData();
createDataTypes2Data();
}
Expand Down Expand Up @@ -144,6 +145,8 @@ public void generatorTypeSequenceTest() throws Exception {

public void createDataTypes2Data() {
try {


getEntityTransaction().begin();

logger.log(Logger.Level.TRACE, "in createDataTypes2Data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void setupDataTypes3() throws Exception {
supports_sequence = Boolean.parseBoolean(s);
logger.log(Logger.Level.INFO, "db.supports.sequence:" + supports_sequence);
if (supports_sequence) {
createSequenceGenerator();
removeTestData();
createDataTypes3Data();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void setupDataTypes4() throws Exception {
supports_sequence = Boolean.parseBoolean(s);
logger.log(Logger.Level.INFO, "db.supports.sequence:" + supports_sequence);
if (supports_sequence) {
createSequenceGenerator();
removeTestData();
createDataTypes4Data();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public JavaArchive createDeployment() throws Exception {
String pkgNameWithoutSuffix = ClientIT.class.getPackageName();
String pkgName = pkgNameWithoutSuffix + ".";
String[] classes = { pkgName + "A", pkgName + "Employee", pkgName + "Order" };
return createDeploymentJar("jpa_jpa22_se_entityManager.jar", pkgNameWithoutSuffix, (String[]) classes);
return createDeploymentJar("jpa_se_entityManager.jar", pkgNameWithoutSuffix, (String[]) classes);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public JavaArchive createDeployment() throws Exception {
String pkgNameWithoutSuffix = ClientIT.class.getPackageName();
String pkgName = pkgNameWithoutSuffix + ".";
String[] classes = { pkgName + "Member", pkgName + "Member_", pkgName + "Order", pkgName + "Order_" };
return createDeploymentJar("jpa_jpa22_se_entityManagerFactory.jar", pkgNameWithoutSuffix, (String[]) classes);
return createDeploymentJar("jpa_se_entityManagerFactory.jar", pkgNameWithoutSuffix, (String[]) classes);

}

Expand Down

0 comments on commit 9c08aa5

Please sign in to comment.