diff --git a/api/src/main/java/javax/jdo/annotations/Convert.java b/api/src/main/java/javax/jdo/annotations/Convert.java index 72ae3f98b..5db3b4f72 100644 --- a/api/src/main/java/javax/jdo/annotations/Convert.java +++ b/api/src/main/java/javax/jdo/annotations/Convert.java @@ -37,7 +37,7 @@ * @since 3.2 */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.FIELD}) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) public @interface Convert { /** diff --git a/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java b/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java index 6f05acdb6..c5a833610 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java @@ -25,9 +25,11 @@ import org.apache.jdo.tck.pc.converter.IPCRect; import org.apache.jdo.tck.pc.converter.PCRect; import org.apache.jdo.tck.pc.converter.PCRectAnnotated; +import org.apache.jdo.tck.pc.converter.PCRectPointTypeAnnotated; +import org.apache.jdo.tck.pc.mylib.ConvertiblePoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; -import org.apache.jdo.tck.util.PointToStringConverter; +import org.apache.jdo.tck.util.PointConversionCounter; /** * Title:PointAttributeConverterTest
@@ -59,6 +61,7 @@ public static void main(String[] args) { protected void localSetUp() { addTearDownClass(PCRect.class); addTearDownClass(PCRectAnnotated.class); + addTearDownClass(PCRectPointTypeAnnotated.class); } /** Test method creating and storing a PCRectString instance. */ @@ -78,7 +81,7 @@ public void testModifyPCRectStringInstance() { /** Test method running a PCRectString query with a query parameter of type Point. */ public void testPCRectStringQueryWithPointParam() { - runQueryWithPointParameter(PCRect.class); + runQueryWithPointParameter(PCRect.class, false); } /** Test method running a PCRectString query with a query parameter of type String. */ @@ -103,7 +106,7 @@ public void testModifyPCRectStringAnnotatedInstance() { /** Test method running a PCRectStringAnnotated query with a query parameter of type String. */ public void testPCRectStringAnnotatedQueryWithPointParam() { - runQueryWithPointParameter(PCRectAnnotated.class); + runQueryWithPointParameter(PCRectAnnotated.class, false); } /** Test method running a PCRectStringAnnotated query with a query parameter of type Point. */ @@ -111,6 +114,31 @@ public void testPCRectStringAnnotatedQueryWithStringParam() throws Exception { runQueryWithStringParameter(PCRectAnnotated.class); } + /** Test method creating and storing a PCRectStringAnnotated instance. */ + public void testStorePCRectPointTypeAnnotatedInstance() { + runStoreIPCRectInstance(PCRectPointTypeAnnotated.class); + } + + /** Test method reading a PCRectStringAnnotated instance from the datastore. */ + public void testReadPCRectPointTypeAnnotatedInstance() { + runReadIPCRectInstance(PCRectPointTypeAnnotated.class); + } + + /** Test method modifying a PCRectStringAnnotated instance and storing in the datastore. */ + public void testModifyPCRectPointTypeAnnotatedInstance() { + runModifyIPCRectInstance(PCRectPointTypeAnnotated.class); + } + + /** Test method running a PCRectStringAnnotated query with a query parameter of type String. */ + public void testPCRectPointTypeAnnotatedQueryWithPointParam() { + runQueryWithPointParameter(PCRectPointTypeAnnotated.class, true); + } + + /** Test method running a PCRectStringAnnotated query with a query parameter of type Point. */ + public void testPCRectPointTypeAnnotatedQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCRectPointTypeAnnotated.class); + } + // Helper methods /** @@ -118,17 +146,17 @@ public void testPCRectStringAnnotatedQueryWithStringParam() throws Exception { * convertToDatastore. */ private void runStoreIPCRectInstance(Class pcrectClass) { - int nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - int nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + int nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + int nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); // Create a persistent IPCRect instance and store its oid // AttributeConverter method convertToDatastore is called when persisting instance createIPCRectInstances(pcrectClass, 1); // convertToDatastore should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + assertEquals(2, PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + assertEquals(0, PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); } /** @@ -149,8 +177,8 @@ private void runReadIPCRectInstance(Class pcrectClass) { pm.close(); pm = null; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); pm = getPM(); pm.currentTransaction().begin(); // Read the IPCRect instance from the datastore, this should call convertToAttribute @@ -160,9 +188,9 @@ private void runReadIPCRectInstance(Class pcrectClass) { pm.currentTransaction().commit(); // convertToDatastore should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + assertEquals(0, PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); // convertToAttribute should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + assertEquals(2, PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); // Check the values of the associated Point instances assertEquals(UL_X, ul.getX()); assertEquals(UL_Y, ul.getY() == null ? 0 : ul.getY().intValue()); @@ -189,8 +217,8 @@ private void runModifyIPCRectInstance(Class pcrectClass) pm.close(); pm = null; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); pm = getPM(); tx = pm.currentTransaction(); tx.begin(); @@ -206,9 +234,9 @@ private void runModifyIPCRectInstance(Class pcrectClass) tx.commit(); // convertToDatastore should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + assertEquals(2, PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); // convertToAttribute should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + assertEquals(2, PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); } /** @@ -217,29 +245,34 @@ private void runModifyIPCRectInstance(Class pcrectClass) * * @throws Exception */ - private void runQueryWithPointParameter(Class pcrectClass) { + private void runQueryWithPointParameter( + Class pcrectClass, boolean useConvertiblePoint) { int nrOfDbCalls; int nrOfAttrCalls; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); createIPCRectInstances(pcrectClass, 5); // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + assertEquals(10, PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + assertEquals(0, PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); pm.close(); pm = null; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); pm = getPM(); pm.currentTransaction().begin(); try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == :point")) { - q.setParameters(new Point(UL_X + 1, UL_Y + 1)); + if (useConvertiblePoint) { + q.setParameters(new ConvertiblePoint(UL_X + 1, UL_Y + 1)); + } else { + q.setParameters(new Point(UL_X + 1, UL_Y + 1)); + } // AttributeConverter method convertToAttribute is called when loading instance from the // datastore List res = q.executeList(); @@ -260,9 +293,9 @@ private void runQueryWithPointParameter(Class pcrectClass } // convertToDatastore should be called to handle the query parameter - assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); + assertTrue(PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); // convertToAttribute should be called at least twice - assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + assertTrue(PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); } /** @@ -276,21 +309,21 @@ private void runQueryWithStringParameter(Class pcrectClas int nrOfDbCalls; int nrOfAttrCalls; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); createIPCRectInstances(pcrectClass, 5); // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + assertEquals(10, PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + assertEquals(0, PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); pm.close(); pm = null; - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + nrOfDbCalls = PointConversionCounter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointConversionCounter.getNrOfConvertToAttributeCalls(); pm = getPM(); pm.currentTransaction().begin(); try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == str")) { @@ -314,9 +347,9 @@ private void runQueryWithStringParameter(Class pcrectClas } // convertToDatastore should not be called - assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); + assertTrue(PointConversionCounter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); // convertToAttribute should be called at least twice - assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + assertTrue(PointConversionCounter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); } /** diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectPointTypeAnnotated.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectPointTypeAnnotated.java new file mode 100644 index 000000000..ee0754acd --- /dev/null +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectPointTypeAnnotated.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jdo.tck.pc.converter; + +import java.util.Date; +import javax.jdo.annotations.Column; +import javax.jdo.annotations.PersistenceCapable; +import org.apache.jdo.tck.pc.mylib.ConvertiblePoint; +import org.apache.jdo.tck.pc.mylib.Point; + +/** + * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type Point are + * converted to strings in the datastore. The conversion is declared directly on the type + * ConvertiblePoint. + */ +@PersistenceCapable(table = "PCRectConv") +public class PCRectPointTypeAnnotated implements IPCRect { + private static long counter = new Date().getTime(); + + private static synchronized long newId() { + return counter++; + } + + @Column(name = "ID") + private long id = newId(); + + @Column(name = "UPPER_LEFT") + private ConvertiblePoint upperLeft; + + @Column(name = "LOWER_RIGHT") + private ConvertiblePoint lowerRight; + + public PCRectPointTypeAnnotated() {} + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Point getUpperLeft() { + return new Point(upperLeft.getX(), upperLeft.getY()); + } + + public void setUpperLeft(Point upperLeft) { + this.upperLeft = new ConvertiblePoint(upperLeft.getX(), upperLeft.getY()); + } + + public Point getLowerRight() { + return new Point(lowerRight.getX(), lowerRight.getY()); + } + + public void setLowerRight(Point lowerRight) { + this.lowerRight = new ConvertiblePoint(lowerRight.getX(), lowerRight.getY()); + } + + public String toString() { + String rc = null; + Object obj = this; + try { + rc = + obj.getClass().getName() + + " ul: " + + getUpperLeft().name() + + " lr: " + + getLowerRight().name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCRectPointTypeAnnotated's values"; + } + return rc; + } +} diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/ConvertiblePoint.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/ConvertiblePoint.java new file mode 100644 index 000000000..b26b30ad6 --- /dev/null +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/ConvertiblePoint.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.pc.mylib; + +import javax.jdo.annotations.Convert; +import org.apache.jdo.tck.util.ConvertiblePointToStringConverter; + +/** A simple point class with two fields. The whole class/type is declared convertible. */ +@Convert(value = ConvertiblePointToStringConverter.class) +public class ConvertiblePoint { + public int x; + public Integer y; + + public ConvertiblePoint() {} + + public ConvertiblePoint(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } + + public ConvertiblePoint(int x, Integer y) { + this.x = x; + this.y = y; + } + + public String toString() { + String rc = null; + try { + rc = "ConvertiblePoint(" + name() + ")"; + } catch (NullPointerException ex) { + rc = "NPE getting ConvertiblePoint's values"; + } + return rc; + } + + public int getX() { + System.out.println("Hello from ConvertiblePoint.getX"); + return x; + } + + public Integer getY() { + System.out.println("Hello from ConvertiblePoint.getY"); + return y; + } + + public String name() { + return "x: " + getX() + ", y: " + getY().intValue(); + } +} diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ConvertiblePointToStringConverter.java b/tck/src/main/java/org/apache/jdo/tck/util/ConvertiblePointToStringConverter.java new file mode 100644 index 000000000..07f12091d --- /dev/null +++ b/tck/src/main/java/org/apache/jdo/tck/util/ConvertiblePointToStringConverter.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jdo.tck.util; + +import javax.jdo.AttributeConverter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.jdo.tck.pc.mylib.ConvertiblePoint; + +/** AttributeConverter implementation mapping a Point instance to a string of the form x:y. */ +public class ConvertiblePointToStringConverter extends PointConversionCounter + implements AttributeConverter { + + // Character to separate x and y value of the Point instance. + private static final String SEPARATOR = ":"; + + private final Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** + * Converts the given Point attribute value to its string representation in the datastore. + * + * @param attributeValue the attribute value of type Point to be converted + * @return the string representation of the Point instance + */ + @Override + public String convertToDatastore(ConvertiblePoint attributeValue) { + PointConversionCounter.incNrOfConvertToDatastoreCalls(); + String datastoreValue = null; + if (attributeValue != null) { + datastoreValue = + attributeValue.getX() + + SEPARATOR + + (attributeValue.getY() == null ? Integer.valueOf(0) : attributeValue.getY()); + } + if (logger.isDebugEnabled()) { + logger.debug( + "ConvertiblePointToStringConverter.convertToDatastore " + + "attributeValue=" + + attributeValue + + " datastoreValue=" + + datastoreValue); + } + return datastoreValue; + } + + /** + * Converts the given string datastore value to its representation as a persistent attribute of + * type Point. + * + * @param datastoreValue the string value in the datastore + * @return the attribute value as Point instance + */ + @Override + public ConvertiblePoint convertToAttribute(String datastoreValue) { + PointConversionCounter.incNrOfConvertToAttributeCalls(); + ConvertiblePoint attributeValue = null; + if (datastoreValue != null) { + String[] parts = datastoreValue.split(SEPARATOR); + if (parts.length == 2) { + Integer x = Integer.valueOf(parts[0]); + Integer y = Integer.valueOf(parts[1]); + attributeValue = new ConvertiblePoint(x == null ? 0 : x.intValue(), y); + } + } + if (logger.isDebugEnabled()) { + logger.debug( + "ConvertiblePointToStringConverter.convertToAttribute " + + "datastoreValue=" + + datastoreValue + + " attributeValue=" + + attributeValue); + } + return attributeValue; + } +} diff --git a/tck/src/main/java/org/apache/jdo/tck/util/PointConversionCounter.java b/tck/src/main/java/org/apache/jdo/tck/util/PointConversionCounter.java new file mode 100644 index 000000000..682bbb98c --- /dev/null +++ b/tck/src/main/java/org/apache/jdo/tck/util/PointConversionCounter.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jdo.tck.util; + +public class PointConversionCounter { + + private static int nrOfConvertToDatastoreCalls = 0; + private static int nrOfConvertToAttributeCalls = 0; + + public static void incNrOfConvertToDatastoreCalls() { + nrOfConvertToDatastoreCalls++; + } + + public static void incNrOfConvertToAttributeCalls() { + nrOfConvertToAttributeCalls++; + } + + /** + * Method returning the current number of convertToDatastore method calls. + * + * @return number of convertToDatastore method calls + */ + public static int getNrOfConvertToDatastoreCalls() { + return nrOfConvertToDatastoreCalls; + } + + /** + * Method returning the current number of convertToAttribute method calls. + * + * @return number of convertToAttribute method calls + */ + public static int getNrOfConvertToAttributeCalls() { + return nrOfConvertToAttributeCalls; + } +} diff --git a/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java b/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java index 80524aa2f..38fd0ef83 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java @@ -22,10 +22,8 @@ import org.apache.jdo.tck.pc.mylib.Point; /** AttributeConverter implementation mapping a Point instance to a string of the form x:y. */ -public class PointToStringConverter implements AttributeConverter { - - private static int nrOfConvertToDatastoreCalls = 0; - private static int nrOfConvertToAttributeCalls = 0; +public class PointToStringConverter extends PointConversionCounter + implements AttributeConverter { // Character to separate x and y value of the Point instance. private static final String SEPARATOR = ":"; @@ -40,7 +38,7 @@ public class PointToStringConverter implements AttributeConverter */ @Override public String convertToDatastore(Point attributeValue) { - nrOfConvertToDatastoreCalls++; + incNrOfConvertToDatastoreCalls(); String datastoreValue = null; if (attributeValue != null) { datastoreValue = @@ -68,7 +66,7 @@ public String convertToDatastore(Point attributeValue) { */ @Override public Point convertToAttribute(String datastoreValue) { - nrOfConvertToAttributeCalls++; + incNrOfConvertToAttributeCalls(); Point attributeValue = null; if (datastoreValue != null) { String[] parts = datastoreValue.split(SEPARATOR); @@ -88,22 +86,4 @@ public Point convertToAttribute(String datastoreValue) { } return attributeValue; } - - /** - * Method returning the current number of convertToDatastore method calls. - * - * @return number of convertToDatastore method calls - */ - public static int getNrOfConvertToDatastoreCalls() { - return nrOfConvertToDatastoreCalls; - } - - /** - * Method returning the current number of convertToAttribute method calls. - * - * @return number of convertToAttribute method calls - */ - public static int getNrOfConvertToAttributeCalls() { - return nrOfConvertToAttributeCalls; - } } diff --git a/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/converter/package.jdo b/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/converter/package.jdo index b0a627f35..60baeac61 100644 --- a/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/converter/package.jdo +++ b/tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/converter/package.jdo @@ -33,6 +33,11 @@ + + + + diff --git a/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/converter/package.jdo b/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/converter/package.jdo index 297e742f7..6be2c08c8 100644 --- a/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/converter/package.jdo +++ b/tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/converter/package.jdo @@ -28,6 +28,8 @@ + + diff --git a/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/converter/package-standard.orm b/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/converter/package-standard.orm index 39f3b3c46..d63ca0960 100644 --- a/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/converter/package-standard.orm +++ b/tck/src/main/resources/orm/datastoreidentity/org/apache/jdo/tck/pc/converter/package-standard.orm @@ -32,6 +32,10 @@ + + + +