How do you assert an exception in JUnit?

In JUnit, how do you assert an exception?

When using JUnit 4, we can use the @Test annotation’s expected attribute to declare that we expect an exception to be raised anywhere within the annotated test function.