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