directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r376613 - in /directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test: java/org/apache/directory/server/ntp/ resources/
Date Fri, 10 Feb 2006 10:02:51 GMT
Author: akarasulu
Date: Fri Feb 10 02:02:49 2006
New Revision: 376613

URL: http://svn.apache.org/viewcvs?rev=376613&view=rev
Log:
removed system.outs and using loggerss ... quieted test added log4j.properties

Added:
    directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/resources/log4j.properties
      - copied unchanged from r376608, directory/sandbox/akarasulu/rc1/apacheds/protocol-dns/src/test/resources/log4j.properties
Modified:
    directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
    directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
    directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java

Modified: directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java?rev=376613&r1=376612&r2=376613&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
(original)
+++ directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/AbstractNtpTestCase.java
Fri Feb 10 02:02:49 2006
@@ -14,9 +14,9 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.directory.server.ntp;
 
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
@@ -24,45 +24,61 @@
 import junit.framework.TestCase;
 
 import org.apache.directory.server.ntp.messages.NtpMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public class AbstractNtpTestCase extends TestCase
 {
-	protected static final int MINIMUM_NTP_DATAGRAM_SIZE = 576;
-	
-	protected void print( NtpMessage request )
-	{
-		System.out.println( request.getLeapIndicator() );
-		System.out.println( request.getVersionNumber() );
-		System.out.println( request.getMode() );
-		System.out.println( request.getStratum() );
-		System.out.println( request.getPollInterval() );
-		System.out.println( request.getPrecision() );
-		System.out.println( request.getRootDelay() );
-		System.out.println( request.getRootDispersion() );
-		System.out.println( request.getReferenceIdentifier() );
-		System.out.println( request.getReferenceTimestamp() );
-		System.out.println( request.getOriginateTimestamp() );
-		System.out.println( request.getReceiveTimestamp() );
-		System.out.println( request.getTransmitTimestamp() );
-	}
-
-	protected ByteBuffer getByteBufferFromFile(String file) throws IOException
-	{
-		InputStream is = getClass().getResourceAsStream(file);
-
-		byte[] bytes = new byte[ MINIMUM_NTP_DATAGRAM_SIZE ];
-
-		int offset = 0;
-		int numRead = 0;
-		while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length
- offset)) >= 0)
-		{
-			offset += numRead;
-		}
-
-		is.close();
-		
-		return ByteBuffer.wrap(bytes);
-	}
-}
+    protected static final int MINIMUM_NTP_DATAGRAM_SIZE = 576;
+    protected final Logger log;
+
 
+    public AbstractNtpTestCase()
+    {
+        log = LoggerFactory.getLogger( getClass() );
+    }
+
+
+    public AbstractNtpTestCase(Class subclass)
+    {
+        log = LoggerFactory.getLogger( subclass );
+    }
+
+
+    protected void print( NtpMessage request )
+    {
+        log.debug( String.valueOf( request.getLeapIndicator() ) );
+        log.debug( String.valueOf( request.getVersionNumber() ) );
+        log.debug( String.valueOf( request.getMode() ) );
+        log.debug( String.valueOf( request.getStratum() ) );
+        log.debug( String.valueOf( request.getPollInterval() ) );
+        log.debug( String.valueOf( request.getPrecision() ) );
+        log.debug( String.valueOf( request.getRootDelay() ) );
+        log.debug( String.valueOf( request.getRootDispersion() ) );
+        log.debug( String.valueOf( request.getReferenceIdentifier() ) );
+        log.debug( String.valueOf( request.getReferenceTimestamp() ) );
+        log.debug( String.valueOf( request.getOriginateTimestamp() ) );
+        log.debug( String.valueOf( request.getReceiveTimestamp() ) );
+        log.debug( String.valueOf( request.getTransmitTimestamp() ) );
+    }
+
+
+    protected ByteBuffer getByteBufferFromFile( String file ) throws IOException
+    {
+        InputStream is = getClass().getResourceAsStream( file );
+
+        byte[] bytes = new byte[MINIMUM_NTP_DATAGRAM_SIZE];
+
+        int offset = 0;
+        int numRead = 0;
+        while ( offset < bytes.length && ( numRead = is.read( bytes, offset, bytes.length
- offset ) ) >= 0 )
+        {
+            offset += numRead;
+        }
+
+        is.close();
+
+        return ByteBuffer.wrap( bytes );
+    }
+}

Modified: directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java?rev=376613&r1=376612&r2=376613&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
(original)
+++ directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageDecoderTest.java
Fri Feb 10 02:02:49 2006
@@ -14,37 +14,39 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.directory.server.ntp;
 
-import java.nio.ByteBuffer;
 
