1 19 20 package org.apache.excalibur.instrument.test; 21 22 import junit.framework.TestCase; 23 24 import org.apache.excalibur.instrument.ValueInstrument; 25 26 32 public class ValueInstrumentTestCase 33 extends TestCase 34 { 35 38 public ValueInstrumentTestCase( String name ) 39 { 40 super( name ); 41 } 42 43 46 47 50 public void testSimpleValueDisconnected() throws Exception 51 { 52 ValueInstrument vi = new ValueInstrument( "testInstrument" ); 53 54 assertEquals( "A disconnected instrument should not be active.", vi.isActive(), false ); 55 56 vi.setValue( 0 ); 57 vi.setValue( -1 ); 58 vi.setValue( 1 ); 59 } 60 61 public void testSimpleValueConnectedInactive() throws Exception 62 { 63 ValueInstrument vi = new ValueInstrument( "testInstrument" ); 64 TestInstrumentProxy proxy = new TestInstrumentProxy(); 65 vi.setInstrumentProxy( proxy ); 66 67 assertEquals( "The instrument should not be active.", vi.isActive(), false ); 68 69 vi.setValue( 0 ); 70 assertEquals( "The expected value was incorrect.", proxy.getValue(), 0 ); 71 72 vi.setValue( -1 ); 73 assertEquals( "The expected value was incorrect.", proxy.getValue(), -1 ); 74 75 vi.setValue( 1 ); 76 assertEquals( "The expected value was incorrect.", proxy.getValue(), 1 ); 77 } 78 79 public void testLargeValueConnectedInactive() throws Exception 80 { 81 ValueInstrument vi = new ValueInstrument( "testInstrument" ); 82 TestInstrumentProxy proxy = new TestInstrumentProxy(); 83 vi.setInstrumentProxy( proxy ); 84 85 assertEquals( "The instrument should not be active.", vi.isActive(), false ); 86 87 vi.setValue( 1313123123 ); 88 assertEquals( "The expected value was incorrect.", proxy.getValue(), 1313123123 ); 89 90 vi.setValue( -325353253 ); 91 assertEquals( "The expected value was incorrect.", proxy.getValue(), -325353253 ); 92 } 93 94 public void testSimpleValueConnectedActive() throws Exception 95 { 96 ValueInstrument vi = new ValueInstrument( "testInstrument" ); 97 TestInstrumentProxy proxy = new TestInstrumentProxy(); 98 vi.setInstrumentProxy( proxy ); 99 proxy.activate(); 100 101 assertEquals( "The instrument should br active.", vi.isActive(), true ); 102 103 vi.setValue( 0 ); 104 assertEquals( "The expected value was incorrect.", proxy.getValue(), 0 ); 105 106 vi.setValue( -1 ); 107 assertEquals( "The expected value was incorrect.", proxy.getValue(), -1 ); 108 109 vi.setValue( 1 ); 110 assertEquals( "The expected value was incorrect.", proxy.getValue(), 1 ); 111 } 112 113 public void testLargeValueConnectedActive() throws Exception 114 { 115 ValueInstrument vi = new ValueInstrument( "testInstrument" ); 116 TestInstrumentProxy proxy = new TestInstrumentProxy(); 117 vi.setInstrumentProxy( proxy ); 118 proxy.activate(); 119 120 assertEquals( "The instrument should br active.", vi.isActive(), true ); 121 122 vi.setValue( 1313123123 ); 123 assertEquals( "The expected value was incorrect.", proxy.getValue(), 1313123123 ); 124 125 vi.setValue( -325353253 ); 126 assertEquals( "The expected value was incorrect.", proxy.getValue(), -325353253 ); 127 } 128 } 129 130 | Popular Tags |