Skip to content

Commit

Permalink
Fixing model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Mar 27, 2015
1 parent ee244c3 commit dc78de1
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 231 deletions.
Expand Up @@ -41,6 +41,9 @@ public class ProfilingConfigurationManager {
* related to profilingConfiguration
* */
public static LoggingConfigurationType checkSystemProfilingConfiguration(PrismObject<SystemConfigurationType> systemConfigurationPrism){
if (systemConfigurationPrism == null) {
return null;
}
SystemConfigurationType systemConfig = systemConfigurationPrism.asObjectable();
ProfilingConfigurationType profilingConfig = systemConfig.getProfilingConfiguration();
boolean isSubsystemConfig;
Expand Down
Expand Up @@ -1263,7 +1263,11 @@ private PrismObject<SystemConfigurationType> getSystemConfiguration(OperationRes
SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("System configuration version read from repo: " + config.getVersion());
if (config == null) {
LOGGER.warn("No system configuration object");
} else {
LOGGER.trace("System configuration version read from repo: " + config.getVersion());
}
}
return config;
}
Expand Down
Expand Up @@ -81,8 +81,10 @@ public void postInit(PrismObject<SystemConfigurationType> systemConfiguration, O
LOGGER.warn("Skipping application of repository logging configuration because {}=true", LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS);
} else {
LoggingConfigurationType loggingConfig = ProfilingConfigurationManager.checkSystemProfilingConfiguration(systemConfiguration);
applyLoggingConfiguration(loggingConfig, systemConfiguration.asObjectable().getVersion(), parentResult);
//applyLoggingConfiguration(systemConfiguration.asObjectable().getLogging(), systemConfiguration.asObjectable().getVersion(), parentResult);
if (loggingConfig != null) {
applyLoggingConfiguration(loggingConfig, systemConfiguration.asObjectable().getVersion(), parentResult);
//applyLoggingConfiguration(systemConfiguration.asObjectable().getLogging(), systemConfiguration.asObjectable().getVersion(), parentResult);
}
}
}

Expand Down
Expand Up @@ -192,8 +192,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
}

// Administrator
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult);
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult);
login(userAdministrator);

// User Templates
Expand Down

This file was deleted.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,6 +46,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
Expand Down Expand Up @@ -74,6 +75,10 @@ public class TestCorrelationConfiramtionEvaluator extends AbstractInternalModelI
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
// super.initSystem(initTask, initResult);
// Administrator
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult);
login(userAdministrator);
}

@Test
Expand Down
1 change: 0 additions & 1 deletion model/model-impl/testng.xml
Expand Up @@ -59,7 +59,6 @@
<classes>
<class name="com.evolveum.midpoint.model.impl.lens.TestAssignmentProcessor"/>
<class name="com.evolveum.midpoint.model.impl.lens.TestAssignmentEvaluator"/>
<class name="com.evolveum.midpoint.model.impl.lens.TestProjectorAddUser"/>
<class name="com.evolveum.midpoint.model.impl.lens.TestProjector"/>
<class name="com.evolveum.midpoint.model.impl.lens.TestProjectorRoleEntitlement"/>
<class name="com.evolveum.midpoint.model.impl.lens.TestDependencies"/>
Expand Down
Expand Up @@ -72,7 +72,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
public static final File SYSTEM_CONFIGURATION_FILE = new File(COMMON_DIR, "system-configuration.xml");
public static final String SYSTEM_CONFIGURATION_OID = SystemObjectsType.SYSTEM_CONFIGURATION.value();

protected static final String USER_ADMINISTRATOR_FILENAME = COMMON_DIR + "/user-administrator.xml";
public static final File USER_ADMINISTRATOR_FILE = new File(COMMON_DIR, "user-administrator.xml");
protected static final String USER_ADMINISTRATOR_OID = "00000000-0000-0000-0000-000000000002";
protected static final String USER_ADMINISTRATOR_USERNAME = "administrator";

Expand Down Expand Up @@ -161,7 +161,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_FAKE_FILENAME = COMMON_DIR + "/resource-dummy-fake.xml";
protected static final String RESOURCE_DUMMY_FAKE_OID = "10000000-0000-0000-0000-00000000000f";

protected static final String ROLE_SUPERUSER_FILENAME = COMMON_DIR + "/role-superuser.xml";
public static final File ROLE_SUPERUSER_FILE = new File(COMMON_DIR, "role-superuser.xml");
protected static final String ROLE_SUPERUSER_OID = "00000000-0000-0000-0000-000000000004";

protected static final File ROLE_PIRATE_FILE = new File(COMMON_DIR, "role-pirate.xml");
Expand Down Expand Up @@ -393,8 +393,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Except
}

// Users
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILENAME, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILENAME, RoleType.class, initResult);
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult);
login(userAdministrator);
}

Expand Down
Expand Up @@ -67,8 +67,8 @@ public class TestLoggingConfiguration extends AbstractConfiguredModelIntegration
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
// DO NOT call super.initSystem() as this will install system config. We do not want that here.
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILENAME, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILENAME, RoleType.class, initResult);
userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, UserType.class, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, RoleType.class, initResult);
login(userAdministrator);
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Evolveum
* Copyright (c) 2010-2015 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,19 +55,12 @@
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@DirtiesContext(classMode=ClassMode.AFTER_CLASS)
public class BadImportTest extends AbstractTestNGSpringContextTests {
public class BadImportTest extends AbstractConfiguredModelIntegrationTest {

private static final Trace LOGGER = TraceManager.getTrace(BadImportTest.class);
private static final File BAD_IMPORT_FILE_NAME = new File("src/test/resources/importer/import-bad.xml");
private static final String USER_JACK_OID = "c0c010c0-d34d-b33f-f00d-111111111111";

@Autowired(required = true)
ModelService modelService;
@Autowired(required = true)
private RepositoryService repositoryService;
@Autowired(required = true)
private TaskManager taskManager;

@AfterClass
@Override
protected void springTestContextAfterTestClass() throws Exception {
Expand Down Expand Up @@ -118,7 +111,7 @@ public void test001BadImport() throws FileNotFoundException, SchemaException {
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, null, null, result);

AssertJUnit.assertNotNull(users);
AssertJUnit.assertEquals("Search retuned unexpected results: "+users, 2, users.size());
AssertJUnit.assertEquals("Search retuned unexpected results: "+users, 3, users.size());

}

Expand Down

0 comments on commit dc78de1

Please sign in to comment.