Skip to content

Commit

Permalink
Code cleanup and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rnc committed Mar 18, 2013
1 parent fde190e commit a88570a
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/org/jacorb/orb/iiop/IIOPAddress.java
Expand Up @@ -210,11 +210,11 @@ private void init_host()
unresolvable = true;
try
{
// host = InetAddress.getByName(null); //localhost
// Attempt to fallback to some valid IP address.
host = InetAddress.getLocalHost();
if (logger.isWarnEnabled())
{
logger.warn ("init_host, " + "default to localhost of " + host.toString() );
logger.warn ("init_host, " + "default to " + host.toString() );
}
}
catch (UnknownHostException ex2)
Expand Down
7 changes: 4 additions & 3 deletions src/org/jacorb/poa/AGM.java
Expand Up @@ -4,6 +4,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import org.jacorb.poa.AGM.TGTCWrapper;
import org.omg.PortableGroup.TagGroupTaggedComponent;


Expand Down Expand Up @@ -112,11 +113,11 @@ final byte[][] getMembersFromGroup (TagGroupTaggedComponent tagGroup)
* @param oid
* @return the groups that have this object as a member
*/
final ArrayList getGroupsWithMember (byte[] oid)
final ArrayList<TGTCWrapper> getGroupsWithMember (byte[] oid)
{
ArrayList keyList = new ArrayList ();
ArrayList<TGTCWrapper> keyList = new ArrayList<TGTCWrapper> ();

for (Iterator iterator = groupTable.keySet ().iterator (); iterator.hasNext ();)
for (Iterator<TGTCWrapper> iterator = groupTable.keySet ().iterator (); iterator.hasNext ();)
{
TGTCWrapper t = (TGTCWrapper)iterator.next ();
byte [][]oids = getMembersFromGroup (t.tcgtc);
Expand Down
14 changes: 8 additions & 6 deletions src/org/jacorb/poa/GOA.java
Expand Up @@ -34,11 +34,13 @@
*/
public class GOA extends org.jacorb.poa.POA implements org.omg.PortableGroup.GOA
{
private static final long serialVersionUID = -806217810084253929L;

// Active Group Map
private AGM agm;

// Table for OIDs to port mappings
private Map portTable;
private Map<byte[], MIOPProfile> portTable;

private MIOPListener listener = null;

Expand All @@ -59,15 +61,15 @@ public GOA (ORB orb, String name, org.jacorb.poa.POA parent, POAManager manager,
{
super (orb, name, parent, manager, policies);

Factories f = orb.getTransportManager ().getFactories (TAG_UIPMC.value);
Factories f = orb.getTransportManager ().getFactories (TAG_UIPMC.value);
logger = orb.getConfiguration ().getLogger("jacorb.poa");

if ( f != null)
{
listener = (MIOPListener)f.create_listener ((ProtocolProperties)null, 0, (short)0);

agm = new AGM();
portTable = new HashMap ();
portTable = new HashMap<byte[], MIOPProfile> ();
}
}

Expand Down Expand Up @@ -280,15 +282,15 @@ void clearGroupRegistration (byte[] oid)
{
if (agm != null)
{
ArrayList groupsKeys = agm.getGroupsWithMember (oid);
ArrayList<TGTCWrapper> groupsKeys = agm.getGroupsWithMember (oid);

for (int i = 0; i < groupsKeys.size(); i++)
{
if (agm.removeFromGroup (((TGTCWrapper)groupsKeys.get (i)).tcgtc, oid) == 0)
if (agm.removeFromGroup (groupsKeys.get (i).tcgtc, oid) == 0)
{
// If this member was last in the group remove the group
// from the multicast listener
listener.removeGroupConnection (((MIOPProfile)portTable.get (oid)).getUIPMCProfile ().the_port);
listener.removeGroupConnection (portTable.get (oid).getUIPMCProfile ().the_port);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/listenendpoints/echo_corbaloc/run_client.sh
Expand Up @@ -11,7 +11,7 @@ export JACORB_HOME
PATH=${PATH}
CLASSPATH=${CLASSPATH}
export PATH=${PATH}:${JACORB_HOME}/bin
export CLASSPATH=${CLASSPATH}:${bn}/build/classes
export CLASSPATH=${CLASSPATH}:`pwd`/build/classes
echo "$bn: JACORB_HOME=<${JACORB_HOME}>"
echo "$bn: CLASSPATH=<${CLASSPATH}>"
echo "$bn: PATH=<${PATH}>"
Expand Down
2 changes: 1 addition & 1 deletion test/listenendpoints/echo_corbaloc/run_client_phil.sh
Expand Up @@ -11,7 +11,7 @@ export JACORB_HOME
PATH=${PATH}
CLASSPATH=${CLASSPATH}
export PATH=${PATH}:${JACORB_HOME}/bin
export CLASSPATH=${CLASSPATH}:${bn}/build/classes
export CLASSPATH=${CLASSPATH}:`pwd`/build/classes
echo "$bn: JACORB_HOME=<${JACORB_HOME}>"
echo "$bn: CLASSPATH=<${CLASSPATH}>"
echo "$bn: PATH=<${PATH}>"
Expand Down
4 changes: 2 additions & 2 deletions test/listenendpoints/echo_corbaloc/run_server.sh
@@ -1,4 +1,4 @@
#!/bin/bash -x
#!/bin/bash
bn=${0##*/}

if [[ ! -n $JACORB_HOME ]] ; then
Expand All @@ -9,7 +9,7 @@ fi
PATH=${PATH}
CLASSPATH=${CLASSPATH}
export PATH=${PATH}:${JACORB_HOME}/bin
export CLASSPATH=${CLASSPATH}:${bn}/build/classes
export CLASSPATH=${CLASSPATH}:`pwd`/build/classes
echo "$bn: JACORB_HOME=<${JACORB_HOME}>"
echo "$bn: CLASSPATH=<${CLASSPATH}>"
echo "$bn: PATH=<${PATH}>"
Expand Down
2 changes: 1 addition & 1 deletion test/regression/build.xml
Expand Up @@ -79,8 +79,8 @@

<target name="build-all"
depends="test-init,
compile-test-listenendpoints,
idl,
compile-test-listenendpoints,
compile-src,
compile-rmic,
compile-src-notification,
Expand Down
Expand Up @@ -21,13 +21,10 @@
package org.jacorb.test.bugs.bugjac417;

import java.util.Properties;

import org.easymock.MockControl;
import org.jacorb.config.Configuration;
import org.jacorb.orb.ORB;
import org.jacorb.orb.factory.DefaultServerSocketFactory;
import org.jacorb.orb.factory.SocketFactoryManager;
import org.jacorb.orb.listener.NullSSLSessionListener;
import org.jacorb.orb.listener.NullTCPConnectionListener;
import org.jacorb.test.common.MyNullLogger;
import org.jacorb.test.common.ORBTestCase;
Expand All @@ -50,9 +47,10 @@ protected void patchORBProperties(Properties properties)
protected void doSetUp() throws Exception
{
objectUnderTest = new SocketFactoryManager();
configControl = MockControl.createControl(Configuration.class);
configControl = MockControl.createNiceControl(Configuration.class);
configMock = (Configuration) configControl.getMock();

configControl.expectAndReturn(configMock.getORB(), orb );
configControl.expectAndReturn(configMock.getLogger("jacorb.orb.factory"), new MyNullLogger() );
configControl.expectAndReturn(configMock.getAttributeAsObject(SocketFactoryManager.TCP_LISTENER, NullTCPConnectionListener.class.getName()), new NullTCPConnectionListener());
configControl.expectAndReturn(configMock.getAttributeAsBoolean(SocketFactoryManager.SUPPORT_SSL, false), false);
Expand Down
Expand Up @@ -60,7 +60,7 @@ protected void setUp() throws Exception
orbSetup.setUp();
orb = orbSetup.getORB();

serverSetup = new ServerSetup(this, PingReceiverImpl.class.getName(), props);
serverSetup = new ServerSetup(this, null, PingReceiverImpl.class.getName(), props);
serverSetup.setUp();
server = PingReceiverHelper.narrow(orb.string_to_object(serverSetup.getServerIOR()));
}
Expand Down
Expand Up @@ -12,7 +12,7 @@ public int testBuffer(int size)
{
try
{
BufferManager bm = new BufferManager(JacORBConfiguration.getConfiguration(null, null, false));
BufferManager bm = new BufferManager(JacORBConfiguration.getConfiguration(null, org.omg.CORBA.ORB.init (new String[]{}, null), false));
bm.getBuffer(size);
}
catch (OutOfMemoryError e)
Expand All @@ -38,7 +38,7 @@ public int testExpandedBuffer(int size)
try
{
System.out.print ("JAC774: requesting buffer with size: " + size);
BufferManager bm = new BufferManager(JacORBConfiguration.getConfiguration(null, null, false));
BufferManager bm = new BufferManager(JacORBConfiguration.getConfiguration(null, org.omg.CORBA.ORB.init (new String[]{}, null), false));
byte buffer[] = bm.getExpandedBuffer (size);
System.out.println (" done. Returned size is:" + buffer.length);
return buffer.length;
Expand Down
Expand Up @@ -121,15 +121,12 @@ public ClientServerSetup( Test test,
Properties optionalClientProperties,
Properties optionalServerProperties )
{
this(test, new String[] {testServer},
new String[] {servantName},
optionalClientProperties,
optionalServerProperties);
this(test, testServer, new String[] { servantName}, optionalClientProperties, optionalServerProperties);

}

public ClientServerSetup( Test test,
String[] testServerArgs,
String testServer,
String[] servantArgs,
Properties optionalClientProperties,
Properties optionalServerProperties )
Expand Down Expand Up @@ -187,7 +184,7 @@ public ClientServerSetup( Test test,
optionalServerProperties.putAll(imrProps);
}

serverSetup = new ServerSetup(this, testServerArgs, servantArgs, optionalServerProperties);
serverSetup = new ServerSetup(this, testServer, servantArgs, optionalServerProperties);
clientORBSetup = new ORBSetup(this, optionalClientProperties);

this.servantName = servantArgs[0];
Expand Down
26 changes: 3 additions & 23 deletions test/regression/src/org/jacorb/test/common/ServerSetup.java
Expand Up @@ -89,22 +89,14 @@ public void run()

public ServerSetup(Test test, String testServer, String servantName, Properties optionalProperties)
{
this(test, new String[]{testServer}, new String[]{servantName}, optionalProperties);
this(test, testServer, new String [] { servantName } , optionalProperties);
}

public ServerSetup(Test test, String[] testServerArgs, String[] testServantArgs, Properties optionalProperties)
public ServerSetup(Test test, String testServer, String[] testServantArgs, Properties optionalProperties)
{
super(test);

if (testServerArgs != null && testServerArgs.length != 0)
{
this.testServer = getTestServer(testServerArgs[0]);
}
else
{
this.testServer = getTestServer(null);
}

this.testServer = getTestServer(testServer);
this.servantName = testServantArgs[0];

if (TestUtils.verbose)
Expand All @@ -127,25 +119,13 @@ public ServerSetup(Test test, String[] testServerArgs, String[] testServantArgs,
{
serverArgs.add(testServantArgs[i]);
}

if (testServerArgs != null) {
for (int i = 1; i < testServerArgs.length; i++)
{
serverArgs.add(testServerArgs[i]);
}
}

}

public ServerSetup(Test test, String servantName)
{
this(test, null, servantName, null);
}

public ServerSetup(Test test, String servantName, Properties optionalProps)
{
this(test, null, servantName, optionalProps);
}

/**
* how long should we wait for a testserver to come up?
Expand Down

0 comments on commit a88570a

Please sign in to comment.