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