Root ton keeps Sri Lanka at bay in Test