List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, Transformer transformer)
From source file:com.utdallas.s3lab.smvhunter.monkey.MonkeyMe.java
/** * @param args/* w ww . j av a2 s .c o m*/ */ public static void main(String[] args) throws Exception { logger.info("start time ==== " + System.currentTimeMillis()); try { //load the adb location from the props file Properties props = new Properties(); props.load(new FileInputStream(new File("adb.props"))); //set the adb location WindowUpdate.adbLocation = props.getProperty("adb_location"); adbLocation = props.getProperty("adb_location"); //set root dir ROOT_DIRECTORY = props.getProperty("root_dir"); //completed txt completedFile = new File(ROOT_DIRECTORY + "tested.txt"); //db location for static analysis dbLocation = props.getProperty("db_location"); //location for smart input generation output smartInputLocation = props.getProperty("smart_input_location"); //udp dump location udpDumpLocation = props.getProperty("udp_dump_location"); //logcat dump location logCatLocation = props.getProperty("log_cat_location"); //strace output location straceOutputLocation = props.getProperty("strace_output_location"); //strace dump location straceDumpLocation = props.getProperty("strace_output_location"); //set x and y coords UIEnumerator.screenX = props.getProperty("x"); UIEnumerator.screenY = props.getProperty("y"); DeviceOfflineMonitor.START_EMULATOR = props.getProperty("restart"); //read output of static analysis readFromStaticAnalysisText(); logger.info("Read static analysis output"); readFromSmartInputText(); logger.info("Read smart input generation output"); //populate the queue with apps which are only present in the static analysis @SuppressWarnings("unchecked") final Set<? extends String> sslApps = new HashSet<String>( CollectionUtils.collect(FileUtils.readLines(new File(dbLocation)), new Transformer() { @Override public Object transform(Object input) { //get app file name String temp = StringUtils.substringBefore(input.toString(), " "); return StringUtils.substringAfterLast(temp, "/"); } })); Collection<File> fileList = FileUtils.listFiles(new File(ROOT_DIRECTORY), new String[] { "apk" }, false); CollectionUtils.filter(fileList, new Predicate() { @Override public boolean evaluate(Object object) { return sslApps.contains(StringUtils.substringAfterLast(object.toString(), "/")); } }); apkQueue = new LinkedBlockingDeque<File>(fileList); logger.info("finished listing files from the root directory"); try { //populate the tested apk list completedApps.addAll(FileUtils.readLines(completedFile)); } catch (Exception e) { //pass except logger.info("No tested.txt file found"); //create new file if (completedFile.createNewFile()) { logger.info("tested.txt created in root directory"); } else { logger.info("tested.txt file could not be created"); } } //get the executors for managing the emulators executors = Executors.newCachedThreadPool(); //set the devicemonitor exec DeviceOfflineMonitor.exec = executors; final List<Future<?>> futureList = new ArrayList<Future<?>>(); //start the offline device monitor (emulator management thread) logger.info("Starting Device Offline Monitor Thread"); executors.submit(new DeviceOfflineMonitor()); //get ADB backend object for device change listener AdbBackend adb = new AdbBackend(); //register for device change and wait for events //once event is received, start the MonkeyMe thread MonkeyDeviceChangeListener deviceChangeListener = new MonkeyDeviceChangeListener(executors, futureList); AndroidDebugBridge.addDeviceChangeListener(deviceChangeListener); logger.info("Listening to changes in devices (emulators)"); //wait for the latch to come down //this means that all the apks have been processed cdl.await(); logger.info("Finished testing all apps waiting for threads to join"); //now wait for every thread to finish for (Future<?> future : futureList) { future.get(); } logger.info("All threads terminated"); //stop listening for device update AndroidDebugBridge.removeDeviceChangeListener(deviceChangeListener); //stop the debug bridge AndroidDebugBridge.terminate(); //stop offline device monitor DeviceOfflineMonitor.stop = true; logger.info("adb and listeners terminated"); } finally { logger.info("Executing this finally"); executors.shutdownNow(); } logger.info("THE END!!"); }
From source file:com.abiquo.abiserver.business.hibernate.pojohb.PojoUtils.java
@SuppressWarnings("unchecked") public static Collection<? extends IPojo> allToPojo(final Collection<? extends IPojoHB> source) { Transformer transformer = InvokerTransformer.getInstance("toPojo"); return CollectionUtils.collect(source, transformer); }
From source file:de.suljee.dw.whenthendowhen.PsiUtils.java
public static String joinExpressionTexts(List<PsiExpression> psiExpressions, String separator) { Collection<String> mockedMethodArgs = CollectionUtils.collect(psiExpressions, EXPRESSION_TO_TEXT_TRANSFORMER); return StringUtils.join(mockedMethodArgs, separator); }
From source file:com.abiquo.abiserver.business.hibernate.pojohb.PojoUtils.java
@SuppressWarnings("unchecked") public static Collection<? extends IPojoHB> allToPojoHB(final Collection<? extends IPojo> source) { Transformer transformer = InvokerTransformer.getInstance("toPojoHB"); return CollectionUtils.collect(source, transformer); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.ReadShiftsByClass.java
@Atomic public static Object run(InfoClass infoClass) { check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE); SchoolClass schoolClass = FenixFramework.getDomainObject(infoClass.getExternalId()); Collection<Shift> shifts = schoolClass.getAssociatedShiftsSet(); return CollectionUtils.collect(shifts, new Transformer() { @Override/*from ww w . j av a 2s . co m*/ public Object transform(Object arg0) { Shift shift = (Shift) arg0; InfoShift infoShift = InfoShift.newInfoFromDomain(shift); return infoShift; } }); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.resourceAllocationManager.ReadAvailableShiftsForClass.java
@Atomic public static Object run(InfoClass infoClass) { check(RolePredicates.RESOURCE_ALLOCATION_MANAGER_PREDICATE); List infoShifts = null;//from w w w .ja v a 2s . c o m SchoolClass schoolClass = FenixFramework.getDomainObject(infoClass.getExternalId()); Set<Shift> shifts = schoolClass.findAvailableShifts(); infoShifts = (List) CollectionUtils.collect(shifts, new Transformer() { @Override public Object transform(Object arg0) { Shift shift = (Shift) arg0; return InfoShift.newInfoFromDomain(shift); } }); return infoShifts; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.ReadExecutionYearsByDegreeCurricularPlanID.java
@Atomic public static List run(String degreeCurricularPlanID) { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); List<ExecutionYear> executionYears = (List<ExecutionYear>) CollectionUtils .collect(degreeCurricularPlan.getExecutionDegreesSet(), new Transformer() { @Override/*from ww w . ja va 2s.c o m*/ public Object transform(Object arg0) { ExecutionDegree executionDegree = (ExecutionDegree) arg0; return InfoExecutionYear.newInfoFromDomain(executionDegree.getExecutionYear()); } }); return executionYears; }
From source file:de.hybris.platform.acceleratorservices.urlencoder.attributes.impl.DefaultStoreFrontAttributeManager.java
@Override public Collection<String> getAllAvailableValues() { return CollectionUtils.collect(getCmsSiteService().getCurrentSite().getStores(), new Transformer() { @Override// w ww.j a v a 2s . co m public Object transform(final Object object) { return ((BaseStoreModel) object).getUid(); } }); }
From source file:de.hybris.platform.acceleratorservices.urlencoder.attributes.impl.DefaultCurrencyAttributeManager.java
@Override public Collection<String> getAllAvailableValues() { return CollectionUtils.collect(getCommerceCommonI18NService().getAllCurrencies(), new Transformer() { @Override/*w ww . j ava 2s. com*/ public Object transform(final Object object) { return ((CurrencyModel) object).getIsocode(); } }); }
From source file:de.hybris.platform.acceleratorservices.urlencoder.attributes.impl.DefaultLanguageAttributeManager.java
@Override public Collection<String> getAllAvailableValues() { return CollectionUtils.collect(getCommerceCommonI18NService().getAllLanguages(), new Transformer() { @Override/*from w ww. ja v a 2 s. c om*/ public Object transform(final Object object) { return ((LanguageModel) object).getIsocode(); } }); }