/* p2pproxy Copyright (C) 2007 Jehan Monnier () P2pProxyNetworkTester.java - junit test for a whole p2pproxy network This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.p2pproxy.test; import java.net.InetAddress; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.linphone.p2pproxy.api.P2pProxyInstance; import org.linphone.p2pproxy.test.utils.P2pNetwork; import org.linphone.p2pproxy.test.utils.SipClient; import junit.framework.Assert; import junit.framework.TestCase; public class P2pProxyNetworkingTester extends TestCase { static { PropertyConfigurator.configure("log4j.properties"); } static P2pNetwork mP2pNetwork =null; static List mClientList = new ArrayList(); static List mProxyInstanceList; private final static Logger mLog = Logger.getLogger(P2pProxyNetworkingTester.class); public P2pProxyNetworkingTester() { // TODO Auto-generated constructor stub } public P2pProxyNetworkingTester(String arg0) { super(arg0); // TODO Auto-generated constructor stub } public void testConnectedRdv() { int lConnectedPeers=0; for (P2pProxyInstance lSuperPeer:mP2pNetwork.getSuperPeers()) { lConnectedPeers += lSuperPeer.getNumberOfconnectedPeers(); } Assert.assertEquals("all peer are not connected",mP2pNetwork.getEdgesPeers().size(),lConnectedPeers) ; mLog.info("testConnectedPeers ok"); } /** * test call from all peers * */ public void testBasicCallFromAllPeers() { try { for (int i=0;i(mP2pNetwork.getAllPeers()); for (P2pProxyInstance lP2pProxyInstance:mProxyInstanceList) { SipClient lSipClient = new SipClient(lP2pProxyInstance.getSipClientProvider(),lP2pProxyInstance.getSipClientName(),lP2pProxyInstance.getAdvertisementDiscoveryTimeout()); lSipClient.register(); mClientList.add(lSipClient); } Thread.sleep(10000); } } /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub super.tearDown(); // for (P2pProxyInstance lP2pProxyInstance:mProxyInstanceList) { // SipClient lSipClient = new SipClient(lP2pProxyInstance.getSipClientProvider(),lP2pProxyInstance.getSipClientName()); // lSipClient.unRegister(); // } } }