protected void assertProfile(String name, int dependencySize, String[] dependencyNames) { Profile profile = profileMap.get(name); assertNotNull("Null profile: " + name, profile); assertNotNull("Null dependencies for profile: " + name, profile.getSubProfiles()); assertDependenciesSize(dependencySize, profile); assertDependencies(dependencyNames, profile.getSubProfiles()); }
public void testParsing() throws Exception { enableTrace("org.jboss.system.server.profileservice.repository"); // Set the server base url as system property for the repository generation. File serverBaseDir = new File("src/resources/server-root/"); System.setProperty("jboss.server.base.url", serverBaseDir.toURL().toExternalForm()); // Setup profile locations File f = new File("src/resources/parsing-tests/"); File one = new File(f, "config/profiles"); File two = new File(f, "common/profiles"); // The xml profile factory AbstractBootstrapProfileFactory profileFactory = new XmlProfileFactory(new URI[] {one.toURI(), two.toURI()}); profileFactory.setProfileFactory(createProfileFactory()); // Clear jar suffixes. JarUtils.clearSuffixes(); // Parse Collection<Profile> profiles = profileFactory.createProfiles(new ProfileKey("default"), null); assertNotNull(profiles); // 2 profiles in default.xml // 1 profile in seam.xml // 2 profiles in clustering.xml // 2 profiles in ejb3.xml // 2 profiles in web.xml assertEquals(10, profiles.size()); this.profileMap = new HashMap<String, Profile>(); for (Profile profile : profiles) { assertNotNull(profile.getKey()); String name = profile.getKey().getName(); assertNotNull(name); this.profileMap.put(name, profile); } // Assert Profiles assertProfiles(); // Try to load the profiles, this will try to resolve the deploymentNames // when loading the filtered repository in serverBaseDir. for (Profile profile : profiles) { Method m = null; try { m = profile.getClass().getMethod("create", new Class[0]); } catch (NoSuchMethodException ignore) { return; } boolean isAccessible = m.isAccessible(); try { m.setAccessible(true); m.invoke(profile, new Object[0]); } finally { m.setAccessible(isAccessible); } } // TODO assert metadata }
protected void assertDependenciesSize(int size, Profile profile) { assertEquals( "dependency size for profile: " + profile.getKey(), size, profile.getSubProfiles().size()); }