Optical detection of electron spin resonance in CdTe