How tell JAVA Selenium WebDriver to wait for specific time period without Thread.sleep()

I’m trying to write a simple UI test with Selenium, TestNG and Hamcrest. The problem is that webshop (Opencart) which I’m using as testing playground uses the same classes for displaying featured products in front page and search results. My test method:

    @DataProvider(name = "searchDataIterator")
public Iterator<Object> searchDataProviderWithIterator(){
   return new ArrayList<Object>(Arrays.asList("macbook", "iphone", "tv", "nokia", "hat")).iterator();

@Test(groups = "generic", dataProvider = "searchDataIterator", priority = 4)
public void runSearchWithDataProvider(String searchData) throws InterruptedException {
    driver.findElement(By.cssSelector("#search input")).clear();
    driver.findElement(By.cssSelector("#search input")).sendKeys(searchData, Keys.ENTER);
    assertThat(driver.findElements(By.className("product-thumb")).size(), is(greaterThan(0)));

Problem is that if I dont’t use Thread.sleep(500); the line assertThat(driver.findElements(By.className(“product-thumb”)).size(), is(greaterThan(0))); catches either Featured product count from front page or results from previous search. I was told that using Therad.sleep() is very bad practice, but how to achieve same thing without it?

Error displaying jsp page and excel file ‘No mapping found for HTTP request with URI

For this application I am trying to export data to an excel spreadsheet user apache poi dependency in my pom.xml. The jsp page does not display. I tried adding a web.xml and a servlet-config.xml and the page does not display, instead it gives me an 404 error “No mapping found for HTTP request with URI [/ApplicationNameErrorCodes/report] in DispatcherServlet with name ‘dispatcher'” I have ran out of ideas, I researched google, I looked on youtube for examples, and I cannot find any resolution that will fix the error so I can display the page properly and create and excel file.

package applicationnameanderrorcodes.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import applicationnameanderrorcodes.model.ApplicationNameAndErrorCodes;
import applicationnameanderrorcodes.view.ExcelGenerator;

@RequestMapping(value = "/")
public class ExcelController {
    @RequestMapping(value = "/report", method = RequestMethod.GET)
    public ModelAndView applicationAndErrorCode(HttpServletRequest request, HttpServletResponse response) {
        String typeReport = request.getParameter("type");

        List<ApplicationNameAndErrorCodes> list = new ArrayList<ApplicationNameAndErrorCodes>();
        list.add(new ApplicationNameAndErrorCodes("Snabox",
                "08988A", "Add Network", "Chris Avery"));
        list.add(new ApplicationNameAndErrorCodes("Navigation",
                "270056A", "Enter Safe Mode to Unlock", "Tim Smith"));
        list.add(new ApplicationNameAndErrorCodes("Magic Desktop",
                "6892077", "Reset Desktop", "Marcus James"));
        list.add(new ApplicationNameAndErrorCodes("IFiring Portal",
                "60112011", "Deleted extra Attribute", "Aby Martinez"));

        if(typeReport != null && typeReport.equals("xlsx")) {
            return new ModelAndView(new ExcelGenerator(), "listOfErrorCodes",list);

        return new ModelAndView("excelReport", "listOfErrorCodes", list);


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

        <context:component-scan base-package="applicationnameanderrorcodes.controller"/>
    <bean id="viewResolver"
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="" xmlns="" xmlns:web="" xsi:schemaLocation="" id="WebApp_ID" version="2.4">


<%@ taglib prefix="c" uri="" %>
<%@ taglib prefix="spring" uri="" %>
  Created by IntelliJ IDEA.
  User: steven
  Date: 12/17/17
  Time: 8:45 PM
  To change this template use File | Settings | File Templates.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <table border="1">
                <td>Application Name</td>
                <td>Error Codde</td>
                <td>User Name</td>
            <c:forEach items="${listOfErrorCodes}" var="errorCode">
    <spring:url value="/report/?type=xlsx" var="xlsxUrl" />
    <a href="${xlsxUrl}">Download Excel</a>

Here’s some files I am not sure I need and a

package applicationnameanderrorcodes.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

public class WebConfig extends WebMvcConfigurerAdapter {

    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        return viewResolver;

package applicationnameanderrorcodes.config;


public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{ WebConfig.class };

    protected Class<?>[] getServletConfigClasses() {
        return null;

    protected String[] getServletMappings() {
        return new String[] {"/"};


<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">

Hibernate caching on dynamic changing parameters

I have a sample hibernate sql statement as below. As this query has three bind parameters which will vary for different criterias, Would PostComment Entity be eligible for ehcache in Hibernate? please advise.

select pc from PostComment pc join fetch p where = :id and pc.startdate= :startdate and pc.enddate= :enddate

Eclipse Milo: How to define Complex Datatypes?

I am currently implementing a server to emulate a PLC. The connection to this PLC is done via OPC-UA. The interface is provided by a thrid party and contains several custom datatypes.


Int32 x
Int32 y

Int32 id
String name
Point location

(both Point and PhysicalObject are datatypes)

Is it possible to define such structures in Milo, both client and server? I could not find anything related in the examples.
I already had a look over the sources, it seems that at least the foundations are there. But being new to OPC UA it is not so easy to figure out if how it is supposed to work.

kotlin annotation processing: check if given TypeElement is from kotlin-class

I am implementing annotation processing library that generates code using java poet based on classes that have specific annotation.

To also consume classes written in kotlin I’ve switched to kapt instead of apt in my sample project. It works with annotated java-classes just fine. Bun kotlin-classes have a different approach with accessing class fields: getters and setters should be used.

Is there a way to determine whether given class (more specifically – not a class but a TypeElement – since this is happening prior to compilation) is java-class or is written in kotlin? Based on that I can write code that generates fields accessing or getters-used accessing.

Java: change prefix namespace in SOAP 1.2

I create a SOAP server, run my server and use SOAPUI my xml client is:

<soap:Envelope xmlns:soap="" xmlns:xsd="">

But I want this:

<soapenv:Envelope xmlns:soap="" xmlns:xsd="">

I’m using Spring Framework with annotations to do this.

Pseudo code request: trying to display a diamond by using characters

enter image description here

I just want some pseudo-code, not a direct answer.

Basically I can display a pyramid(diamond, equilateral triangle) in Java.
But now i have to display a more complicated diamond using +’s and -‘s as a border and to fill the diamond with =’s and -‘s as shown in the image.

    public void process(int size) {

    int width = size*2-1;

    for(int i =0; i < size; i++){
        for(int j =0; j <=width +1; j++){
            if(j >= size -i && j<= size +i){
                mOut.print(" ");
    }for(int i =size-1; i >= 0; i--){
        for(int j =0; j <=width +1; j++){
            if(j >= size -i && j<= size +i){
                mOut.print(" ");


I understand this code doesn’t produce it but building on this how could I make the new types of diamond?

Any advice is welcome.

Execute a TaskScheduler in a RequestMapping method

what i want to do is execute a certain code ( post to a facebook page feed ) every “input” minutes, the timer is an input that will be retrieved as a @RequestParam from a html template, i tried using ThreadPoolTaskScheduler but i failed any help how to proceed ?

    @PostMapping(value = "/feed")
    String doPost(@RequestParam MultipartFile file, @RequestParam Long 
        time) throws IOException { 
           ThreadPoolTaskScheduler.scheduleAtFixedRate(Runnable(){..}, time);

Android: Background Service always shuts down

Recent changes in Androids background task running behaviour makes it very difficult to keep Services alive and continue work in applications when the phone is locked. My Service is only working properly when the screen is on or the phone gets charged. When the phone is locked, the Service shuts down almost immediately or runs way too slow to be useful in any way.

I tried to use “START_STICKY” flag and a startForeground() Notification to keep the Service alive but this doens’t help at all. I’m using a Handler that calls dowork() every 5 seconds, which then checks if theres something to do.

I want to perform a simple task on a certain time event: wake up every half/quarter or full hour, do some quick work without CPU limitation, then shut down until next time. The phone should wake up reliable and accurate on time and get “whitelisted” to use some CPU power for around half a minute. I don’t do any intense work, that could affect user performance.

public class MyService extends Service {

public MyService() {


public IBinder onBind(Intent intent) {

    return null;

public int onStartCommand(Intent intent, int flags, int startId) {

Intent notificationIntent = new Intent(this, MainActivity.class);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);

Notification notification = new NotificationCompat.Builder(this)
.setContentText("Service is running")

startForeground(1, notification);

final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
handler.postDelayed(this, 5000);
}, 1500);


How to ASN.1 encode a map / dictionary?

My ASN.1 library[1][2], in Java and Squeak/Pharo, supports sequences, sequence-of and mapped-sequence, as well as set, set-of and mapped-set. The missing collection type I wish to map is the dictionary, or map.

Are there any standard way of mapping a dictionary of key/value pairs to a robust ASN.1 encoding? Are there links to this common standard and/or examples of mapping a map/dictionary of key/value pairs? Perhaps an undiscovered SO discussion could be pointed to.

I am trying to create a generic object mapping, sort of an ANY type, but it would need the key/value pairs of the instance variables of said generic object.

Thank you.

[1] –

[2] –