@Test public void testMigrateOperation() throws Exception {
  String subsystemXml=readResource("subsystem-migrate-2.2.0.xml");
  NewSubsystemAdditionalInitialization additionalInitialization=new NewSubsystemAdditionalInitialization();
  KernelServices services=createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build();
  ModelNode model=services.readWholeModel();
  assertFalse(additionalInitialization.extensionAdded);
  assertTrue(model.get(SUBSYSTEM,WebExtension.SUBSYSTEM_NAME).isDefined());
  assertFalse(model.get(SUBSYSTEM,UNDERTOW_SUBSYSTEM_NAME).isDefined());
  ModelNode migrateOp=new ModelNode();
  migrateOp.get(OP).set("migrate");
  migrateOp.get(OP_ADDR).add(SUBSYSTEM,WebExtension.SUBSYSTEM_NAME);
  checkOutcome(services.executeOperation(migrateOp));
  model=services.readWholeModel();
  assertTrue(additionalInitialization.extensionAdded);
  assertFalse(model.get(SUBSYSTEM,WebExtension.SUBSYSTEM_NAME).isDefined());
  assertTrue(model.get(SUBSYSTEM,UNDERTOW_SUBSYSTEM_NAME).isDefined());
  ModelNode ioSubsystem=model.get(SUBSYSTEM,"io");
  assertTrue(ioSubsystem.isDefined());
  assertTrue(ioSubsystem.get("worker","default").isDefined());
  assertTrue(ioSubsystem.get("buffer-pool","default").isDefined());
  ModelNode newSubsystem=model.get(SUBSYSTEM,UNDERTOW_SUBSYSTEM_NAME);
  ModelNode newServer=newSubsystem.get("server","default-server");
  assertNotNull(newServer);
  assertTrue(newServer.isDefined());
  assertEquals("default-host",newServer.get(Constants.DEFAULT_HOST).asString());
  ModelNode servletContainer=newSubsystem.get(Constants.SERVLET_CONTAINER,"default");
  assertNotNull(servletContainer);
  assertTrue(servletContainer.isDefined());
  assertEquals("${prop.default-session-timeout:30}",servletContainer.get(Constants.DEFAULT_SESSION_TIMEOUT).asString());
  assertEquals("${prop.listings:true}",servletContainer.get(Constants.DIRECTORY_LISTING).asString());
  ModelNode jsp=servletContainer.get(Constants.SETTING,Constants.JSP);
  assertNotNull(jsp);
  assertEquals("${prop.recompile-on-fail:true}",jsp.get(Constants.RECOMPILE_ON_FAIL).asString());
  ModelNode welcome=servletContainer.get(Constants.WELCOME_FILE,"toto");
  assertTrue(welcome.isDefined());
  ModelNode mimeMapping=servletContainer.get(Constants.MIME_MAPPING,"ogx");
  assertTrue(mimeMapping.isDefined());
  assertEquals("application/ogg",mimeMapping.get(Constants.VALUE).asString());
  ModelNode connector=newServer.get(Constants.HTTP_LISTENER,"http");
  assertTrue(connector.isDefined());
  assertEquals("http",connector.get(Constants.SOCKET_BINDING).asString());
  assertEquals("${prop.enabled:true}",connector.get(Constants.ENABLED).asString());
  assertEquals("${prop.enable-lookups:false}",connector.get(Constants.RESOLVE_PEER_ADDRESS).asString());
  assertEquals("${prop.max-post-size:2097153}",connector.get(Constants.MAX_POST_SIZE).asString());
  assertEquals("https",connector.get(Constants.REDIRECT_SOCKET).asString());
  ModelNode httpsConnector=newServer.get(Constants.HTTPS_LISTENER,"https");
  String realmName=httpsConnector.get(Constants.SECURITY_REALM).asString();
  assertTrue(realmName,realmName.startsWith("jbossweb-migration-security-realm"));
  assertEquals("${prop.session-cache-size:512}",httpsConnector.get(Constants.SSL_SESSION_CACHE_SIZE).asString());
  assertEquals("REQUESTED",httpsConnector.get(Constants.VERIFY_CLIENT).asString());
  ModelNode realm=model.get(CORE_SERVICE,MANAGEMENT).get(SECURITY_REALM,realmName);
  ModelNode trustStore=realm.get(AUTHENTICATION,TRUSTSTORE);
  assertEquals("${file-base}/jsse.keystore",trustStore.get(KeystoreAttributes.KEYSTORE_PATH.getName()).asString());
  ModelNode filters=newSubsystem.get(Constants.CONFIGURATION,Constants.FILTER);
  ModelNode dumpFilter=filters.get("expression-filter","request-dumper");
  assertEquals("dump-request",dumpFilter.get("expression").asString());
  validateExpressionFilter(dumpFilter);
  ModelNode remoteAddrFilter=filters.get("expression-filter","remote-addr");
  assertEquals("access-control(acl={'192.168.1.20 deny', '127.0.0.1 allow', '127.0.0.2 allow'} , attribute=%a)",remoteAddrFilter.get("expression").asString());
  validateExpressionFilter(remoteAddrFilter);
  ModelNode stuckFilter=filters.get("expression-filter","stuck");
  assertEquals("stuck-thread-detector(threshhold='1000')",stuckFilter.get("expression").asString());
  validateExpressionFilter(stuckFilter);
  ModelNode proxyFilter=filters.get("expression-filter","proxy");
  assertEquals("regex(pattern=\"proxy1|proxy2\", value=%{i,x-forwarded-for}, full-match=true) and regex(pattern=\"192\\.168\\.0\\.10|192\\.168\\.0\\.11\", value=%{i,x-forwarded-for}, full-match=true) -> proxy-peer-address",proxyFilter.get("expression").asString());
  validateExpressionFilter(proxyFilter);
  ModelNode crawler=servletContainer.get(Constants.SETTING,Constants.CRAWLER_SESSION_MANAGEMENT);
  assertTrue(crawler.isDefined());
  assertEquals(1,crawler.get(Constants.SESSION_TIMEOUT).asInt());
  assertEquals("Google",crawler.get(Constants.USER_AGENTS).asString());
  ModelNode virtualHost=newServer.get(Constants.HOST,"default-host");
  assertEquals("welcome-content",virtualHost.get("location","/").get(Constants.HANDLER).asString());
  assertEquals("localhost",virtualHost.get("alias").asList().get(0).asString());
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"request-dumper"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"remote-addr"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"proxy"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"stuck"));
  assertFalse(virtualHost.hasDefined(Constants.FILTER_REF,"myvalve"));
  ModelNode accessLog=virtualHost.get(Constants.SETTING,Constants.ACCESS_LOG);
  assertEquals("prefix",accessLog.get(Constants.PREFIX).asString());
  assertEquals("true",accessLog.get(Constants.ROTATE).asString());
  assertEquals("extended",accessLog.get(Constants.PATTERN).asString());
  assertEquals("toto",accessLog.get(Constants.DIRECTORY).asString());
  assertEquals("jboss.server.base.dir",accessLog.get(Constants.RELATIVE_TO).asString());
  ModelNode sso=virtualHost.get(Constants.SETTING,Constants.SINGLE_SIGN_ON);
  assertEquals("${prop.domain:myDomain}",sso.get(Constants.DOMAIN).asString());
  assertEquals("${prop.http-only:true}",sso.get(Constants.HTTP_ONLY).asString());
  virtualHost=newServer.get(Constants.HOST,"vs1");
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"request-dumper"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"remote-addr"));
  assertFalse(virtualHost.hasDefined(Constants.FILTER_REF,"myvalve"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"proxy"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"stuck"));
  accessLog=virtualHost.get(Constants.SETTING,Constants.ACCESS_LOG);
  assertEquals("myapp_access_log.",accessLog.get(Constants.PREFIX).asString());
  assertEquals(".log",accessLog.get(Constants.SUFFIX).asString());
  assertEquals("true",accessLog.get(Constants.ROTATE).asString());
  assertEquals("common",accessLog.get(Constants.PATTERN).asString());
  assertEquals("${jboss.server.log.dir}",accessLog.get(Constants.DIRECTORY).asString());
  assertEquals("exists(%{r,log-enabled})",accessLog.get(Constants.PREDICATE).asString());
  virtualHost=newServer.get(Constants.HOST,"vs1");
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"request-dumper"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"remote-addr"));
  assertFalse(virtualHost.hasDefined(Constants.FILTER_REF,"myvalve"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"proxy"));
  assertTrue(virtualHost.hasDefined(Constants.FILTER_REF,"stuck"));
  assertEquals("myapp_access_log.",accessLog.get(Constants.PREFIX).asString());
  assertEquals(".log",accessLog.get(Constants.SUFFIX).asString());
  assertEquals("true",accessLog.get(Constants.ROTATE).asString());
  assertEquals("common",accessLog.get(Constants.PATTERN).asString());
  assertEquals("${jboss.server.log.dir}",accessLog.get(Constants.DIRECTORY).asString());
  assertEquals("exists(%{r,log-enabled})",accessLog.get(Constants.PREDICATE).asString());
}
