Design, construction, and beam tests of a rotatable collimator prototype for high-intensity and high-energy hadron accelerators