public void createXmlMessages() throws Exception { Browser.createXmlMessages(); MMS.createXmlMessages(); JavaApp.createXmlMessages(); // IM should be last to generate id_name for all other applications!!! // set flag to avoid duplicationNAP names before calling createXmlMessages() // The method setNAPFlagForIMAndValidate() should be changed for new applications Validator.setNAPFlagForIMAndValidate(); IM.createXmlMessages(); }
public void testSLM() throws Exception { IM im = new IM(); SLM slm = new SLM(); assertEquals(100, slm.prepareRange(1.0)); assertEquals(slm.MAX_RANGE, slm.prepareRange(Double.POSITIVE_INFINITY)); boolean save = slm.binaryMode; slm.binaryMode = true; slm.createPointsBuf(); assertEquals(-1, slm.lastBufPos); for (int range = 0; range <= slm.MAX_RANGE; range++) { slm.lastBufPos = -1; slm.putPointToBuf(range, 0, 0); slm.pointsBuf[2] = (byte) (range % 256); assertEquals(range / 256, toInt(slm.pointsBuf[1])); assertEquals(range % 256, toInt(slm.pointsBuf[2])); int rr = toInt(slm.pointsBuf[1]) * 256 + toInt(slm.pointsBuf[2]); assertEquals(range, rr); } slm.binaryMode = save; slm.lastBufPos = -1; assertEquals(0.0, slm.errorMean); assertEquals(0.0, slm.errorVariance); assertEquals(0.0, slm.zeroPerCircle); assertEquals(false, slm.hundr); im.moving = true; for (int i = 0; i < 10; i++) { im.doStep(); String distance = im.genDistance(); im.sendDistanceToAll(distance); Thread.sleep(10); assertEquals(distance, IM.FormatDistance(slm.distance)); } VolumeMock volume = new VolumeMock("127.0.0.1", slm.slmport); String cmd[][] = { {"H", "REPLIES ON"}, {"X", "*BINARY"}, {"?", "*MDA072"}, {"J", "v3.1d - Oct 12 2007"}, {"C", "*A00000"}, {"I00010", "*D00010"}, {"FE1543", "*F01543"}, {"FT", "*Tenth"}, {"S", "*STARTD"}, {"A", "*Lasron"} }; for (int i = 0; i < cmd.length; i++) { volume.Send(cmd[i][0] + "\n"); // slm.readProcessPacket(); assertEquals(cmd[i][1], volume.Recieve()); } }
public static String validateAndCreateIMs(ArrayList arrIMLines) throws Exception { String err = ""; String line; String[] result_str; int colIndex; // set array with headers if (arrIMLines.size() > 0) { line = (String) arrIMLines.get(0); // get headers line += ",dummy"; // for supporting method split. result_str = line.split(","); IM.colsNum = result_str.length; for (int i = 0; i < result_str.length; i++) { IM.arrIMLineHeaders.add(result_str[i]); } } for (int i = 1; i < arrIMLines.size(); i++) { // start from 1 to skip header line = (String) arrIMLines.get(i); if ((Util.str(line)).length() == 0) { continue; } line += ",dummy"; // for supporting method split. result_str = line.split(","); Value[] result = Util.attStrToArrValue(result_str); // checlk for length if (result.length != IM.colsNum) { err += "IM, line#" + (i + 1) + ": The number of tokens should be " + IM.colsNum + "\n"; continue; } IM im = new IM(); colIndex = IM.arrIMLineHeaders.indexOf("mcc"); if (colIndex == -1) { throw new Exception("The colomn 'mcc' is missing in the IM file"); } im.mcc = result[colIndex]; im.mcc.pos = i + 1; colIndex = IM.arrIMLineHeaders.indexOf("mnc"); if (colIndex == -1) { throw new Exception("The colomn 'mnc' is missing in the IM file"); } im.mnc = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("operator_name"); if (colIndex == -1) { throw new Exception("The colomn 'operator_name' is missing in the IM file"); } im.operator_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("account_type"); if (colIndex == -1) { throw new Exception("The colomn 'account_type' is missing in the IM file"); } im.account_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("country_name"); if (colIndex == -1) { throw new Exception("The colomn 'country_name' is missing in the IM file"); } im.country_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("Brand_instance_name"); if (colIndex == -1) { throw new Exception("The colomn 'Brand_instance_name' is missing in the IM file"); } im.Brand_instance_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("IspProfileName"); if (colIndex == -1) { throw new Exception("The colomn 'IspProfileName' is missing in the IM file"); } im.IspProfileName = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("gprs_access_point_name"); if (colIndex == -1) { throw new Exception("The colomn 'gprs_access_point_name' is missing in the IM file"); } im.gprs_access_point_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ap_requires_auth"); if (colIndex == -1) { throw new Exception("The colomn 'ap_requires_auth' is missing in the IM file"); } im.ap_requires_auth = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_type"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_type' is missing in the IM file"); } im.ppp_auth_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_name"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_name' is missing in the IM file"); } im.ppp_auth_name = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ppp_auth_secret"); if (colIndex == -1) { throw new Exception("The colomn 'ppp_auth_secret' is missing in the IM file"); } im.ppp_auth_secret = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("nap_addr_type"); if (colIndex == -1) { throw new Exception("The colomn 'nap_addr_type' is missing in the IM file"); } im.nap_addr_type = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("bearer"); if (colIndex == -1) { throw new Exception("The colomn 'bearer' is missing in the IM file"); } im.bearer = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerAddr"); if (colIndex == -1) { throw new Exception("The colomn 'ServerAddr' is missing in the IM file"); } im.ServerAddr = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerPort"); if (colIndex == -1) { throw new Exception("The colomn 'ServerPort' is missing in the IM file"); } im.ServerPort = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ClientID"); if (colIndex == -1) { throw new Exception("The colomn 'ClientID' is missing in the IM file"); } im.ClientID = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey1"); if (colIndex == -1) { throw new Exception("The colomn 'PrivateKey1' is missing in the IM file"); } im.PrivateKey1 = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("PrivateKey2"); if (colIndex == -1) { throw new Exception("The colomn 'PrivateKey2' is missing in the IM file"); } im.PrivateKey2 = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerPostURL"); if (colIndex == -1) { throw new Exception("The colomn 'ServerPostURL' is missing in the IM file"); } im.ServerPostURL = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("LoginAutoResetConversation"); if (colIndex == -1) { throw new Exception("The colomn 'LoginAutoResetConversation' is missing in the IM file"); } im.LoginAutoResetConversation = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerCirSupported"); if (colIndex == -1) { throw new Exception("The colomn 'ServerCirSupported' is missing in the IM file"); } im.ServerCirSupported = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerLoginMethod"); if (colIndex == -1) { throw new Exception("The colomn 'ServerLoginMethod' is missing in the IM file"); } im.ServerLoginMethod = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyAddress"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyAddress' is missing in the IM file"); } im.ServerProxyAddress = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyPassword"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyPassword' is missing in the IM file"); } im.ServerProxyPassword = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerProxyUserName"); if (colIndex == -1) { throw new Exception("The colomn 'ServerProxyUserName' is missing in the IM file"); } im.ServerProxyUserName = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerTransportType"); if (colIndex == -1) { throw new Exception("The colomn 'ServerTransportType' is missing in the IM file"); } im.ServerTransportType = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerSMSDestinationAddress"); if (colIndex == -1) { throw new Exception("The colomn 'ServerSMSDestinationAddress' is missing in the IM file"); } im.ServerSMSDestinationAddress = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServSMSCirSup"); if (colIndex == -1) { throw new Exception("The colomn 'ServSMSCirSup' is missing in the IM file"); } im.ServSMSCirSup = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRKeepTim"); if (colIndex == -1) { throw new Exception("The colomn 'SvTCPCIRKeepTim' is missing in the IM file"); } im.SvTCPCIRKeepTim = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("SvTCPCIRSup"); if (colIndex == -1) { throw new Exception("The colomn 'SvTCPCIRSup' is missing in the IM file"); } im.SvTCPCIRSup = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("ServerCloseSocketAfterResponse"); if (colIndex == -1) { throw new Exception( "The colomn 'ServerCloseSocketAfterResponse' is missing in the IM file"); } im.ServerCloseSocketAfterResponse = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("AutoRefreshContactList"); if (colIndex == -1) { throw new Exception("The colomn 'AutoRefreshContactList' is missing in the IM file"); } im.AutoRefreshContactList = result[colIndex]; colIndex = IM.arrIMLineHeaders.indexOf("FrbdUnauthoMsgs"); if (colIndex == -1) { throw new Exception("The colomn 'FrbdUnauthoMsgs' is missing in the IM file"); } im.FrbdUnauthoMsgs = result[colIndex]; // validate all data String lineErr = im.validateData(); if (lineErr.length() > 0) { err += "IM, data not valid, line #" + (i + 1) + ": \n" + lineErr + "\n"; } IM.arrIMFromLines.add(im); } return err; }
public void testLM() throws Exception { IM im = new IM(); assertEquals(9, im.POINTS_PER_SECOND); assertEquals(im.maxDistance, im.position); im.maxDistance = 10.1; im.minDistance = 9.1; im.errorVariance = 0.0; im.errorMean = 0.0; im.position = im.maxDistance; im.speed = 1.0; im.moving = true; assertEquals("00010.10m\n", im.genDistance()); int i = 0; while (true) { im.doStep(); i++; if (im.position <= im.minDistance) break; assertEquals(im.maxDistance - i * im.speed / im.POINTS_PER_SECOND, im.position, 0.00000001); } assertEquals(false, im.moving); assertEquals(im.minDistance, im.position); // --- check maxDistance --- im.position = im.maxDistance - 0.0001; im.speed = -1.0; im.moving = true; im.doStep(); assertEquals(false, im.moving); assertEquals(im.maxDistance, im.position); im.unbind(); im = new IM(); im.unbind(); }