avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test InfoBuilderTestCase.java
Date Tue, 12 Nov 2002 01:34:56 GMT
donaldp     2002/11/11 17:34:56

  Modified:    info/src/test/org/apache/avalon/framework/tools/infobuilder/test
                        InfoBuilderTestCase.java
  Log:
  unit test the writers
  
  Revision  Changes    Path
  1.6       +62 -3     jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoBuilderTestCase.java
  
  Index: InfoBuilderTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/info/src/test/org/apache/avalon/framework/tools/infobuilder/test/InfoBuilderTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InfoBuilderTestCase.java	12 Nov 2002 01:09:40 -0000	1.5
  +++ InfoBuilderTestCase.java	12 Nov 2002 01:34:56 -0000	1.6
  @@ -23,6 +23,11 @@
   import org.apache.avalon.framework.tools.infobuilder.InfoBuilder;
   import org.apache.avalon.framework.tools.infobuilder.SerializedInfoWriter;
   import org.apache.avalon.framework.tools.infobuilder.SerializedInfoReader;
  +import org.apache.avalon.framework.tools.infobuilder.XMLInfoWriter;
  +import org.apache.avalon.framework.tools.infobuilder.InfoWriter;
  +import org.apache.avalon.framework.tools.infobuilder.InfoReader;
  +import org.apache.avalon.framework.tools.infobuilder.XMLInfoReader;
  +import org.apache.avalon.framework.container.ContainerUtil;
   import java.util.Properties;
   import java.io.File;
   import java.io.FileOutputStream;
  @@ -88,13 +93,15 @@
           throws Exception
       {
           final ServiceInfo expected = createDummyServiceInfo();
  -        final SerializedInfoWriter writer = new SerializedInfoWriter();
  +        final InfoWriter writer = new SerializedInfoWriter();
  +        ContainerUtil.enableLogging( writer, new ConsoleLogger() );
           final File output = File.createTempFile( "info-test", ".ser" );
           final FileOutputStream outputStream = new FileOutputStream( output );
           writer.writeServiceInfo( expected, outputStream );
           outputStream.close();
   
  -        final SerializedInfoReader reader = new SerializedInfoReader();
  +        final InfoReader reader = new SerializedInfoReader();
  +        ContainerUtil.enableLogging( reader, new ConsoleLogger() );
           final String implementationKey = expected.getServiceDescriptor().getImplementationKey();
           final FileInputStream inputStream = new FileInputStream(output );
           final ServiceInfo actual = reader.createServiceInfo( implementationKey, inputStream
);
  @@ -103,6 +110,58 @@
           output.delete();
   
           InfoAssert.assertEqualInfos( " Dummy service written out and read back " +
  +                                     "in again should be equal",
  +                                     expected,
  +                                     actual );
  +    }
  +
  +    public void testWriteSerComponent1()
  +        throws Exception
  +    {
  +        final ComponentInfo expected = createDummyComponentInfo();
  +        final InfoWriter writer = new SerializedInfoWriter();
  +        ContainerUtil.enableLogging( writer, new ConsoleLogger() );
  +        final File output = File.createTempFile( "info-test", ".ser" );
  +        final FileOutputStream outputStream = new FileOutputStream( output );
  +        writer.writeComponentInfo( expected, outputStream );
  +        outputStream.close();
  +
  +        final InfoReader reader = new SerializedInfoReader();
  +        ContainerUtil.enableLogging( reader, new ConsoleLogger() );
  +        final String implementationKey = expected.getComponentDescriptor().getImplementationKey();
  +        final FileInputStream inputStream = new FileInputStream( output );
  +        final ComponentInfo actual = reader.createComponentInfo( implementationKey, inputStream
);
  +        inputStream.close();
  +        output.deleteOnExit();
  +        output.delete();
  +
  +        InfoAssert.assertEqualInfos( " Dummy ComponentInfo written out and read back "
+
  +                                     "in again should be equal",
  +                                     expected,
  +                                     actual );
  +    }
  +
  +    public void testWriteXMLComponent1()
  +        throws Exception
  +    {
  +        final ComponentInfo expected = createDummyComponentInfo();
  +        final InfoWriter writer = new XMLInfoWriter();
  +        ContainerUtil.enableLogging( writer, new ConsoleLogger() );
  +        final File output = File.createTempFile( "info-test", ".xml" );
  +        final FileOutputStream outputStream = new FileOutputStream( output );
  +        writer.writeComponentInfo( expected, outputStream );
  +        outputStream.close();
  +
  +        final InfoReader reader = new XMLInfoReader();
  +        ContainerUtil.enableLogging( reader, new ConsoleLogger() );
  +        final String implementationKey = expected.getComponentDescriptor().getImplementationKey();
  +        final FileInputStream inputStream = new FileInputStream( output );
  +        final ComponentInfo actual = reader.createComponentInfo( implementationKey, inputStream
);
  +        inputStream.close();
  +        //output.deleteOnExit();
  +        //output.delete();
  +
  +        InfoAssert.assertEqualInfos( " Dummy ComponentInfo written out and read back "
+
                                        "in again should be equal",
                                        expected,
                                        actual );
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message