use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.
the class DataCollectorManagerImplTest method test1.
@Test
public void test1() {
// IDataCollector ios = Mockito.mock(IDataCollector.class);
// Mockito.when(ios.getType()).thenReturn(DataCollectorType.IOS);
List<IDataCollector> collist = new ArrayList<IDataCollector>();
IDataCollector defaultCollector = Mockito.mock(IDataCollector.class);
Mockito.when(defaultCollector.getType()).thenReturn(DataCollectorType.DEFAULT);
collist.add(defaultCollector);
IDataCollector iosCollector = Mockito.mock(IDataCollector.class);
Mockito.when(iosCollector.getType()).thenReturn(DataCollectorType.IOS);
collist.add(iosCollector);
IDataCollector rootedCollector = Mockito.mock(IDataCollector.class);
Mockito.when(rootedCollector.getType()).thenReturn(DataCollectorType.ROOTED_ANDROID);
collist.add(rootedCollector);
IDataCollector nonRootedCollector = Mockito.mock(IDataCollector.class);
Mockito.when(nonRootedCollector.getType()).thenReturn(DataCollectorType.NON_ROOTED_ANDROID);
collist.add(nonRootedCollector);
cmg = (DataCollectorManagerImpl) context.getBean(IDataCollectorManager.class);
ApplicationContext context = Mockito.mock(ApplicationContext.class);
String[] arr = { "ios", "default", "rooted", "nonrooted" };
Mockito.when(context.getBeanNamesForType((Class<?>) Mockito.any())).thenReturn(arr);
Mockito.when(context.getBean("ios")).thenReturn(iosCollector);
Mockito.when(context.getBean("default")).thenReturn(defaultCollector);
Mockito.when(context.getBean("rooted")).thenReturn(rootedCollector);
Mockito.when(context.getBean("nonrooted")).thenReturn(nonRootedCollector);
List<IDataCollector> collectors = cmg.getAvailableCollectors(context);
IDataCollector res = cmg.getIOSCollector();
assertNotNull(res);
IDataCollector res1 = cmg.getNorootedDataCollector();
assertNotNull(res1);
IDataCollector res2 = cmg.getRootedDataCollector();
assertNotNull(res2);
assertEquals(3, collectors.size());
}
use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.
the class ARODataCollectorMenu method chooseDevice.
private IAroDevice chooseDevice(IAroDevices aroDevices, List<IDataCollector> collectors) {
ArrayList<IAroDevice> deviceList = aroDevices.getDeviceList();
IAroDevice device = null;
int delayTimeDL = 0;
int throttleDL = 0;
int throttleUL = 0;
boolean throttleDLEnable = false;
boolean throttleULEnable = false;
boolean profileBoolean = false;
String traceFolderName = "";
String profileLocation = "";
if (((MainFrame) parent).getPreviousOptions() != null) {
previousOptions = ((MainFrame) parent).getPreviousOptions();
}
metaDataModel = new MetaDataModel();
DataCollectorSelectNStartDialog dialog = new DataCollectorSelectNStartDialog(((MainFrame) parent).getJFrame(), parent, deviceList, traceFolderName, collectors, true, previousOptions, metaDataModel);
if (dialog.getResponse()) {
device = dialog.getDevice();
traceFolderName = dialog.getTraceFolder();
device.setCollector(dialog.getCollectorOption());
/*debug purpose*/
delayTimeDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayDS();
dialog.getDeviceOptionPanel().getAttenuatorModel().getDelayUS();
throttleDL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleDL();
throttleUL = dialog.getDeviceOptionPanel().getAttenuatorModel().getThrottleUL();
throttleDLEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleDLEnabled();
throttleULEnable = dialog.getDeviceOptionPanel().getAttenuatorModel().isThrottleULEnabled();
profileLocation = dialog.getDeviceOptionPanel().getAttenuatorModel().getLocalPath();
profileBoolean = dialog.getDeviceOptionPanel().getAttenuatorModel().isLoadProfile();
LOG.info("set U delay: " + delayTimeDL + ", set D delay: " + delayTimeDL + ", set U throttle: " + throttleUL + ", set D throttle: " + throttleDL + ", set profile: " + profileBoolean + ", set profileLocation: " + profileLocation);
if (device.isPlatform(IAroDevice.Platform.iOS)) {
IDataCollector iosCollector = findIOSCollector(collectors);
if ((throttleDLEnable || throttleULEnable) && !NetworkUtil.isNetworkUp(SharedNetIF)) {
MessageDialogFactory.getInstance().showInformationDialog(((MainFrame) parent).getJFrame(), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.finalwarning"), ResourceBundleHelper.getMessageString("dlog.collector.option.attenuator.attenuation.noshared"));
return null;
}
if (!checkSetSuPassword(iosCollector)) {
return null;
} else {
LOG.info("pw validated");
}
}
String traceFolderPath = (device.getPlatform().equals(IAroDevice.Platform.Android)) ? Util.getAROTraceDirAndroid() + System.getProperty("file.separator") + traceFolderName : Util.getAROTraceDirIOS() + System.getProperty("file.separator") + traceFolderName;
String currentPath = ((MainFrame) parent).getTracePath();
if (fileManager.directoryExistAndNotEmpty(traceFolderPath)) {
int result = folderExistsDialog();
if (result == JOptionPane.OK_OPTION) {
if (traceFolderPath.equals(currentPath)) {
new MessageDialogFactory().showErrorDialog(null, ResourceBundleHelper.getMessageString("viewer.contentUnwritable"));
return null;
}
File mountPoint = fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT);
if (fileManager.createFile(traceFolderPath, IOSCollectorImpl.IOSAPP_MOUNT).exists() && device.getPlatform().equals(IAroDevice.Platform.iOS)) {
IExternalProcessRunner runner = new ExternalProcessRunnerImpl();
String results = runner.executeCmd(String.format("umount %s;rmdir %s", mountPoint, mountPoint));
if (!results.isEmpty()) {
new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " is BUSY");
return null;
} else {
int count = 0;
while (fileManager.directoryExistAndNotEmpty(mountPoint.toString())) {
if (++count > 5) {
new MessageDialogFactory().showErrorDialog(null, traceFolderPath + "/" + IOSCollectorImpl.IOSAPP_MOUNT + " will not release, please detach the iOS device and delete the foldere manually");
return null;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Log.error("sleep interrupted");
}
}
}
}
fileManager.deleteFolderContents(traceFolderPath);
} else {
return null;
}
}
Hashtable<String, Object> extras = prepareStartCollectorExtras(device, traceFolderName, dialog);
updateMetaData(device, traceFolderName, dialog);
extras.put("DIALOG_SIZE", dialog.getBaseSize());
if (dialog.getDeviceOptionPanel().getLabeledExpandedOptionFields().isVisible()) {
extras.put("MetaDataExpanded", true);
}
((MainFrame) parent).startCollector(device, traceFolderName, extras, metaDataModel);
} else {
traceFolderName = null;
}
dialog.dispose();
return device;
}
use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.
the class AROController method getAroDevices.
/**
* Builds a list of IAroDevices
*
* @return a list of IAroDevices
*/
public IAroDevices getAroDevices() {
// IDevice[] androidDevices = null;
IAroDevices aroDevices = new AroDevices();
List<IDataCollector> collectors = getAvailableCollectors();
if (Util.isMacOS()) {
getDevices(aroDevices, collectors, DataCollectorType.IOS);
}
if (getDevices(aroDevices, collectors, DataCollectorType.ROOTED_ANDROID) == 0) {
getDevices(aroDevices, collectors, DataCollectorType.NON_ROOTED_ANDROID);
}
return aroDevices;
}
use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.
the class AROController method getDevices.
private int getDevices(IAroDevices aroDevices, List<IDataCollector> collectors, DataCollectorType collectorType) {
int count = 0;
for (IDataCollector iDataCollector : collectors) {
if (iDataCollector.getType().equals(collectorType) && aroDevices != null) {
if (Util.isMacOS() && iDataCollector.getType().equals(DataCollectorType.IOS)) {
StatusResult status = new StatusResult();
IAroDevice[] aroDeviceArray = iDataCollector.getDevices(status);
aroDevices.addDeviceArray(aroDeviceArray);
count = aroDeviceArray == null ? 0 : aroDeviceArray.length;
} else {
IDevice[] androidDevices = getConnectedDevices();
if (androidDevices != null && androidDevices.length > 0) {
aroDevices.addDeviceArray(androidDevices);
}
count = androidDevices == null ? 0 : androidDevices.length;
}
}
}
return count;
}
use of com.att.aro.core.datacollector.IDataCollector in project VideoOptimzer by attdevsupport.
the class AROController method loadCollector.
/**
* Loads the appropriate collector for an IAroDevice
*
* @param device an IAroDevice
* @return collector associated with the device
*/
private IDataCollector loadCollector(IAroDevice device) {
IDataCollector collector = null;
if (device.isPlatform(IAroDevice.Platform.Android)) {
if (device.isRooted()) {
LOG.debug("rooted device");
isRooted = true;
collector = context.getBean(IDataCollectorManager.class).getRootedDataCollector();
} else {
LOG.debug("non-rooted device");
collector = context.getBean(IDataCollectorManager.class).getNorootedDataCollector();
}
} else if (device.isPlatform(IAroDevice.Platform.iOS)) {
LOG.debug("iOS device");
collector = context.getBean(IDataCollectorManager.class).getIOSCollector();
}
return collector;
}
Aggregations