This project has retired. For details please refer to its Attic page.
NotifierTest xref
View Javadoc
1   /*
2   cd .. * Copyright 2001-2009 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *      http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.apache.juddi.subscription.notify;
16  
17  import java.lang.reflect.InvocationTargetException;
18  import java.net.URISyntaxException;
19  
20  import junit.framework.Assert;
21  
22  import org.apache.juddi.api_v3.AccessPointType;
23  import org.apache.juddi.model.BindingTemplate;
24  import org.apache.juddi.model.TmodelInstanceInfo;
25  import org.junit.Test;
26  
27  /**
28   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
29   */
30  public class NotifierTest 
31  {	
32  	@Test
33  	public void testHTTPNotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
34  		BindingTemplate bindingTemplate = new BindingTemplate();
35  		bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier");
36  		bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString());
37  		bindingTemplate.setAccessPointUrl("http://localhost:12345/tcksubscriptionlistener");
38  		TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo();
39  		instanceInfo.setTmodelKey("uddi:uddi.org:transport:http");
40  		bindingTemplate.getTmodelInstanceInfos().add(instanceInfo);
41  		
42  		Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate);
43  		
44  		Assert.assertEquals(HTTPNotifier.class, notifier.getClass());
45  	}
46  	@Test
47  	public void testSMTPNotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
48  		BindingTemplate bindingTemplate = new BindingTemplate();
49  		bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier");
50  		bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString());
51  		bindingTemplate.setAccessPointUrl("mailto:order@islandtrading.example");
52  		TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo();
53  		instanceInfo.setTmodelKey("uddi:uddi.org:transport:smtp");
54  		bindingTemplate.getTmodelInstanceInfos().add(instanceInfo);
55  		
56  		Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate);
57  		
58  		Assert.assertEquals(SMTPNotifier.class, notifier.getClass());
59  	}
60  	
61          
62  	
63  }