001: package org.drools.base.extractors;
002:
003: import junit.framework.Assert;
004:
005: import org.drools.base.ClassFieldExtractorCache;
006: import org.drools.base.ClassFieldExtractorFactory;
007: import org.drools.base.TestBean;
008: import org.drools.spi.Extractor;
009:
010: public class ByteClassFieldExtractorTest extends
011: BaseClassFieldExtractorsTest {
012: Extractor extractor = ClassFieldExtractorCache.getExtractor(
013: TestBean.class, "byteAttr", getClass().getClassLoader());
014: TestBean bean = new TestBean();
015:
016: protected void setUp() throws Exception {
017: super .setUp();
018: }
019:
020: public void testGetBooleanValue() {
021: try {
022: this .extractor.getBooleanValue(null, this .bean);
023: fail("Should have throw an exception");
024: } catch (final Exception e) {
025: // success
026: }
027: }
028:
029: public void testGetByteValue() {
030: try {
031: Assert.assertEquals(1, this .extractor.getByteValue(null,
032: this .bean));
033: } catch (final Exception e) {
034: fail("Should not throw an exception");
035: }
036: }
037:
038: public void testGetCharValue() {
039: try {
040: this .extractor.getCharValue(null, this .bean);
041: fail("Should have throw an exception");
042: } catch (final Exception e) {
043: // success
044: }
045: }
046:
047: public void testGetDoubleValue() {
048: try {
049: Assert.assertEquals(1.0, this .extractor.getDoubleValue(
050: null, this .bean), 0.01);
051: } catch (final Exception e) {
052: fail("Should not throw an exception");
053: }
054: }
055:
056: public void testGetFloatValue() {
057: try {
058: Assert.assertEquals(1.0f, this .extractor.getFloatValue(
059: null, this .bean), 0.01);
060: } catch (final Exception e) {
061: fail("Should not throw an exception");
062: }
063: }
064:
065: public void testGetIntValue() {
066: try {
067: Assert.assertEquals(1, this .extractor.getIntValue(null,
068: this .bean));
069: } catch (final Exception e) {
070: fail("Should not throw an exception");
071: }
072: }
073:
074: public void testGetLongValue() {
075: try {
076: Assert.assertEquals(1, this .extractor.getLongValue(null,
077: this .bean));
078: } catch (final Exception e) {
079: fail("Should not throw an exception");
080: }
081: }
082:
083: public void testGetShortValue() {
084: try {
085: Assert.assertEquals(1, this .extractor.getShortValue(null,
086: this .bean));
087: } catch (final Exception e) {
088: fail("Should not throw an exception");
089: }
090: }
091:
092: public void testGetValue() {
093: try {
094: Assert.assertEquals(1, ((Number) this .extractor.getValue(
095: null, this .bean)).byteValue());
096: } catch (final Exception e) {
097: fail("Should not throw an exception");
098: }
099: }
100:
101: public void testIsNullValue() {
102: try {
103: Assert.assertFalse(this .extractor.isNullValue(null,
104: this .bean));
105: } catch (final Exception e) {
106: fail("Should not throw an exception");
107: }
108: }
109: }
|