/*
 * TestVpnService.java
 * JUnit 4.x based test
 *
 * Created on May 25, 2007, 4:00 PM
 */

package client;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

import javax.xml.soap.SOAPFault;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.soap.SOAPFaultException;

import ossj.common.ex.MplsVpnServiceKeyImpl;
import ossj.common.ex.MplsVpnServiceValueImpl;
import ossj.common.ex.VpnService;
import ossj.common.ex.VpnServiceService;
/**
 *
 * @author vince
 */
public class TestVpnService {
        
    public TestVpnService() {
    }
    
    @Test public void testVpnService() {
        try {
            
            System.out.println(" Retrieving port from the VpnService");            
            VpnService port = new VpnServiceService().getVpnServicePort();
            
            System.out.println(" Invoking 'createMplsVpnService' operation on the Servant port");
            MplsVpnServiceValueImpl mplsVpn = new MplsVpnServiceValueImpl();
            //set the mandatory attributes
            mplsVpn.setVrfName("myVrfName");
            mplsVpn.setSubGraphId(0);
            mplsVpn.setState("Active");
            mplsVpn.setSubscriberId("mySubscriberId");
            mplsVpn.setMandatory(false);
            mplsVpn.setStartMode(0);
            
            //invoke create method on the WS
            MplsVpnServiceKeyImpl mplsVpnKey = (MplsVpnServiceKeyImpl)port.createMplsVpnServiceByValue(mplsVpn);
            
            System.out.println(" Result, MplsVpnServiceKey returned for the new created:");
            System.out.println("    primaryKey: "+mplsVpnKey.getPrimaryKey());
            System.out.println("    type      : "+mplsVpnKey.getType());
            System.out.println("    VrfName   : "+mplsVpn.getVrfName());
            
            // get the new created vpnservice
            System.out.println(" Invoking 'getMplsVpnService' with "+mplsVpnKey.getPrimaryKey());
            MplsVpnServiceValueImpl mplsValue = (MplsVpnServiceValueImpl)port.getMplsVpnServiceByKey(mplsVpnKey,null);
            System.out.println(" Result, MplsVpnServiceKey returned for the new created:");
            System.out.println("    primaryKey    : "+mplsValue.getMplsVpnServiceKey().getPrimaryKey());
            System.out.println("    SubsbcriverId : "+mplsValue.getSubscriberId());
            System.out.println("    VrfName       : "+mplsValue.getVrfName());
            
            // change some values
            System.out.println(" Invoking 'setMplsVpnServiceByValue'");
            mplsValue.setSubscriberId("mySubscriberId");
            mplsValue.setVrfName("updated VrfName: ["+mplsVpnKey.getPrimaryKey()+"]");
            port.setMplsVpnServiceByValue(mplsValue,false);
            
            // get the new created vpnservice
            System.out.println(" Invoking 'getMplsVpnService' with "+mplsVpnKey.getPrimaryKey());
            mplsValue = (MplsVpnServiceValueImpl)port.getMplsVpnServiceByKey(mplsVpnKey,null);
            System.out.println(" Result, MplsVpnServiceKey returned for the new created:");
            System.out.println("    primaryKey    : "+mplsValue.getMplsVpnServiceKey().getPrimaryKey());
            System.out.println("    SubsbcriverId : "+mplsValue.getSubscriberId());
            System.out.println("    VrfName       : "+mplsValue.getVrfName());
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        
    }
    
    @BeforeClass
    public static void setUpClass() throws Exception {
    }
    
    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() throws Exception {
    }
    
    @After
    public void tearDown() throws Exception {
    }
    
}
