Search in sources :

Example 6 with IFileManager

use of com.att.aro.core.fileio.IFileManager in project VideoOptimzer by attdevsupport.

the class AROToolMenu method openPcapAnalysis.

private void openPcapAnalysis() {
    // Open PCAP analysis tool
    AROTraceData traceData = ((MainFrame) parent).getController().getTheModel();
    IFileManager fileManager = ContextAware.getAROConfigContext().getBean(IFileManager.class);
    File dir = fileManager.createFile(traceData.getAnalyzerResult().getTraceresult().getTraceDirectory());
    File[] trafficFiles;
    if (fileManager.isFile(dir.getAbsolutePath())) {
        trafficFiles = new File[] { new File(dir.getAbsolutePath()) };
    } else {
        trafficFiles = getTrafficTextFiles(dir);
    }
    if (trafficFiles != null && trafficFiles.length > 0) {
        try {
            for (File trafficFile : trafficFiles) {
                if (trafficFile.getName().equals(TraceDataConst.FileName.PCAP_FILE)) {
                    Desktop.getDesktop().open(trafficFile);
                    break;
                }
            }
        } catch (NullPointerException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IllegalArgumentException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcap"));
        } catch (IOException e) {
            MessageDialogFactory.showMessageDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("menu.tools.error.noPcapApp"));
        }
    }
}
Also used : IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) File(java.io.File) MainFrame(com.att.aro.ui.view.MainFrame) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 7 with IFileManager

use of com.att.aro.core.fileio.IFileManager in project VideoOptimzer by attdevsupport.

the class Application method cleanUp.

private void cleanUp(ApplicationContext context) {
    String dir = "";
    File filepath = new File(UtilOut.class.getProtectionDomain().getCodeSource().getLocation().getPath());
    dir = filepath.getParent();
    IFileManager filemanager = context.getBean(IFileManager.class);
    filemanager.deleteFile(dir + System.getProperty("file.separator") + "AROCollector.apk");
    filemanager.deleteFile(dir + System.getProperty("file.separator") + "ARODataCollector.apk");
}
Also used : File(java.io.File) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 8 with IFileManager

use of com.att.aro.core.fileio.IFileManager in project VideoOptimzer by attdevsupport.

the class Application method runDataCollector.

/**
 * Launches a DataCollection. Provides an input prompt for the user to stop the
 * collection by typing "stop"
 *
 * <pre>
 * Note:
 * Do not exit collection by pressing a ctrl-c
 * Doing so will exit ARO.Console but will not stop the trace on the device.
 * </pre>
 *
 * @param context
 * @param cmds
 */
