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

Jdo 709 #20

Merged
merged 11 commits into from
May 20, 2021
Merged

Jdo 709 #20

merged 11 commits into from
May 20, 2021

Conversation

mboapache
Copy link
Contributor

This pull request adds a TCK test case for the AttributeConverter interface.

The persistent capable class PCRect2 has two fields of type Point. A point consists of two integer fields (x, y) and is not persistent capable. Each PCRect2 point instance is mapped to a string of the form "x:y". So the DB schema for PCRect2 has two VARCHAR columns. PCRect2 has a static nested class PointToStringConverter that implements the JDO AttributeConverter interface and implements the conversion from a point to a string and vice versa.

The TCK Test class AttributeConverterTest has two test methods.

  1. The first method creates a PCRect2 instance, stores it and reads it back from the datastore. It make sure the point instances in the PCRect2 instance retrieved from the datastore are equal to the original point instances.
  2. The second test method creates some PCRect2 instances and runs a query with a point instance as query parameter.

The AttributeConverter implementation has static fields to count the number of converter calls. This allows the test class to check whether the converter methods are called.

/**
* PCRect2'S ObjectId class.
*/
public static class Oid implements Serializable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this Oid class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need an Oid class for applicationidentity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the Oid class by using SingleFieldIdentity. Now the RCRectString metadata defines javax.jdo.identity.LongIdentity as ObjectId class.

@@ -38,7 +38,7 @@

<!-- TCK Loggers -->

<Logger name="org.apache.jdo.tck" level="info" additivity="false">
<Logger name="org.apache.jdo.tck" level="debug" additivity="false">
Copy link
Contributor

Choose a reason for hiding this comment

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

That looks like an unrelated change. Is it intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! This change is not intended. I will revert this.

*
* @author Michael Bouschen
*/
public class PCRect2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call it PCRectString or something instead of PCRect2? That may be more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

mboapache and others added 4 commits April 29, 2021 19:19
Co-authored-by: Tobias Bouschen <tobias.bouschen@googlemail.com>
… removed code in comment

Co-authored-by: Tobias Bouschen <tobias.bouschen@googlemail.com>
… for PCRectString class

Co-authored-by: Tilmann <tilmannz@apache.org>
Co-authored-by: Tobias Bouschen <tobias.bouschen@googlemail.com>

Co-authored-by: Tobias Bouschen <tobias.bouschen@googlemail.com>
* PersistenceCapable class to test JDO AttributeConverter interface.
* It#s fields of type Point are converted to strins in the datastore.
*
* @author Michael Bouschen
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally, @author tags are not used in Apache code anywhere.

- Added separate test cases for storing and reading a PCRectString instance
- Added new test case for modifying a  PCRectString instance
- AttributeConverter implementation moved from static nested class  of PCRectString to util package
- Added helper method to create PCRectString instances to TCK test class
- Removed author tag
@mboapache mboapache merged commit 7913371 into master May 20, 2021
@mboapache mboapache deleted the JDO-709 branch May 20, 2021 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants