1 17 package org.apache.servicemix.wsn; 18 19 import java.io.IOException ; 20 import java.io.InputStream ; 21 22 import javax.xml.bind.JAXBContext; 23 import javax.xml.bind.JAXBException; 24 import javax.xml.bind.Unmarshaller; 25 26 import junit.framework.TestCase; 27 28 import org.apache.servicemix.wsn.jaxws.InvalidFilterFault; 29 import org.apache.servicemix.wsn.jaxws.InvalidProducerPropertiesExpressionFault; 30 import org.apache.servicemix.wsn.jaxws.UnacceptableInitialTerminationTimeFault; 31 import org.oasis_open.docs.wsn.b_2.Subscribe; 32 33 public class SubscriptionTest extends TestCase { 34 35 private JAXBContext context; 36 private Unmarshaller unmarshaller; 37 private AbstractSubscription subscription; 38 39 protected void setUp() throws Exception { 40 context = JAXBContext.newInstance(Subscribe.class); 41 unmarshaller = context.createUnmarshaller(); 42 subscription = new DummySubscription("mySubscription"); 43 } 44 45 protected Subscribe getSubscription(String file) throws JAXBException, IOException { 46 InputStream is = getClass().getResourceAsStream(file); 47 Subscribe subscribe = (Subscribe) unmarshaller.unmarshal(is); 48 is.close(); 49 return subscribe; 50 } 51 52 public void testWithNilITT() throws Exception { 53 Subscribe subscribe = getSubscription("subscribe-nil-itt.xml"); 54 subscription.validateSubscription(subscribe); 55 } 56 57 public void testWithAbsoluteITT() throws Exception { 58 Subscribe subscribe = getSubscription("subscribe-abs-itt.xml"); 59 try { 60 subscription.validateSubscription(subscribe); 61 fail("Invalid initial termination time used. Fault was expected."); 62 } catch (UnacceptableInitialTerminationTimeFault e) { 63 } 65 } 66 67 public void testWithEmptyITT() throws Exception { 68 Subscribe subscribe = getSubscription("subscribe-empty-itt.xml"); 69 try { 70 subscription.validateSubscription(subscribe); 71 fail("Invalid initial termination time used. Fault was expected."); 72 } catch (UnacceptableInitialTerminationTimeFault e) { 73 } 75 } 76 77 public void testWithNoITT() throws Exception { 78 Subscribe subscribe = getSubscription("subscribe-no-itt.xml"); 79 subscription.validateSubscription(subscribe); 80 } 81 82 public void testWithUseRaw() throws Exception { 83 Subscribe subscribe = getSubscription("subscribe-raw.xml"); 84 subscription.validateSubscription(subscribe); 85 } 86 87 public void testWithProducerProperties() throws Exception { 88 Subscribe subscribe = getSubscription("subscribe-pp.xml"); 89 try { 90 subscription.validateSubscription(subscribe); 91 fail("ProducerProperties used. Fault was expected."); 92 } catch (InvalidProducerPropertiesExpressionFault e) { 93 } 95 } 96 97 public void testWithNoTopic() throws Exception { 98 Subscribe subscribe = getSubscription("subscribe-no-topic.xml"); 99 try { 100 subscription.validateSubscription(subscribe); 101 fail("ProducerProperties used. Fault was expected."); 102 } catch (InvalidFilterFault e) { 103 } 105 } 106 107 public void testWithEPR() throws Exception { 108 Subscribe subscribe = getSubscription("subscribe-epr.xml"); 109 subscription.validateSubscription(subscribe); 110 } 111 112 } 113 | Popular Tags |