Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreate test for 30444 #30595

Open
wants to merge 1 commit into
base: integration
Choose a base branch
from

Conversation

ajaypaul-ibm
Copy link
Contributor

@ajaypaul-ibm ajaypaul-ibm requested a review from njr-11 January 21, 2025 09:40
@ajaypaul-ibm
Copy link
Contributor Author

ajaypaul-ibm commented Jan 21, 2025

#build (view Open Liberty Personal Build - ✅ completed successfully!)

Note: Target locations of links might be accessible only to IBM employees.

@LibbyBot
Copy link

Code analysis and actions

DO NOT DELETE THIS COMMENT.
  • 3 FAT files were changed, added, or removed.

  • Check that the build did not break the affected FAT suite(s).

  • Please describe in a separate comment how you tested your changes.

Copy link
Contributor

@njr-11 njr-11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these tests. Please continue to work to get them closer to the scenario in #30444 that is failing on Oracle. If, after that, the error still does not reproduce, then work with Kyle on figuring out whether any differences in the Oracle version used might be the cause. If not that, then it will be necessary to look into whether preceding tests might contribute to the issue.

Comment on lines +887 to +917
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 121878,Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352,Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));

// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();

// Execute the JPQL query
List<City> results;
tx.begin();
try {
results = em.createQuery("SELECT c FROM City c", City.class)
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}

// Verify the results
assertEquals(3, results.size());
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Prague")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Brno")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Ostrava")));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, although a slightly different scenario and not properly indented

Suggested change
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 121878,Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352,Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<City> results;
tx.begin();
try {
results = em.createQuery("SELECT c FROM City c", City.class)
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(3, results.size());
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Prague")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Brno")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Ostrava")));
}
deleteAllEntities(City.class);
// Set up test data
City city1 = City.of("Prague", "Bohemia", 121878,Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352,Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<City> results;
tx.begin();
try {
results = em.createQuery("SELECT c FROM City c", City.class)
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(3, results.size());
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Prague")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Brno")));
assertTrue(results.stream().anyMatch(c -> c.getName().equals("Ostrava")));
}

Comment on lines +919 to +951
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectCity_30444() throws Exception {
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));

// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();

// Execute the JPQL query
List<String> results;
tx.begin();
try {
results = em.createQuery("SELECT name FROM City WHERE name = :name ORDER BY population DESC", String.class)
.setParameter("name", "Prague")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}

// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, although a slightly different scenario and not properly indented

Suggested change
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectCity_30444() throws Exception {
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<String> results;
tx.begin();
try {
results = em.createQuery("SELECT name FROM City WHERE name = :name ORDER BY population DESC", String.class)
.setParameter("name", "Prague")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0));
}
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectCity_30444() throws Exception {
deleteAllEntities(City.class);
// Set up test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<String> results;
tx.begin();
try {
results = em.createQuery("SELECT name FROM City WHERE name = :name ORDER BY population DESC", String.class)
.setParameter("name", "Prague")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0));
}

Comment on lines +953 to +988
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectKeys_30444() throws Exception {
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));

// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();

// Execute the JPQL query
List<CityId> results;
tx.begin();
try {
results = em.createQuery(
"SELECT new io.openliberty.jpa.data.tests.models.CityId(c.name, c.stateName) FROM City c WHERE c.stateName = :stateName ORDER BY c.population DESC",
CityId.class)
.setParameter("stateName", "Bohemia")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}

// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0).getName());
assertEquals("Bohemia", results.get(0).getStateName());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, although a slightly different scenario and not properly indented. This one seems to be the closest to the failing Jakarta Data test, although still has some differences such as ordering on the population attribute rather than the name attribute which is a component of the IdClass.

Suggested change
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectKeys_30444() throws Exception {
deleteAllEntities(City.class);
// Setup test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<CityId> results;
tx.begin();
try {
results = em.createQuery(
"SELECT new io.openliberty.jpa.data.tests.models.CityId(c.name, c.stateName) FROM City c WHERE c.stateName = :stateName ORDER BY c.population DESC",
CityId.class)
.setParameter("stateName", "Bohemia")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0).getName());
assertEquals("Bohemia", results.get(0).getStateName());
}
@Test
//Reference issue https://github.com/OpenLiberty/open-liberty/issues/30444
public void testSelectKeys_30444() throws Exception {
deleteAllEntities(City.class);
// Set up test data
City city1 = City.of("Prague", "Bohemia", 1384732, Set.of(55901, 55902, 55903, 55904, 55906));
City city2 = City.of("Brno", "Moravia", 209352, Set.of(14601, 14602, 14603, 14604, 14606));
City city3 = City.of("Ostrava", "Silesia", 23456,Set.of(55906, 55907, 55908, 14604, 55902));
// Persist the cities
tx.begin();
em.persist(city1);
em.persist(city2);
em.persist(city3);
tx.commit();
// Execute the JPQL query
List<CityId> results;
tx.begin();
try {
results = em.createQuery(
"SELECT new io.openliberty.jpa.data.tests.models.CityId(c.name, c.stateName) FROM City c WHERE c.stateName = :stateName ORDER BY c.population DESC",
CityId.class)
.setParameter("stateName", "Bohemia")
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
throw e;
}
// Verify the results
assertEquals(1, results.size());
assertEquals("Prague", results.get(0).getName());
assertEquals("Bohemia", results.get(0).getStateName());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants