/** * Verifies the equality of the two objects. Performs special handling of certain types. * * @param inExpected expected object. * @param inActual actual object. * @throws IOException if there were errors. */ private static void verifyEquals(Object inExpected, Object inActual) throws IOException { if (inExpected == null) { assertNull(inActual); } else { assertNotNull("Expected:" + inExpected, inActual); // special handling for certain types if (inExpected instanceof ModuleInfo) { ModuleInfo e = (ModuleInfo) inExpected; ModuleInfo a = (ModuleInfo) inActual; ModuleTestBase.assertModuleInfo( a, e.getURN(), e.getState(), e.getInitiatedDataFlows(), e.getParticipatingDataFlows(), e.isAutocreated(), e.isAutostart(), e.isReceiver(), e.isEmitter(), e.isFlowRequester()); assertEquals(e.getLastStartFailure(), a.getLastStartFailure()); assertEquals(e.getLastStopFailure(), a.getLastStopFailure()); assertEquals(e.getLockQueueLength(), a.getLockQueueLength()); assertEquals(e.getReadLockCount(), a.getReadLockCount()); assertEquals(e.isWriteLocked(), a.isWriteLocked()); } else if (inExpected instanceof Map) { // Convert both maps to the same type Map e = new HashMap<Object, Object>((Map<?, ?>) inExpected); Map a = new HashMap<Object, Object>((Map<?, ?>) inActual); assertEquals(e, a); } else if (inExpected instanceof CreateStrategyParameters) { CreateStrategyParameters e = (CreateStrategyParameters) inExpected; CreateStrategyParameters a = (CreateStrategyParameters) inActual; assertEquals(e.getInstanceName(), a.getInstanceName()); assertEquals(e.getStrategyName(), a.getStrategyName()); assertEquals(e.getLanguage(), a.getLanguage()); InputStream ein = e.getStrategySource(); InputStream ain = a.getStrategySource(); assertArrayEquals(IOUtils.toByteArray(ein), IOUtils.toByteArray(ain)); ein.close(); ain.close(); } else { assertEquals(inExpected, inActual); } } }
/** * Verifies the contents of a create strategy parameters instance. * * @param inParms the instance whose contents need to be verified. * @param inInstanceName the instance name * @param inStrategyName the strategy name * @param inLanguage the language * @param inParameters the parameters * @param inRouteToServer if the orders should be routed to the server. */ private static void assertCSP( CreateStrategyParameters inParms, String inInstanceName, String inStrategyName, String inLanguage, String inParameters, boolean inRouteToServer) { assertEquals(inInstanceName, inParms.getInstanceName()); assertEquals(inStrategyName, inParms.getStrategyName()); assertEquals(inLanguage, inParms.getLanguage()); assertEquals(inParameters, inParms.getParameters()); assertEquals(inRouteToServer, inParms.isRouteOrdersToServer()); }