Bug 552792 - [metatype] Persistence StackOverflowError when reading
Double

Added tests and also fixed support for BigInteger/BigDecimal

Change-Id: I4e81901c91e3d507029a3574718bed5bc9b33eeb
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.core.prefs
index 0a67bc6..1e26766 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.core.prefs
@@ -2,10 +2,13 @@
 org.eclipse.jdt.core.builder.cleanOutputFolder=clean
 org.eclipse.jdt.core.builder.duplicateResourceTask=warning
 org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
 org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
 org.eclipse.jdt.core.circularClasspath=error
 org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=ignore
 org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
diff --git a/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.launching.prefs b/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.launching.prefs
new file mode 100644
index 0000000..f8a131b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.compendium.tests/.settings/org.eclipse.jdt.launching.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning
+org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning
diff --git a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/getMinMax.tb1/OSGI-INF/metatype/metadata.xml b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/getMinMax.tb1/OSGI-INF/metatype/metadata.xml
index f525328..79a668c 100755
--- a/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/getMinMax.tb1/OSGI-INF/metatype/metadata.xml
+++ b/bundles/org.eclipse.equinox.compendium.tests/bundles_src/metatype/getMinMax.tb1/OSGI-INF/metatype/metadata.xml
@@ -12,6 +12,15 @@
 		<AD id="getMinAsNotANumber" type="String" min="foo"/>
 		<AD id="minMaxValidUsingInt" type="Password" min="8" max="16"/>
 		<AD id="minMaxValidUsingString" type="String" min="1" max="1.2"/>
+		<AD id="getDouble" type="Double" min="1" max="100"/>
+		<AD id="getFloat" type="Float" min="1" max="100"/>
+		<AD id="getByte" type="Byte" min="1" max="2"/>
+		<AD id="getShort" type="Short" min="1" max="2"/>
+		<AD id="getCharacter" type="Character" min="a" max="z"/>
+		<AD id="getBoolean" type="Boolean" min="false" max="true"/>
+		<AD id="getLong" type="Long" min="1" max="1000"/>
+		<AD id="getBigInteger" type="BigInteger" min="1" max="1000"/>
+		<AD id="getBigDecimal" type="BigDecimal" min="1.1" max="1000.1"/>
 	</OCD>
 	<Designate pid="org.eclipse.equinox.metatype.tests.getMinMax.tb1">
 		<Object ocdref="getMinMax"/>
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
index e38f02b..34b2852 100644
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AllTests.java
@@ -18,7 +18,7 @@
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
-@SuiteClasses({AttributeTypePasswordTest.class, Bug332161Test.class, Bug340899Test.class, BugTests.class, SameOcdPidFactoryPidTest.class, ExtendableTest.class, Bug358969Test.class, UnresolvedBundleTest.class, GetDefaultValueTest.class, IconTest.class, Bug395196Test.class, NoADTest.class})
+@SuiteClasses({AttributeTypePasswordTest.class, Bug332161Test.class, Bug340899Test.class, BugTests.class, SameOcdPidFactoryPidTest.class, ExtendableTest.class, Bug358969Test.class, UnresolvedBundleTest.class, GetDefaultValueTest.class, IconTest.class, Bug395196Test.class, NoADTest.class, GetMinMaxTest.class})
 public class AllTests {
 	//see @SuiteClasses
 }
diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetMinMaxTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetMinMaxTest.java
index 7d4d9a4..926995f 100755
--- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetMinMaxTest.java
+++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetMinMaxTest.java
@@ -37,31 +37,84 @@
 	@Test
 	public void testGetMax() throws Exception {
 		assertMaxValue("getMax", "0"); //$NON-NLS-1$ //$NON-NLS-2$
+		restartMetatype();
+		assertMaxValue("getMax", "0"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Test
 	public void testGetMaxAsNotANumber() {
 		assertMaxValue("getMaxAsNotANumber", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		restartMetatype();
+		assertMaxValue("getMaxAsNotANumber", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Test
 	public void testGetMaxNull() {
 		assertMaxValue("getMaxNull", null); //$NON-NLS-1$
+		restartMetatype();
+		assertMaxValue("getMaxNull", null); //$NON-NLS-1$
 	}
 
 	@Test
 	public void testGetMin() {
 		assertMinValue("getMin", "5"); //$NON-NLS-1$ //$NON-NLS-2$
+		restartMetatype();
+		assertMinValue("getMin", "5"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Test
 	public void testGetMinAsNotANumber() {
 		assertMinValue("getMinAsNotANumber", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
+		restartMetatype();
+		assertMinValue("getMinAsNotANumber", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Test
 	public void testGetMinNull() {
 		assertMinValue("getMinNull", null); //$NON-NLS-1$
+		restartMetatype();
+		assertMinValue("getMinNull", null); //$NON-NLS-1$
+	}
+
+	@Test
+	public void testGetTheRest() {
+		assertMinValue("getDouble", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getDouble", "100.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getFloat", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getFloat", "100.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getByte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getByte", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getShort", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getShort", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getLong", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getLong", "1000"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getCharacter", "a"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getCharacter", "z"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBoolean", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBoolean", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBigInteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBigInteger", "1000"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBigDecimal", "1.1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBigDecimal", "1000.1"); //$NON-NLS-1$ //$NON-NLS-2$
+		restartMetatype();
+		assertMinValue("getDouble", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getDouble", "100.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getFloat", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getFloat", "100.0"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getByte", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getByte", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getShort", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getShort", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getLong", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getLong", "1000"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getCharacter", "a"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getCharacter", "z"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBoolean", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBoolean", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBigInteger", "1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBigInteger", "1000"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMinValue("getBigDecimal", "1.1"); //$NON-NLS-1$ //$NON-NLS-2$
+		assertMaxValue("getBigDecimal", "1000.1"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
 	@Test
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
index 000e8f2..d70d0e2 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/DataParser.java
@@ -71,6 +71,8 @@
 	private static final String BOOLEAN = "Boolean"; //$NON-NLS-1$
 	private static final String SHORT = "Short"; //$NON-NLS-1$
 	private static final String PASSWORD = "Password"; //$NON-NLS-1$
+	private static final String BIGINTEGER = "BigInteger"; //$NON-NLS-1$
+	private static final String BIGDECIMAL = "BigDecimal"; //$NON-NLS-1$
 
 	protected Bundle _dp_bundle;
 	protected URL _dp_url;
@@ -443,6 +445,7 @@
 			super(handler);
 		}
 
+		@SuppressWarnings("deprecation")
 		public void init(String name, Attributes atts, List<AttributeDefinitionImpl> ads) {
 
 			logger.log(LogTracker.LOG_DEBUG, "Here is AttributeDefinitionHandler():init()"); //$NON-NLS-1$
@@ -492,6 +495,10 @@
 				_dataType = AttributeDefinition.SHORT;
 			} else if (ad_type_val.equalsIgnoreCase(PASSWORD)) {
 				_dataType = AttributeDefinition.PASSWORD;
+			} else if (ad_type_val.equalsIgnoreCase(BIGDECIMAL)) {
+				_dataType = AttributeDefinition.BIGDECIMAL;
+			} else if (ad_type_val.equalsIgnoreCase(BIGINTEGER)) {
+				_dataType = AttributeDefinition.BIGINTEGER;
 			} else {
 				_isParsedDataValid = false;
 				logger.log(LogTracker.LOG_ERROR, NLS.bind(MetaTypeMsg.INVALID_TYPE, new Object[] {ad_type_val, ad_id_val, _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName()}));
diff --git a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
index 356c07a..f91f63d 100644
--- a/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
+++ b/bundles/org.eclipse.equinox.metatype/src/org/eclipse/equinox/metatype/impl/Persistence.java
@@ -105,7 +105,7 @@
 		}
 
 		public double readDouble() throws IOException {
-			return readDouble();
+			return in.readDouble();
 		}
 
 		public float readFloat() throws IOException {