donaldp 2002/11/11 17:09:40
Modified: info/src/test/org/apache/avalon/framework/tools/infobuilder/test
InfoBuilderTestCase.java
Log:
Unit test writing of ser version of info objects
Revision Changes Path
1.5 +30 -1
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InfoBuilderTestCase.java 4 Oct 2002 07:46:33 -0000 1.4
+++ InfoBuilderTestCase.java 12 Nov 2002 01:09:40 -0000 1.5
@@ -21,7 +21,12 @@
import org.apache.avalon.framework.info.ParameterDescriptor;
import org.apache.avalon.framework.logger.ConsoleLogger;
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 java.util.Properties;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
/**
* Abstract class which TestCases can extend.
@@ -75,6 +80,30 @@
final ServiceInfo expected = createDummyServiceInfo();
InfoAssert.assertEqualInfos( SERVICE1 + " should be equal to constructed
actual",
+ expected,
+ actual );
+ }
+
+ public void testWriteSerService1()
+ throws Exception
+ {
+ final ServiceInfo expected = createDummyServiceInfo();
+ final SerializedInfoWriter writer = new SerializedInfoWriter();
+ 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 String implementationKey =
expected.getServiceDescriptor().getImplementationKey();
+ final FileInputStream inputStream = new FileInputStream(output );
+ final ServiceInfo actual = reader.createServiceInfo( implementationKey,
inputStream );
+ inputStream.close();
+ output.deleteOnExit();
+ output.delete();
+
+ InfoAssert.assertEqualInfos( " Dummy service 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>