Let $\phi:\mathbb{R}\to \mathbb{R}$ be a convex function. Then one can prove by Jensen's inequality that $$\tag{$*$} \phi \left(\int_\mathbb{R}xg(x) \, dx \right) \leq \int_\mathbb{R}\phi (x)g(x) \, dx $$ for every $g$ such that $\int_\mathbb{R}g(x) \, dx=1$ and $\int_\mathbb{R}|x|g(x) \, dx < +\infty$.
Now
suppose that $\phi$ is continuous and $(*)$ holds for every $g$ with the hypotheses above; is it true that $\phi$ is convex?
The intuition coming from other cases already treated before on this site suggests this should be the case, I'm looking for a proof or a reference.
Take a sequence $g_n$ converging to $\theta \delta_a + (1 - \theta)\delta_b$ in the weak sense of measures. One concludes that $\phi(\theta a + (1 - \theta) b) \le \theta \phi(a) + (1 - \theta)\phi(b)$. As $a$ and $b$ are arbitrary real numbers and $\theta\in [0,1]$, the convexity of $\phi$ follows.