@@ -0,0 +1,2827 @@
+/*%0A * JBoss, Home of Professional Open Source%0A * Copyright 2017, Red Hat, Inc., and individual contributors as indicated%0A * by the @authors tag.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.jboss.as.test.integration.management.console;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0A%0Aimport java.net.HttpURLConnection;%0Aimport java.net.URL;%0A%0Aimport javax.inject.Inject;%0A%0Aimport org.apache.http.client.methods.HttpGet;%0Aimport org.jboss.as.test.integration.management.util.ServerReload;%0Aimport org.jboss.as.test.shared.TestSuiteEnvironment;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.wildfly.core.testrunner.ManagementClient;%0Aimport org.wildfly.core.testrunner.WildflyTestRunner;%0A%0A/**%0A * Since console is not loaded in core dist, in both modes the server is supposed to return 404.%0A *%0A * @author Tomas Hofman (thofman@redhat.com)%0A */%0A@RunWith(WildflyTestRunner.class)%0Apublic class WebConsoleRedirectionTestCase %7B%0A%0A    @SuppressWarnings(%22unused%22)%0A    @Inject%0A    private static ManagementClient managementClient;%0A%0A    @Test%0A    public void testRedirectionInAdminMode() throws Exception %7B%0A        ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient(), true);%0A        try %7B%0A            final HttpURLConnection connection = getConnection();%0A            assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());%0A        %7D finally %7B%0A            ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient(), false);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testRedirectionInNormalMode() throws Exception %7B%0A        final HttpURLConnection connection = getConnection();%0A        assertEquals(HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());%0A    %7D%0A%0A    private HttpURLConnection getConnection() throws Exception %7B%0A        final URL url = new URL(%22http://%22 + TestSuiteEnvironment.getServerAddress() + %22:%22 + TestSuiteEnvironment.getServerPort() + %22/%22);%0A        final HttpURLConnection connection = (HttpURLConnection) url.openConnection();%0A        assertNotNull(connection);%0A        connection.setInstanceFollowRedirects(false);%0A        connection.setRequestMethod(HttpGet.METHOD_NAME);%0A        connection.connect();%0A        return connection;%0A    %7D%0A%0A%7D%0A

test case - DisabledConsoleHandler returns 404 if console