"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dso-l2/src/test/java/com/tc/stats/DSOTest.java" between
terracotta-core-5.7.0.tar.gz and terracotta-core-5.7.1.tar.gz

About: Terracotta - Clustering technology for Java ("Network Attached Memory", "Distributed Cache"). Source code of the server (5.x) core components.

DSOTest.java  (terracotta-core-5.7.0):DSOTest.java  (terracotta-core-5.7.1)
skipping to change at line 28 skipping to change at line 28
*/ */
package com.tc.stats; package com.tc.stats;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.tc.net.protocol.tcm.MessageChannel; import com.tc.net.protocol.tcm.MessageChannel;
import com.tc.object.net.DSOChannelManagerMBean; import com.tc.object.net.DSOChannelManagerMBean;
import com.tc.objectserver.core.api.ServerConfigurationContext; import com.tc.objectserver.core.api.ServerConfigurationContext;
import com.tc.objectserver.core.impl.ServerManagementContext; import com.tc.objectserver.core.impl.ServerManagementContext;
import com.tc.util.PortChooser;
import java.net.ConnectException; import java.net.ConnectException;
import java.net.Socket; import java.net.Socket;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Ignore; import org.junit.Ignore;
import org.terracotta.utilities.test.net.PortManager;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
public class DSOTest { public class DSOTest {
private DSO dso; private DSO dso;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
ServerManagementContext serverManagementContext = mock(ServerManagementConte xt.class); ServerManagementContext serverManagementContext = mock(ServerManagementConte xt.class);
DSOChannelManagerMBean dsoChannelManagerMBean = mock(DSOChannelManagerMBean. class); DSOChannelManagerMBean dsoChannelManagerMBean = mock(DSOChannelManagerMBean. class);
when(dsoChannelManagerMBean.getActiveChannels()).thenReturn(new MessageChann el[0]); when(dsoChannelManagerMBean.getActiveChannels()).thenReturn(new MessageChann el[0]);
when(serverManagementContext.getChannelManager()).thenReturn(dsoChannelManag erMBean); when(serverManagementContext.getChannelManager()).thenReturn(dsoChannelManag erMBean);
dso = new DSO(serverManagementContext, mock(ServerConfigurationContext.class ), mock(MBeanServer.class)); dso = new DSO(serverManagementContext, mock(ServerConfigurationContext.class ), mock(MBeanServer.class));
} }
@Test @Ignore("some enviroments don't like the socket stuff going on here") @Test @Ignore("some enviroments don't like the socket stuff going on here")
public void testJMXRemote() throws Exception { public void testJMXRemote() throws Exception {
PortChooser portChooser = new PortChooser(); try (PortManager.PortRef portRef = PortManager.getInstance().reservePort())
final int jmxRemotePort = portChooser.chooseRandomPort(); {
dso.setJmxRemotePort(String.valueOf(jmxRemotePort)); final int jmxRemotePort = portRef.port();
dso.startJMXRemote(); dso.setJmxRemotePort(String.valueOf(jmxRemotePort));
try { dso.startJMXRemote();
Socket socket = new Socket("localhost", jmxRemotePort); try {
socket.close(); Socket socket = new Socket("localhost", jmxRemotePort);
} catch (ConnectException ce) { socket.close();
fail("couldn't connect to jmx remote at port " + jmxRemotePort); } catch (ConnectException ce) {
fail("couldn't connect to jmx remote at port " + jmxRemotePort);
}
try {
dso.stopJMXRemote();
new Socket("localhost", jmxRemotePort);
fail("jmx remote stop failed");
} catch (ConnectException expected) {}
} }
try {
dso.stopJMXRemote();
new Socket("localhost", jmxRemotePort);
fail("jmx remote stop failed");
} catch (ConnectException expected) {}
} }
} }
 End of changes. 4 change blocks. 
16 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)