Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 37162 invoked from network); 1 Oct 2007 19:30:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Oct 2007 19:30:41 -0000 Received: (qmail 64451 invoked by uid 500); 1 Oct 2007 19:30:31 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 64396 invoked by uid 500); 1 Oct 2007 19:30:31 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 64385 invoked by uid 99); 1 Oct 2007 19:30:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2007 12:30:31 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2007 19:30:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A82071A9832; Mon, 1 Oct 2007 12:29:50 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r581044 - /directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java Date: Mon, 01 Oct 2007 19:29:50 -0000 To: commits@directory.apache.org From: szoerner@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071001192950.A82071A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: szoerner Date: Mon Oct 1 12:29:49 2007 New Revision: 581044 URL: http://svn.apache.org/viewvc?rev=581044&view=rev Log: Way of how to determine the loopback interface changed Modified: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java (contents, props changed) Modified: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java?rev=581044&r1=581043&r2=581044&view=diff ============================================================================== --- directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java (original) +++ directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java Mon Oct 1 12:29:49 2007 @@ -1,108 +1,108 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.directory.server.ntp; - - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import junit.framework.TestCase; - -import org.apache.commons.net.ntp.NTPUDPClient; -import org.apache.commons.net.ntp.TimeInfo; -import org.apache.mina.common.ThreadModel; -import org.apache.mina.filter.executor.ExecutorFilter; -import org.apache.mina.transport.socket.nio.DatagramAcceptor; -import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig; -import org.apache.mina.util.AvailablePortFinder; - - -/** - * A simple integration test which uses the Apache Commons Net client to talk to the NTP server. - * - * @author Apache Directory Project - * @version $Rev: $, $Date: $ - */ -public class NtpServerUdpClientTest extends TestCase -{ - - private NtpServer ntpServer = null; - - protected int port = 0; - - public static final long DELTA_MS = 2500; - - - /** Starts the NTP server on UDP, uses the first port available starting from 1024. - */ - protected void setUp() - { - - NtpConfiguration ntpCfg = new NtpConfiguration(); - - port = AvailablePortFinder.getNextAvailable( 1024 ); - ntpCfg.setIpPort( port ); - - DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig(); - udpConfig.setThreadModel( ThreadModel.MANUAL ); - - ExecutorService logicExecutor = Executors.newFixedThreadPool( 10 ); - - DatagramAcceptor udpAcceptor = new DatagramAcceptor(); - udpAcceptor.getFilterChain().addLast( "executor", new ExecutorFilter( logicExecutor ) ); - - ntpServer = new NtpServer( ntpCfg, udpAcceptor, udpConfig ); - } - - - /** - * Uses the NTPUDPClient class from Apache Commons Net to request the current time. - * - * @throws UnknownHostException - * @throws IOException - */ - public void testReturnTime() throws UnknownHostException, IOException - { - - // Get time via client call - NTPUDPClient client = new NTPUDPClient(); - InetAddress localhost = InetAddress.getByName( "localhost" ); - TimeInfo time = client.getTime( localhost, port ); - long returnTime = time.getReturnTime(); - - long now = System.currentTimeMillis(); - - // Check whether the time returned by the server is close to system time. - long delta = Math.abs( now - returnTime ); - assertTrue( delta < DELTA_MS ); - } - - - /** Shuts the NTP server down - */ - protected void tearDown() - { - ntpServer.destroy(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.directory.server.ntp; + + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import junit.framework.TestCase; + +import org.apache.commons.net.ntp.NTPUDPClient; +import org.apache.commons.net.ntp.TimeInfo; +import org.apache.mina.common.ThreadModel; +import org.apache.mina.filter.executor.ExecutorFilter; +import org.apache.mina.transport.socket.nio.DatagramAcceptor; +import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig; +import org.apache.mina.util.AvailablePortFinder; + + +/** + * A simple integration test which uses the Apache Commons Net client to talk to the NTP server. + * + * @author Apache Directory Project + * @version $Rev$, $Date$ + */ +public class NtpServerUdpClientTest extends TestCase +{ + + private NtpServer ntpServer = null; + + protected int port = 0; + + public static final long DELTA_MS = 2500; + + + /** Starts the NTP server on UDP, uses the first port available starting from 1024. + */ + protected void setUp() + { + + NtpConfiguration ntpCfg = new NtpConfiguration(); + + port = AvailablePortFinder.getNextAvailable( 1024 ); + ntpCfg.setIpPort( port ); + + DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig(); + udpConfig.setThreadModel( ThreadModel.MANUAL ); + + ExecutorService logicExecutor = Executors.newFixedThreadPool( 10 ); + + DatagramAcceptor udpAcceptor = new DatagramAcceptor(); + udpAcceptor.getFilterChain().addLast( "executor", new ExecutorFilter( logicExecutor ) ); + + ntpServer = new NtpServer( ntpCfg, udpAcceptor, udpConfig ); + } + + + /** + * Uses the NTPUDPClient class from Apache Commons Net to request the current time. + * + * @throws UnknownHostException + * @throws IOException + */ + public void testReturnTime() throws UnknownHostException, IOException + { + + // Get time via client call + NTPUDPClient client = new NTPUDPClient(); + InetAddress localhost = InetAddress.getByName( null ); + TimeInfo time = client.getTime( localhost, port ); + long returnTime = time.getReturnTime(); + + long now = System.currentTimeMillis(); + + // Check whether the time returned by the server is close to system time. + long delta = Math.abs( now - returnTime ); + assertTrue( delta < DELTA_MS ); + } + + + /** Shuts the NTP server down + */ + protected void tearDown() + { + ntpServer.destroy(); + } +} Propchange: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpServerUdpClientTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Id Revision