// ignoring incorrect eclipse warning
@SuppressWarnings("null")
void runDataCollector(ApplicationContext context, Commands cmds) {
    if (cmds.getOutput() != null) {
        // LOGGER.info("runDataCollector");
        IDataCollectorManager colmg = context.getBean(IDataCollectorManager.class);
        colmg.getAvailableCollectors(context);
        IDataCollector collector = null;
        switch(cmds.getStartcollector()) {
            case "rooted_android":
                collector = colmg.getRootedDataCollector();
                break;
            case "vpn_android":
                collector = colmg.getNorootedDataCollector();
                break;
            case "ios":
                collector = colmg.getIOSCollector();
                if (cmds.getSudo().isEmpty() || !collector.setPassword(cmds.getSudo())) {
                    printError(ErrorCodeRegistry.getInvalidPasswordError());
                    System.exit(1);
                }
                if ("hd".equals(cmds.getVideo()) || "sd".equals(cmds.getVideo())) {
                    printError(ErrorCodeRegistry.getInvalidiOSArgs());
                    System.exit(1);
                }
                break;
            default:
                printError(ErrorCodeRegistry.getCollectorNotfound());
                System.exit(1);
                break;
        }
        StatusResult result = null;
        if (collector == null) {
            printError(ErrorCodeRegistry.getCollectorNotfound());
            System.exit(1);
        }
        if (cmds.getOverwrite().equalsIgnoreCase("yes")) {
            String traceName = cmds.getOutput();
            IFileManager filemanager = context.getBean(IFileManager.class);
            filemanager.directoryDeleteInnerFiles(traceName);
        }
        OutSave outSave = prepareSystemOut();
        AttenuatorModel model = getAttenuateModel(cmds);
        // If the user want to collect regular iOS collection, they can proceed
        if (DataCollectorType.IOS.equals(collector.getType()) && (model.isThrottleDLEnabled() || model.isThrottleULEnabled())) {
            if (isIOSAttenuationConfirmed() && NetworkUtil.isNetworkUp("bridge100")) {
                model.setConstantThrottle(true);
                println("Collection proceeded.");
            } else {
                System.exit(1);
            }
        }
        videoOption = configureVideoOption(cmds.getVideo());
        try {
            Hashtable<String, Object> extras = new Hashtable<String, Object>();
            Orientation videoOrientation = getOrientation(cmds.getVideoOrientation());
            extras.put("video_option", getVideoOption());
            extras.put("videoOrientation", videoOrientation == null ? Orientation.PORTRAIT : videoOrientation);
            extras.put("AttenuatorModel", model);
            extras.put("assignPermission", false);
            result = runCommand(cmds, collector, cmds.getSudo(), extras);
        } finally {
            restoreSystemOut(outSave);
        }
        if (result.getError() != null) {
            outln("Caught an error:");
            printError(result.getError());
        } else {
            outSave = prepareSystemOut();
            try {
                String input = "";
                print("Data collector is running, enter stop to save trace and quit program");
                print(">");
                do {
                    input = readInput();
                } while (!input.contains("stop"));
            } finally {
                restoreSystemOut(outSave);
            }
            println("stopping collector...");
            try {
                if (collector != null)
                    collector.stopCollector();
            } finally {
                restoreSystemOut(outSave);
            }
            println("collector stopped, trace saved to: " + cmds.getOutput());
            cleanUp(context);
            println("VO exited");
            System.exit(0);
        }
    } else {
        println("No output tracefolder was entered\n");
        usageHelp();
        System.exit(1);
    }
}
Also used : OutSave(com.att.aro.console.printstreamutils.OutSave) Hashtable(java.util.Hashtable) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDataCollectorManager(com.att.aro.core.datacollector.IDataCollectorManager) AttenuatorModel(com.att.aro.core.peripheral.pojo.AttenuatorModel) IDataCollector(com.att.aro.core.datacollector.IDataCollector) Orientation(com.att.aro.core.video.pojo.Orientation) IFileManager(com.att.aro.core.fileio.IFileManager)

Example 9 with IFileManager

use of com.att.aro.core.fileio.IFileManager in project VideoOptimzer by attdevsupport.

the class AlarmAnalysisInfoParserImplTest method readData.

@SuppressWarnings("deprecation")
@Test
public void readData() throws IOException {
    parser = (AlarmAnalysisInfoParserImpl) context.getBean(IAlarmAnalysisInfoParser.class);
    IFileManager filereader = Mockito.mock(IFileManager.class);
    String[] arr = getData();
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
    parser.setFileReader(filereader);
    Date date = new Date(2014, 01, 06, 12, 0, 26);
    AlarmAnalysisResult result = null;
    boolean hasdata = false;
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    result = parser.parse("/", "alarm_info_end", "2.3", 3015093, 3064068, date);
    hasdata = result.getStatistics().size() > 0;
    assertTrue(hasdata);
    String[] startarr = getDataStart();
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(startarr);
    date = new Date(2014, 01, 06, 12, 0, 29);
    AlarmAnalysisResult result2 = parser.parse("/", "alarm_info_start", "2.3", 3047197, 3064068, date);
    List<AlarmAnalysisInfo> alarmStatisticsInfosEnd = result.getStatistics();
    List<AlarmAnalysisInfo> alarmStatisticsInfosStart = result2.getStatistics();
    List<AlarmAnalysisInfo> alarmlist = parser.compareAlarmAnalysis(alarmStatisticsInfosEnd, alarmStatisticsInfosStart);
    hasdata = alarmlist.size() > 0;
    assertTrue(hasdata);
}
Also used : AlarmAnalysisInfo(com.att.aro.core.peripheral.pojo.AlarmAnalysisInfo) AlarmAnalysisResult(com.att.aro.core.peripheral.pojo.AlarmAnalysisResult) Date(java.util.Date) IFileManager(com.att.aro.core.fileio.IFileManager) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 10 with IFileManager

