/*******************************************************************************
* Licensed 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.kato.tck.scenario142.javaruntime;
import javax.tools.diagnostics.runtime.java.JavaField;
import javax.tools.diagnostics.runtime.java.JavaObject;
import org.apache.kato.tck.harness.TCKJavaRuntimeTestcase;
import org.apache.kato.tck.scenario142.javaruntime.SetupJavaField_getFloat;
/**
* Test JavaField.getFloat() against various fields and values.
*
*/
public class TestJavaField_getFloat extends TCKJavaRuntimeTestcase {
SetupJavaField_getFloat setup=new SetupJavaField_getFloat();
static JavaObject thisObject = null;
public JavaObject getScenerioReference() {
if (thisObject == null) {
thisObject = super.getScenerioReference();
}
return thisObject;
}
public void testMaxFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField maxFloatField = getJavaField(thisJavaObject, "maxFloat");
float maxFloatValue = maxFloatField.getFloat(thisJavaObject);
assertEquals(setup.maxFloat, maxFloatValue, 0.0);
}
public void testMinFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField minFloatField = getJavaField(thisJavaObject, "minFloat");
float minFloatValue = minFloatField.getFloat(thisJavaObject);
assertEquals(setup.minFloat, minFloatValue, 0.0);
}
public void testStaticMinFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField minFloatField = getJavaField(thisJavaObject, "staticMinFloat");
float minFloatValue = minFloatField.getFloat(null);
assertEquals(SetupJavaField_getFloat.staticMinFloat, minFloatValue, 0.0);
}
public void testZeroFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField zeroFloatField = getJavaField(thisJavaObject, "zeroFloat");
float zeroFloatValue = zeroFloatField.getFloat(thisJavaObject);
assertEquals(setup.zeroFloat, zeroFloatValue, 0.0);
}
public void testNegFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField negFloatField = getJavaField(thisJavaObject, "negFloat");
float negFloatValue = negFloatField.getFloat(thisJavaObject);
assertEquals(setup.negFloat, negFloatValue, 0.0);
}
public void testPosFloatValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField posFloatField = getJavaField(thisJavaObject, "posFloat");
float posFloatValue = posFloatField.getFloat(thisJavaObject);
assertEquals(setup.posFloat, posFloatValue, 0.0);
}
public void testDoubleValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField doubleValueField = getJavaField(thisJavaObject, "doubleValue");
try{
float aDoubleValue = doubleValueField.getFloat(thisJavaObject);
fail("Missing illegal argument exception from JavaField.getFloat(doubleValue)");
} catch (IllegalArgumentException e) {
// expected
}
}
public void testLongValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField longValueField = getJavaField(thisJavaObject, "longValue");
try{
float aLongValue = longValueField.getFloat(thisJavaObject);
} catch (IllegalArgumentException e) {
fail("Unexpected illegal argument exception from JavaField.getFloat(longValue)");
}
}
public void testIntValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField intValueField = getJavaField(thisJavaObject, "intValue");
try{
float aIntValue = intValueField.getFloat(thisJavaObject);
} catch (IllegalArgumentException e) {
fail("Unexpected illegal argument exception from JavaField.getFloat(intValue)");
}
}
public void testByteValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField byteValueField = getJavaField(thisJavaObject, "byteValue");
try{
float aByteValue = byteValueField.getFloat(thisJavaObject);
} catch (IllegalArgumentException e) {
fail("Unexpected illegal argument exception from JavaField.getFloat(byteValue)");
}
}
public void testCharValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField charValueField = getJavaField(thisJavaObject, "charValue");
try{
float aCharValue = charValueField.getFloat(thisJavaObject);
} catch (IllegalArgumentException e) {
fail("Unexpected illegal argument exception from JavaField.getFloat(charValue)");
}
}
public void testShortValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField floatValueField = getJavaField(thisJavaObject, "floatValue");
try{
float aShortValue = floatValueField.getFloat(thisJavaObject);
} catch (IllegalArgumentException e) {
fail("Unexpected illegal argument exception from JavaField.getFloat(floatValue)");
}
}
public void testBooleanValue() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField booleanValueField = getJavaField(thisJavaObject, "booleanValue");
try{
float aBooleanValue = booleanValueField.getFloat(thisJavaObject);
fail("Missing illegal argument exception from JavaField.getFloat(booleanValue)");
} catch (IllegalArgumentException e) {
// expected
}
}
public void testObjectReference() throws Exception {
JavaObject thisJavaObject = getScenerioReference();
JavaField objectReferenceField = getJavaField(thisJavaObject, "objectReference");
try{
float anObjectReference = objectReferenceField.getFloat(thisJavaObject);
fail("Missing illegal argument exception from JavaField.getFloat(objectReference)");
} catch (IllegalArgumentException e) {
// expected
}
}
}