Discrete time inverse fourier transform of cosine squared
The only thing that went wrong is your last statement:

They're only zero if $k\ne 0$. 

Thus, you get three Dirac delta distributions. 

Let's look at your last equation, and work with that:

$$
\begin{align}
 x(n) &amp;= \frac{1}{2\pi}\int\limits_{0}^{2\pi} \frac{e^{j\omega(n+2)} + e^{j\omega(n-2)} + 2e^{jn\omega}}{4}\,d\omega \tag1\label{orig}\\
&amp;=\frac1{8\pi}\left(\int\limits_{0}^{2\pi}e^{j(n+2)\omega}\,d\omega + \int\limits_{0}^{2\pi}e^{j(n-2)\omega}\,d\omega + \int\limits_{0}^{2\pi}e^{jn\omega}\,d\omega \right)\tag2\label{linearint}
\end{align}$$

From $\eqref{orig}$ to $\eqref{linearint}$ I just went ahead and used the fact that integration is a linear operation to decompose that single integral into a sum of three, very similar, integrals.

Now, let's look at the last one, as you (sadly, with a mistake), already did:
$$
i(n):=\int\limits_0^{2\pi}e^{jn\omega}\,d\omega =
\begin{cases}\frac1{jn}e^{jn\omega}\Big|_{\omega=0}^{2\pi} \overset{e^x\text{ is }j2\pi\text{-periodic}}= 0&amp; \text{for } n\omega \ne 0\\
\int\limits_0^{2\pi}e^{0}\,d\omega= \int\limits_0^{2\pi}1\,d\omega= 2\pi&amp; \text{else.}
\end{cases}
$$

So, this integral yields zero for all values of $n$ but for $n=0$, in which case it yields a fixed, finite, non-zero value.

Your other two integrals are just the same, but shifted w.r.t. $n$ by $2$ to the left or the right.

For more info on the Dirac delta distribution (looks like a function, isn't quite exactly a function), I'd recommend your favourite textbook or wikipedia. It's a thing that, when integrated, has an integral of $1$, but in an arbitrarily narrow support around $0$, outside of which its value is $0$.