use of alma.ACSErrTypeCommon.CouldntPerformActionEx in project ACS by ACS-Community.
the class EventComponentTest method doSomeStuff.
/**
* Gets the supplier component to send out events
*/
public void doSomeStuff() throws AcsJCouldntPerformActionEx {
try {
// get the supplier component to create 10 default events.
// The consumer will unsubscribe after having received 5 of these events.
m_supplierComp.sendEvents((short) 10);
// Now give the supplier component a bunch of event structs to publish on the fridge channel
// Note that the event type is different from the above.
int nNestedEvents = 5;
NestedFridgeEvent[] nestedEvents = new NestedFridgeEvent[nNestedEvents];
for (int i = 0; i < nNestedEvents; i++) {
nestedEvents[i] = new NestedFridgeEvent();
nestedEvents[i].status = TemperatureStatus.ATREF;
}
m_supplierComp.sendEventsSpecial(nestedEvents);
} catch (CouldntPerformActionEx e) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(e);
}
}
use of alma.ACSErrTypeCommon.CouldntPerformActionEx in project ACS by ACS-Community.
the class TestLogLevelsCompTest method testGetLevels.
/**
* @throws Exception
*/
public void testGetLevels() throws Exception {
int[] levels;
for (TestLogLevelsComp testlogComp : components) {
try {
levels = testlogComp.getLevels();
} catch (CouldntPerformActionEx ex) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
}
String componentName = testlogComp.name();
// Prepare the log levels via the container's LoggingConfigurable interface
String containerName = containerTestUtil.resolveContainerName(componentName);
LoggingConfigurable containerLogConfig = containerTestUtil.getContainerLoggingIF(containerName);
// @TODO get logger name from the container via a new IDL method, because the logger name
// may not be the same as the container (e.g. for C++ containers).
//String loggerName = containerName;
String loggerName = componentName;
// Get the log level that our test component is subject to
alma.Logging.LoggingConfigurablePackage.LogLevels componentLogLevels = containerLogConfig.get_logLevels(loggerName);
if (componentLogLevels.useDefault) {
m_logger.info("levels from component's getLevels method (hardcoded remote, local, effective): " + levels[0] + ", " + levels[1] + ", " + levels[2] + ", " + levels[3] + ", " + levels[4]);
Assert.assertEquals(levels[3], componentLogLevels.minLogLevel);
Assert.assertEquals(levels[4], componentLogLevels.minLogLevelLocal);
} else {
m_logger.info("levels from component's getLevels method and LoggingConfigurable: " + levels[0] + ", " + levels[1] + ", " + levels[2] + ", " + levels[3] + ", " + levels[4]);
}
// levels[0-4]: hardcoded remote, hardcoded local, AcsLogger, AcsLogHandler, StdoutConsoleHandler
Assert.assertTrue(levels[3] != -1);
Assert.assertTrue(levels[4] != -1);
// The AcsLogger setting should be the minimum of the one for AcsLogHandler and StdoutConsoleHandler
int minLevel = levels[3];
if (levels[3] > levels[4] || levels[3] == -1)
minLevel = levels[4];
Assert.assertEquals(levels[2], minLevel);
}
// // Sleep is to work-around a race condition, whereby the tearDown() can get called "too early"
// // (logging not properly initialised when it is already stopped after running this short method).
// Thread.sleep(3000);
}
use of alma.ACSErrTypeCommon.CouldntPerformActionEx in project ACS by ACS-Community.
the class CounterTest method testNC.
/**
* @throws Exception
*/
public void testNC() throws Exception {
// Start consumers first, then suppliers
for (CounterConsumer consumer : consumers) {
String componentName = consumer.name();
try {
consumer.getBlocks();
m_logger.info(componentName + " now expecting blocks");
} catch (CouldntPerformActionEx ex) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
}
}
int blocksOut = 0;
for (CounterSupplier supplier : suppliers) {
String componentName = supplier.name();
try {
m_logger.info("requesting " + componentName + " to sendBlocks");
blocksOut = supplier.sendBlocks(initVal, lastVal, changeVal, period);
m_logger.info(componentName + " has sent " + blocksOut + " blocks");
} catch (CouldntPerformActionEx ex) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
}
}
// Now wait till all consumers are done ...
int blocksIn = 0;
for (CounterConsumer consumer : consumers) {
String componentName = consumer.name();
try {
blocksIn = consumer.waitTillDone();
m_logger.info(componentName + " has received " + blocksIn + " blocks");
Assert.assertEquals(blocksOut, blocksIn);
} catch (CouldntPerformActionEx ex) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
}
}
// make sure there was enough time to let logs through
//Thread.sleep(1000);
}
use of alma.ACSErrTypeCommon.CouldntPerformActionEx in project ACS by ACS-Community.
the class LocalPubSubTest method testOneSupplierOneSubscriberMixedEvents.
/**
* Publishes >= 200 "MountStatusData" or "LightweightMountStatusData" events on the NC "CONTROL_REALTIME",
* using a single supplier component "JavaSupplier-1" for sequential publishing at a rate of 1 events every 48 ms,
* and a single subscriber component "JavaSubscriber" for counting the events.
* The call to the supplier component is asynchronous, returning while the publisher runs in "indefinite publishing" mode.
* Once the subscriber has received enough data, we terminate the supplier.
*/
@Test
public void testOneSupplierOneSubscriberMixedEvents() throws Throwable {
final int numEvents = 200;
final int eventPeriodMillis = 48;
String[] ncNames = new String[] { CHANNELNAME_CONTROL_REALTIME.value };
// mixed events spec
final NcEventSpec[] ncEventSpecs = new NcEventSpec[] { new NcEventSpec(ncNames[0], new String[] { "MountStatusData", "LightweightMountStatusData" }, // don't care about antenna name here
"") };
// Create, configure and activate dynamic subscriber component.
// It must be running before we publish events, to make sure we don't lose any.
String subscriberContainerName = "localSubscriberContainer1";
String subscriberComponentName = "JavaSubscriber-1";
try {
containerUtil.startContainer(localhostName, ContainerImplLangType.JAVA, subscriberContainerName, null, true);
final CorbaNotifyConsumerOperations subscriberComp = componentAccessUtil.getDynamicSubscriberComponent(subscriberComponentName, subscriberContainerName, ImplLangT.JAVA);
subscriberComp.ncConnect(ncNames);
m_logger.info("Connected subscriber to NC " + ncNames[0]);
Callable<Integer> runSubscriber = new Callable<Integer>() {
@Override
public Integer call() throws Exception {
m_logger.info("About to call subscriber#receiveEvents in a separate thread...");
return subscriberComp.receiveEvents(ncEventSpecs, 0, numEvents);
}
};
Future<Integer> subscriberCallFuture = singThrExec.submit(runSubscriber);
// to "ensure" that the subscriber is ready before we publish events
Thread.sleep(100);
// Create dynamic supplier component
String componentName = "JavaSupplier-1";
CorbaNotifySupplierOperations supplierComp = componentAccessUtil.getDynamicSupplierComponent(componentName, supplierContainerName, ImplLangT.JAVA);
// supplier setup
supplierComp.ncConnect(ncNames);
m_logger.info("Connected supplier to NC " + ncNames[0] + ". Will now send ~" + numEvents + " events, one every " + eventPeriodMillis + " ms.");
// Let publisher component publish events as long as it takes for the subscriber to get enough of them
supplierComp.sendEvents(ncEventSpecs, eventPeriodMillis, -1);
int subscriberReceptionTimeMillis = subscriberCallFuture.get(60, TimeUnit.SECONDS);
m_logger.info("Subscriber component done. It received " + numEvents + " events in " + subscriberReceptionTimeMillis + " ms.");
int expectedReceptionTimeMillis = numEvents * eventPeriodMillis;
assertThat("It should have taken around " + expectedReceptionTimeMillis + " ms to receive the events.", subscriberReceptionTimeMillis, is(both(greaterThan((int) (0.90 * expectedReceptionTimeMillis))).and(lessThan((int) (1.1 * expectedReceptionTimeMillis)))));
// stop supplier (it was in 'infinite' sending mode)
supplierComp.interrupt();
} catch (CouldntPerformActionEx ex) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
} catch (ExecutionException ex) {
Throwable ex2 = ex.getCause();
if (ex2 instanceof CouldntPerformActionEx) {
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx((CouldntPerformActionEx) ex2);
} else {
throw ex2;
}
} finally {
componentAccessUtil.releaseComponent(subscriberComponentName, true);
containerUtil.stopContainer(localhostName, subscriberContainerName);
// for supplier component and container we trust the tearDown method..
}
}
use of alma.ACSErrTypeCommon.CouldntPerformActionEx in project ACS by ACS-Community.
the class ContainerClientPendingReplyTimeoutTest method testOrbLevelTimeout.
/**
* Tests the client-side relative roundtrip ORB timeout for Java containers "frodoContainerWithTimeoutX".
* Here the values in the CDB are supposed to override the general ORB timeout setting from orb.properties.
*/
public void testOrbLevelTimeout() throws Exception {
assertEquals(syslevelOrbTimeoutSecDefined, syslevelOrbTimeoutSec);
//seconds defined in CDB
String container = "frodoContainerWithTimeout";
String component = "DummyCompWrapper_ContainerTimeout";
String container1, component1;
int[] timeout = { 30, 10, 20 };
//Change this value from 1 to 2 or 3 if you want to test other configurations by hand. This is set to 1 to avoid a timeout from NRI tests.
int n = 1;
for (int i = 0; i < n; i++) {
container1 = container + (i + 1);
component1 = component + (i + 1);
DummyComponentWrapper wrapper1 = DummyComponentWrapperHelper.narrow(getContainerServices().getComponent(component1));
int timeout1Sec = (int) jconttestUtil.getContainerLevelOrbTimeout(container1);
assertEquals("Unexpected CDB timeout for container " + container1, timeout[i], timeout1Sec);
//because this test is run several times with different values of syslevelOrbTimeoutSec
if (syslevelOrbTimeoutSec <= timeout1Sec)
break;
assertTrue(container1 + "'s timeout should be shorter than the system-level timeout", syslevelOrbTimeoutSec - timeout1Sec >= 5);
try {
assertFalse(wrapper1.callDummyComponentWithTime((timeout1Sec - 5) * 1000));
//Here we will check that the timeout is similar (+- 5 s) to the timeout defined in CDB
StopWatch sw = new StopWatch(m_logger);
boolean gotTimeoutException = wrapper1.callDummyComponentWithTime((timeout1Sec + 5) * 1000);
int actualTimeout1Sec = (int) sw.getLapTimeMillis() / 1000;
assertTrue("timeout exception expected", gotTimeoutException);
int deviationSec = Math.abs(actualTimeout1Sec - timeout1Sec);
assertTrue("Expected timeout exception was thrown, but after unexpected " + actualTimeout1Sec + " ms.", deviationSec < 2);
} catch (CouldntPerformActionEx ex) {
// so that junit can display the exception trace
throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
}
}
// @TODO: use also DummyCompWrapper_ContainerTimeout2 and DummyCompWrapper_ContainerTimeout3
// to check different container timeout settings.
// This should also check the effect of variations of the system-level timeout, as described in COMP-1063/19/Jun/08 10:03 AM
// (The magic 3 minutes even if system level is at 7 minutes. To be verified usign command line override of
// property jacorb.connection.client.pending_reply_timeout)
//This test will be run 2 times with different values of the system level timeout timeout using the prologue of TAT
}
Aggregations