use of com.att.aro.core.fileio.IFileManager in project VideoOptimzer by attdevsupport.

the class AlarmAnalysisInfoParserImplTest method readData_Test2.

@Test
public void readData_Test2() throws IOException {
    parser = (AlarmAnalysisInfoParserImpl) context.getBean(IAlarmAnalysisInfoParser.class);
    IFileManager filereader = Mockito.mock(IFileManager.class);
    String[] startarr2 = getDataStart2();
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(startarr2);
    parser.setFileReader(filereader);
    @SuppressWarnings("deprecation") Date date = new Date(2014, 01, 06, 12, 0, 30);
    AlarmAnalysisResult result4 = null;
    boolean hasdata = false;
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    result4 = parser.parse("/", "alarm_info_end", "3.0", 3015093, 3064068, date);
    String[] startarr3 = getDataStart3();
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(startarr3);
    AlarmAnalysisResult result3 = parser.parse("/", "alarm_info_start", "3.0", 3047197, 3064068, date);
    List<AlarmAnalysisInfo> alarmStatisticsInfosStart1 = result4.getStatistics();
    List<AlarmAnalysisInfo> alarmStatisticsInfosEnd1 = result3.getStatistics();
    List<AlarmAnalysisInfo> alarmlist1 = parser.compareAlarmAnalysis(alarmStatisticsInfosEnd1, alarmStatisticsInfosStart1);
    hasdata = alarmlist1.size() > 0;
    assertTrue(hasdata);
}
Also used : AlarmAnalysisInfo(com.att.aro.core.peripheral.pojo.AlarmAnalysisInfo) AlarmAnalysisResult(com.att.aro.core.peripheral.pojo.AlarmAnalysisResult) Date(java.util.Date) IFileManager(com.att.aro.core.fileio.IFileManager) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

IFileManager (com.att.aro.core.fileio.IFileManager)11 BaseTest (com.att.aro.core.BaseTest)5 Test (org.junit.Test)5 File (java.io.File)4 IOException (java.io.IOException)3 Date (java.util.Date)3 StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)2 AlarmAnalysisInfo (com.att.aro.core.peripheral.pojo.AlarmAnalysisInfo)2 AlarmAnalysisResult (com.att.aro.core.peripheral.pojo.AlarmAnalysisResult)2 CpuActivityList (com.att.aro.core.peripheral.pojo.CpuActivityList)2 MainFrame (com.att.aro.ui.view.MainFrame)2 OutSave (com.att.aro.console.printstreamutils.OutSave)1 IDataCollector (com.att.aro.core.datacollector.IDataCollector)1 IDataCollectorManager (com.att.aro.core.datacollector.IDataCollectorManager)1 FileManagerImpl (com.att.aro.core.fileio.impl.FileManagerImpl)1 VideoStreamConstructor (com.att.aro.core.packetanalysis.impl.VideoStreamConstructor)1 AttenuatorModel (com.att.aro.core.peripheral.pojo.AttenuatorModel)1 AROTraceData (com.att.aro.core.pojo.AROTraceData)1 ErrorCode (com.att.aro.core.pojo.ErrorCode)1 Orientation (com.att.aro.core.video.pojo.Orientation)1