Novak Djokovic suffered a shock loss to a German teenager in his last match before defending his Wimbledon crown, while Rafael Nadal got a vital win on grass in his bid to find form.