forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AS7-6386] Test the loading if versioned consoles
- Loading branch information
1 parent
01afffe
commit 92e7bc2
Showing
26 changed files
with
835 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
domain-http/interface/src/test/java/org/jboss/as/domain/http/server/ConsoleModeTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.domain.http.server; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static junit.framework.Assert.assertNotNull; | ||
import static junit.framework.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
|
||
import org.jboss.modules.LocalModuleLoader; | ||
import org.jboss.modules.ModuleClassLoader; | ||
import org.jboss.modules.ModuleIdentifier; | ||
import org.jboss.modules.ModuleLoader; | ||
import org.junit.Test; | ||
|
||
|
||
/** | ||
* | ||
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a> | ||
*/ | ||
public class ConsoleModeTestCase { | ||
|
||
|
||
@Test | ||
public void testDefaultModules() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console"), "modules-default"); | ||
} | ||
|
||
|
||
@Test | ||
public void testVersionedNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-versioned"); | ||
} | ||
|
||
@Test | ||
public void testVersionedAndMainSlot() throws Exception { | ||
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-versioned"); | ||
} | ||
|
||
@Test | ||
public void testVersionedLayersNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1"); | ||
} | ||
|
||
@Test | ||
public void testVersionedLayersAndMainSlot() throws Exception { | ||
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "1.2.1"), "modules-base-and-layer1"); | ||
} | ||
|
||
@Test | ||
public void testSeveralRootsVersionedLayersNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2"); | ||
} | ||
|
||
@Test | ||
public void testSeveralRootsVersionedLayersAndMainSlot() throws Exception { | ||
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2"); | ||
} | ||
|
||
@Test | ||
public void testSeveralRootsDifferentOrderVersionedLayersNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1"); | ||
} | ||
|
||
@Test | ||
public void testSeveralRootsDifferentOrderVersionedLayersAndMainSlot() throws Exception { | ||
checkModule("main", ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-layer2", "modules-base-and-layer1"); | ||
} | ||
|
||
@Test | ||
public void testAddonsAndLayersAddon1WinsNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "2.0.0"), "modules-base-and-layer1", "modules-addons1"); | ||
} | ||
|
||
@Test | ||
public void testAddonsAndLayersLayer2WinsNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "3.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1"); | ||
} | ||
|
||
@Test | ||
public void testAddonsAndLayersAddon2WinsNoSlot() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "4.0.0"), "modules-base-and-layer1", "modules-layer2", "modules-addons1", "modules-addons2"); | ||
} | ||
|
||
@Test | ||
public void testAddonsOnly() throws Exception { | ||
checkModule(null, ModuleIdentifier.create("org.jboss.as.console.main", "4.0.0"), "modules-addons1", "modules-addons2"); | ||
} | ||
|
||
private void checkModule(String slot, ModuleIdentifier expected, String...moduleDirNames) throws Exception { | ||
ModuleLoader loader = createModuleLoader(moduleDirNames); | ||
ClassLoader classLoader = ConsoleMode.ConsoleHandler.findConsoleClassLoader(loader, slot); | ||
assertNotNull(classLoader); | ||
assertTrue(classLoader instanceof ModuleClassLoader); | ||
ModuleClassLoader moduleClassLoader = (ModuleClassLoader)classLoader; | ||
assertEquals(expected, moduleClassLoader.getModule().getIdentifier()); | ||
} | ||
|
||
private ModuleLoader createModuleLoader(String...moduleDirNames) { | ||
StringBuilder sb = new StringBuilder(); | ||
for (String moduleDirName : moduleDirNames) { | ||
File file = new File("target/test-classes", moduleDirName); | ||
assertTrue(file.exists()); | ||
if (sb.length() > 0) { | ||
sb.append(File.pathSeparatorChar); | ||
} | ||
sb.append(file.getAbsolutePath()); | ||
} | ||
System.setProperty("module.path", sb.toString()); | ||
LocalModuleLoader loader = new LocalModuleLoader(); | ||
return loader; | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...-http/interface/src/test/java/org/jboss/as/domain/http/server/ConsoleVersionTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2013, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.domain.http.server; | ||
|
||
import static junit.framework.Assert.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.TreeSet; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a> | ||
*/ | ||
public class ConsoleVersionTestCase { | ||
|
||
@Test | ||
public void testSortConsoleVersions() { | ||
ConsoleVersion versionMain = new ConsoleVersion("main"); | ||
ConsoleVersion version001 = new ConsoleVersion("0.0.1"); | ||
ConsoleVersion version002 = new ConsoleVersion("0.0.2"); | ||
ConsoleVersion version010 = new ConsoleVersion("0.1.0"); | ||
ConsoleVersion version020 = new ConsoleVersion("0.2.0"); | ||
ConsoleVersion version100 = new ConsoleVersion("1.0.0"); | ||
ConsoleVersion version101 = new ConsoleVersion("1.0.1"); | ||
ConsoleVersion version102 = new ConsoleVersion("1.0.2"); | ||
ConsoleVersion version110 = new ConsoleVersion("1.1.0"); | ||
ConsoleVersion version111 = new ConsoleVersion("1.1.1"); | ||
ConsoleVersion version120 = new ConsoleVersion("1.2.0"); | ||
ConsoleVersion version122 = new ConsoleVersion("1.2.2"); | ||
ConsoleVersion version200 = new ConsoleVersion("2.0.0"); | ||
ConsoleVersion version201 = new ConsoleVersion("2.0.1"); | ||
ConsoleVersion version210 = new ConsoleVersion("2.1.0"); | ||
|
||
TreeSet<ConsoleVersion> set = new TreeSet<ConsoleVersion>(); | ||
set.add(versionMain); | ||
set.add(version001); | ||
set.add(version002); | ||
set.add(version010); | ||
set.add(version020); | ||
set.add(version100); | ||
set.add(version101); | ||
set.add(version102); | ||
set.add(version110); | ||
set.add(version111); | ||
set.add(version120); | ||
set.add(version122); | ||
set.add(version200); | ||
set.add(version201); | ||
set.add(version210); | ||
|
||
Iterator<ConsoleVersion> it = set.iterator(); | ||
Assert.assertEquals(version210, it.next()); | ||
Assert.assertEquals(version201, it.next()); | ||
Assert.assertEquals(version200, it.next()); | ||
Assert.assertEquals(version122, it.next()); | ||
Assert.assertEquals(version120, it.next()); | ||
Assert.assertEquals(version111, it.next()); | ||
Assert.assertEquals(version110, it.next()); | ||
Assert.assertEquals(version102, it.next()); | ||
Assert.assertEquals(version101, it.next()); | ||
Assert.assertEquals(version100, it.next()); | ||
Assert.assertEquals(version020, it.next()); | ||
Assert.assertEquals(version010, it.next()); | ||
Assert.assertEquals(version002, it.next()); | ||
Assert.assertEquals(version001, it.next()); | ||
Assert.assertEquals(versionMain, it.next()); | ||
Assert.assertFalse(it.hasNext()); | ||
|
||
ArrayList<ConsoleVersion> list = new ArrayList<ConsoleVersion>(set); | ||
for (int i = 1 ; i < list.size() - 1; i++) { | ||
final ConsoleVersion current = list.get(i); | ||
for (int j = 0 ; j < i ; j++) { | ||
final ConsoleVersion higher = list.get(j); | ||
assertTrue(higher.compareTo(current) < 0); | ||
assertTrue(current.compareTo(higher) > 0); | ||
} | ||
|
||
for (int j = i + 1 ; j < list.size() ; j++) { | ||
final ConsoleVersion lower = list.get(j); | ||
assertTrue(current.compareTo(lower) < 0); | ||
assertTrue(lower.compareTo(current) > 0); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.