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 BooleanClassFieldExtractorTest extends
011: BaseClassFieldExtractorsTest {
012: Extractor extractor = ClassFieldExtractorCache.getExtractor(
013: TestBean.class, "booleanAttr", 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: Assert.assertTrue(this .extractor.getBooleanValue(null,
023: this .bean));
024: } catch (final Exception e) {
025: fail("Should not throw exception");
026: }
027: }
028:
029: public void testGetByteValue() {
030: try {
031: this .extractor.getByteValue(null, this .bean);
032: fail("Should have throw an exception");
033: } catch (final Exception e) {
034: // success
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: this .extractor.getDoubleValue(null, this .bean);
050: fail("Should have throw an exception");
051: } catch (final Exception e) {
052: // success
053: }
054: }
055:
056: public void testGetFloatValue() {
057: try {
058: this .extractor.getFloatValue(null, this .bean);
059: fail("Should have throw an exception");
060: } catch (final Exception e) {
061: // success
062: }
063: }
064:
065: public void testGetIntValue() {
066: try {
067: this .extractor.getIntValue(null, this .bean);
068: fail("Should have throw an exception");
069: } catch (final Exception e) {
070: // success
071: }
072: }
073:
074: public void testGetLongValue() {
075: try {
076: this .extractor.getLongValue(null, this .bean);
077: fail("Should have throw an exception");
078: } catch (final Exception e) {
079: // success
080: }
081: }
082:
083: public void testGetShortValue() {
084: try {
085: this .extractor.getShortValue(null, this .bean);
086: fail("Should have throw an exception");
087: } catch (final Exception e) {
088: // success
089: }
090: }
091:
092: public void testGetValue() {
093: try {
094: Assert.assertSame(Boolean.TRUE, this .extractor.getValue(
095: null, this .bean));
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: }
|