diff --git a/core/modules/system/tests/modules/module_test/lib/Drupal/module_test/Controllers/ModuleTestController.php b/core/modules/system/tests/modules/module_test/lib/Drupal/module_test/Controllers/ModuleTestController.php
new file mode 100644
index 0000000..d30e087
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test/lib/Drupal/module_test/Controllers/ModuleTestController.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * @file
+ * Contains \Drupal\module_test\Controllers\ModuleTestController.
+ */
+
+namespace Drupal\module_test\Controllers;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+use Drupal\Core\Controller\ControllerInterface;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+
+/**
+ * Controller routines for module_test routes.
+ */
+class ModuleTestController implements ControllerInterface {
+
+  protected $moduleHandler;
+
+   /*
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static($container->get('module_handler'));
+  }
+
+  /**
+   * Constructs a ModuleTestController object.
+   *
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
+   *   The factory for configuration objects.
+   */
+  public function __construct(ModuleHandlerInterface $moduleHandler) {
+    $this->moduleHandler = $moduleHandler;
+  }
+
+  /**
+   * For 'hook dynamic loading' test.
+   *
+   * If the hook is dynamically loaded correctly, the menu callback should
+   * return 'success!'.
+   */
+  function invokeDynamicLoadingHook() {
+    $result = $this->moduleHandler->invoke('module_test', 'test_hook');
+    return $result['module_test'];
+  }
+
+  /**
+   * For 'hook dynamic loading' test.
+   *
+   * If the hook is dynamically loaded correctly, the menu callback should
+   * return 'success!'.
+   */
+  function invokeDynamicLoadingHookAll() {
+    $result = $this->moduleHandler->invokeAll('test_hook');
+    return $result['module_test'];
+  }
+
+  /**
+   * For 'hook dynamic loading' test.
+   *
+   * If the hook is dynamically loaded correctly, the menu callback should
+   * return 'success!'.
+   */
+  function invokeDynamicLoadingHookAllDuringLoad($param) {
+    return $param;
+  }
+
+  /**
+   * For 'class loading' test.
+   *
+   * This module does not have a dependency on module_autoload_test.module. If
+   * that module is enabled, this function should return the string
+   * 'Drupal\\module_autoload_test\\SomeClass::testMethod() was invoked.'. If
+   * that module is not enabled, this function should return nothing.
+   */
+  function testClassLoading() {
+    if (class_exists('Drupal\module_autoload_test\SomeClass')) {
+      $obj = new \Drupal\module_autoload_test\SomeClass();
+      return $obj->testMethod();
+    }
+  }
+
+}
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index fd1d2e6..3cf8484 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -70,61 +70,24 @@ function module_test_hook_info() {
 function module_test_menu() {
   $items['module-test/hook-dynamic-loading-invoke'] = array(
     'title' => 'Test hook dynamic loading (invoke)',
-    'page callback' => 'module_test_hook_dynamic_loading_invoke',
-    'access arguments' => array('access content'),
+    'route_name' => 'module_test_hook_dynamic_loading_invoke',
   );
   $items['module-test/hook-dynamic-loading-invoke-all'] = array(
     'title' => 'Test hook dynamic loading (invoke_all)',
-    'page callback' => 'module_test_hook_dynamic_loading_invoke_all',
-    'access arguments' => array('access content'),
+    'route_name' => 'module_test_hook_dynamic_loading_invoke_all',
   );
   $items['module-test/hook-dynamic-loading-invoke-all-during-load/%module_test'] = array(
     'title' => 'Test hook dynamic loading (menu item load)',
-    'page callback' => 'module_test_hook_dynamic_loading_invoke_all_during_load',
-    'page arguments' => array(2),
-    'access arguments' => array('access content'),
+    'route_name' => 'module_test_hook_dynamic_loading_invoke_all_during_load',
   );
   $items['module-test/class-loading'] = array(
     'title' => 'Test loading a class from another module',
-    'page callback' => 'module_test_class_loading',
-    'access callback' => TRUE,
+    'route_name' => 'module_test_class_loading',
   );
   return $items;
 }
 
 /**
- * Page callback for 'hook dynamic loading' test.
- *
- * If the hook is dynamically loaded correctly, the menu callback should
- * return 'success!'.
- */
-function module_test_hook_dynamic_loading_invoke() {
-  $result = module_invoke('module_test', 'test_hook');
-  return $result['module_test'];
-}
-
-/**
- * Page callback for 'hook dynamic loading' test.
- *
- * If the hook is dynamically loaded correctly, the menu callback should
- * return 'success!'.
- */
-function module_test_hook_dynamic_loading_invoke_all() {
-  $result = Drupal::moduleHandler()->invokeAll('test_hook');
-  return $result['module_test'];
-}
-
-/**
- * Page callback for 'hook dynamic loading' test.
- *
- * If the hook is dynamically loaded correctly, the menu callback should
- * return 'success!'.
- */
-function module_test_hook_dynamic_loading_invoke_all_during_load($param) {
-  return $param;
-}
-
-/**
  * Load function used by module_test_hook_dynamic_loading_invoke_all_during_load().
  *
  * @see module_test_menu().
diff --git a/core/modules/system/tests/modules/module_test/module_test.routing.yml b/core/modules/system/tests/modules/module_test/module_test.routing.yml
new file mode 100644
index 0000000..260a449
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test/module_test.routing.yml
@@ -0,0 +1,27 @@
+module_test_hook_dynamic_loading_invoke:
+  pattern: '/module-test/hook-dynamic-loading-invoke'
+  defaults:
+    _controller: '\Drupal\module_test\Controllers\ModuleTestController::invokeDynamicLoadingHook'
+  requirements:
+    _permission: 'access content'
+
+module_test_hook_dynamic_loading_invoke_all:
+  pattern: '/module-test/hook-dynamic-loading-invoke-all'
+  defaults:
+    _controller: '\Drupal\module_test\Controllers\ModuleTestController::invokeDynamicLoadingHookAll'
+  requirements:
+    _permission: 'access content'
+
+module_test_hook_dynamic_loading_invoke_all_during_load:
+  pattern: '/module-test/hook-dynamic-loading-invoke-all-during-load/{param}'
+  defaults:
+    _controller: '\Drupal\module_test\Controllers\ModuleTestController::invokeDynamicLoadingHookAllDuringLoad'
+  requirements:
+    _permission: 'access content'
+
+module_test_class_loading:
+  pattern: '/module-test/class-loading'
+  defaults:
+    _controller: '\Drupal\module_test\Controllers\ModuleTestController::testClassLoading'
+  requirements:
+    _access: 'TRUE'
