dblevins 2005/09/27 06:58:18
Added: modules/core/src/test/org/openejb/client
ProtocolMetaDataTest.java
Log:
New metadata object to represent protocol magic
Revision Changes Path
1.1
openejb/modules/core/src/test/org/openejb/client/ProtocolMetaDataTest.java
Index: ProtocolMetaDataTest.java
===================================================================
package org.openejb.client;
/**
* @version $Revision: 1.1 $ $Date: 2005/09/27 10:58:18 $
*/
import junit.framework.*;
import org.openejb.client.ProtocolMetaData;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
public class ProtocolMetaDataTest extends TestCase {
private ProtocolMetaData protocol;
protected void setUp() throws Exception {
protocol = new ProtocolMetaData("2.4");
}
public void testGetSpec() throws Exception {
assertEquals("OEJB/2.4", protocol.getSpec());
}
public void testGetId() throws Exception {
assertEquals("OEJB", protocol.getId());
}
public void testGetMajor() throws Exception {
assertEquals(2, protocol.getMajor());
}
public void testGetMinor() throws Exception {
assertEquals(4, protocol.getMinor());
}
public void testGetVersion() throws Exception {
assertEquals("2.4", protocol.getVersion());
}
public void testSerialization() throws Exception {
ProtocolMetaData exptected = new ProtocolMetaData("1.2");
ProtocolMetaData actual = new ProtocolMetaData();
externalize(exptected, actual);
assertEquals(exptected.getId(), actual.getId());
assertEquals(exptected.getMajor(), actual.getMajor());
assertEquals(exptected.getMinor(), actual.getMinor());
assertEquals(exptected.getVersion(), actual.getVersion());
assertEquals(exptected.getSpec(), actual.getSpec());
}
private void externalize(ProtocolMetaData original, ProtocolMetaData
copy) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
original.writeExternal(out);
out.close();
ByteArrayInputStream bais = new
ByteArrayInputStream(baos.toByteArray());
ObjectInputStream in = new ObjectInputStream(bais);
copy.readExternal(in);
}
}