+import java.nio.ByteBuffer;
 import org.apache.directory.server.ntp.io.NtpMessageDecoder;
 import org.apache.directory.server.ntp.messages.NtpMessage;
 
 
 public class NtpMessageDecoderTest extends AbstractNtpTestCase
 {
-	private ByteBuffer requestByteBuffer;
-	
-	public void testParseClient() throws Exception
-	{
-		requestByteBuffer = getByteBufferFromFile( "NTP-CLIENT-UDP.pdu" );
-		
-		NtpMessageDecoder decoder = new NtpMessageDecoder();
-		NtpMessage request        = decoder.decode( requestByteBuffer );
-		
-		print( request );
-	}
-	
-	public void testParseServer() throws Exception
-	{
-		requestByteBuffer = getByteBufferFromFile( "NTP-SERVER-UDP.pdu" );
-		
-		NtpMessageDecoder decoder = new NtpMessageDecoder();
-		NtpMessage request        = decoder.decode( requestByteBuffer );
-		
-		print( request );
-	}
-}
+    private ByteBuffer requestByteBuffer;
+
 
+    public NtpMessageDecoderTest()
+    {
+        super( NtpMessageDecoderTest.class );
+    }
+
+
+    public void testParseClient() throws Exception
+    {
+        requestByteBuffer = getByteBufferFromFile( "NTP-CLIENT-UDP.pdu" );
+        NtpMessageDecoder decoder = new NtpMessageDecoder();
+        NtpMessage request = decoder.decode( requestByteBuffer );
+        print( request );
+    }
+
+
+    public void testParseServer() throws Exception
+    {
+        requestByteBuffer = getByteBufferFromFile( "NTP-SERVER-UDP.pdu" );
+        NtpMessageDecoder decoder = new NtpMessageDecoder();
+        NtpMessage request = decoder.decode( requestByteBuffer );
+        print( request );
+    }
+}

Modified: directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java?rev=376613&r1=376612&r2=376613&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
(original)
+++ directory/sandbox/akarasulu/rc1/apacheds/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpMessageEncoderTest.java
Fri Feb 10 02:02:49 2006
@@ -14,9 +14,9 @@
  *   limitations under the License.
  *
  */
-
 package org.apache.directory.server.ntp;
 
+
 import java.nio.ByteBuffer;
 
 import org.apache.directory.server.ntp.io.NtpMessageDecoder;
@@ -32,39 +32,44 @@
 
 public class NtpMessageEncoderTest extends AbstractNtpTestCase
 {
-	public void testEncodeMessage() throws Exception
-	{
-		NtpMessageModifier modifier = new NtpMessageModifier();
-		modifier.setLeapIndicator( LeapIndicatorType.NO_WARNING );
-		modifier.setVersionNumber( 4 );
-		modifier.setMode( ModeType.SERVER );
-		modifier.setStratum( StratumType.PRIMARY_REFERENCE );
-		modifier.setPollInterval( (byte)0x06 ); // 6
-		modifier.setPrecision( (byte)0xFA );    // -6
-		modifier.setRootDelay( 0 );
-		modifier.setRootDispersion( 0 );
-		modifier.setReferenceIdentifier( ReferenceIdentifier.LOCL );
-		
-		NtpTimeStamp now = new NtpTimeStamp();
-		
-		modifier.setReferenceTimestamp( now );
-		modifier.setOriginateTimestamp( now );
-		modifier.setReceiveTimestamp( now );
-		modifier.setTransmitTimestamp( now );
-		
-		NtpMessage message = modifier.getNtpMessage();
-		
-		ByteBuffer replyByteBuffer = ByteBuffer.allocate( 1024 );
-		
-		NtpMessageEncoder encoder = new NtpMessageEncoder();
-		encoder.encode( replyByteBuffer, message );
-		
-		print( message );
-		
-		NtpMessageDecoder decoder = new NtpMessageDecoder();
-		NtpMessage reply = decoder.decode( replyByteBuffer );
-		
-		print( reply );
-	}
-}
+    public NtpMessageEncoderTest()
+    {
+        super( NtpMessageEncoderTest.class );
+    }
+
+
+    public void testEncodeMessage() throws Exception
+    {
+        NtpMessageModifier modifier = new NtpMessageModifier();
+        modifier.setLeapIndicator( LeapIndicatorType.NO_WARNING );
+        modifier.setVersionNumber( 4 );
+        modifier.setMode( ModeType.SERVER );
+        modifier.setStratum( StratumType.PRIMARY_REFERENCE );
+        modifier.setPollInterval( ( byte ) 0x06 ); // 6
+        modifier.setPrecision( ( byte ) 0xFA ); // -6
+        modifier.setRootDelay( 0 );
+        modifier.setRootDispersion( 0 );
+        modifier.setReferenceIdentifier( ReferenceIdentifier.LOCL );
+
+        NtpTimeStamp now = new NtpTimeStamp();
+
+        modifier.setReferenceTimestamp( now );
+        modifier.setOriginateTimestamp( now );
+        modifier.setReceiveTimestamp( now );
+        modifier.setTransmitTimestamp( now );
+
+        NtpMessage message = modifier.getNtpMessage();
+
+        ByteBuffer replyByteBuffer = ByteBuffer.allocate( 1024 );
+
+        NtpMessageEncoder encoder = new NtpMessageEncoder();
+        encoder.encode( replyByteBuffer, message );
 
+        print( message );
+
+        NtpMessageDecoder decoder = new NtpMessageDecoder();
+        NtpMessage reply = decoder.decode( replyByteBuffer );
+
+        print( reply );
+    }
+}



Mime
View raw message