Skip to content

Commit

Permalink
Test cleanup (possible fix for test deadlock)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Mar 10, 2017
1 parent f07569f commit 73526af
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 81 deletions.
Expand Up @@ -138,7 +138,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_WHITE_NAMESPACE = MidPointConstants.NS_RI;

// YELLOW dummy resource is the same as default one but with strong asIs administrativeStatus mapping
protected static final String RESOURCE_DUMMY_YELLOW_FILENAME = COMMON_DIR + "/resource-dummy-yellow.xml";
protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(COMMON_DIR, "resource-dummy-yellow.xml");
protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000704";
protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow";
protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI;
Expand All @@ -159,7 +159,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra
protected static final String RESOURCE_DUMMY_EMERALD_NAMESPACE = MidPointConstants.NS_RI;

// Black dummy resource for testing tolerant attributes
protected static final String RESOURCE_DUMMY_BLACK_FILENAME = COMMON_DIR + "/resource-dummy-black.xml";
protected static final File RESOURCE_DUMMY_BLACK_FILE = new File(COMMON_DIR, "resource-dummy-black.xml");
protected static final String RESOURCE_DUMMY_BLACK_OID = "10000000-0000-0000-0000-000000000305";
protected static final String RESOURCE_DUMMY_BLACK_NAME = "black";
protected static final String RESOURCE_DUMMY_BLACK_NAMESPACE = MidPointConstants.NS_RI;
Expand Down
Expand Up @@ -104,11 +104,6 @@ public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredM
protected ResourceType resourceDummyWhiteType;
protected PrismObject<ResourceType> resourceDummyWhite;

protected DummyResource dummyResourceYellow;
protected DummyResourceContoller dummyResourceCtlYellow;
protected ResourceType resourceDummyYellowType;
protected PrismObject<ResourceType> resourceDummyYellow;

protected DummyResource dummyResourceGreen;
protected DummyResourceContoller dummyResourceCtlGreen;
protected ResourceType resourceDummyGreenType;
Expand All @@ -119,11 +114,6 @@ public class AbstractInitializedModelIntegrationTest extends AbstractConfiguredM
protected ResourceType resourceDummyEmeraldType;
protected PrismObject<ResourceType> resourceDummyEmerald;

protected DummyResource dummyResourceBlack;
protected DummyResourceContoller dummyResourceCtlBlack;
protected ResourceType resourceDummyBlackType;
protected PrismObject<ResourceType> resourceDummyBlack;

protected DummyResource dummyResourceOrange;
protected DummyResourceContoller dummyResourceCtlOrange;
protected ResourceType resourceDummyOrangeType;
Expand Down Expand Up @@ -164,6 +154,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
dummyResourceCtlRed = initDummyResourcePirate(RESOURCE_DUMMY_RED_NAME,
RESOURCE_DUMMY_RED_FILE, RESOURCE_DUMMY_RED_OID, initTask, initResult);

initDummyResourcePirate(RESOURCE_DUMMY_YELLOW_NAME,
RESOURCE_DUMMY_YELLOW_FILE, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult);

initDummyResourcePirate(RESOURCE_DUMMY_BLACK_NAME,
RESOURCE_DUMMY_BLACK_FILE, RESOURCE_DUMMY_BLACK_OID, initTask, initResult);

dummyResourceCtlBlue = DummyResourceContoller.create(RESOURCE_DUMMY_BLUE_NAME, resourceDummyBlue);
dummyResourceCtlBlue.extendSchemaPirate();
dummyResourceBlue = dummyResourceCtlBlue.getDummyResource();
Expand All @@ -185,13 +181,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
resourceDummyWhiteType = resourceDummyWhite.asObjectable();
dummyResourceCtlWhite.setResource(resourceDummyWhite);

dummyResourceCtlYellow = DummyResourceContoller.create(RESOURCE_DUMMY_YELLOW_NAME, resourceDummyYellow);
dummyResourceCtlYellow.extendSchemaPirate();
dummyResourceYellow = dummyResourceCtlYellow.getDummyResource();
resourceDummyYellow = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_YELLOW_FILENAME, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult);
resourceDummyYellowType = resourceDummyYellow.asObjectable();
dummyResourceCtlYellow.setResource(resourceDummyYellow);

dummyResourceCtlGreen = DummyResourceContoller.create(RESOURCE_DUMMY_GREEN_NAME, resourceDummyGreen);
dummyResourceCtlGreen.extendSchemaPirate();
dummyResourceGreen = dummyResourceCtlGreen.getDummyResource();
Expand All @@ -206,13 +195,6 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
resourceDummyEmerald = importAndGetObjectFromFile(ResourceType.class, getResourceDummyEmeraldFile(), RESOURCE_DUMMY_EMERALD_OID, initTask, initResult);
resourceDummyEmeraldType = resourceDummyEmerald.asObjectable();
dummyResourceCtlEmerald.setResource(resourceDummyEmerald);

dummyResourceCtlBlack = DummyResourceContoller.create(RESOURCE_DUMMY_BLACK_NAME, resourceDummyBlack);
dummyResourceCtlBlack.extendSchemaPirate();
dummyResourceBlack = dummyResourceCtlBlack.getDummyResource();
resourceDummyBlack = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_BLACK_FILENAME, RESOURCE_DUMMY_BLACK_OID, initTask, initResult);
resourceDummyBlackType = resourceDummyBlack.asObjectable();
dummyResourceCtlBlack.setResource(resourceDummyBlack);

dummyResourceCtlOrange = DummyResourceContoller.create(RESOURCE_DUMMY_ORANGE_NAME, resourceDummyOrange);
dummyResourceCtlOrange.extendSchemaPirate();
Expand Down
Expand Up @@ -999,7 +999,8 @@ public void test150ModifyUserJackAssignYellowAccount() throws Exception {

// Check shadow
PrismObject<ShadowType> accountShadowYellow = getShadowModel(accountYellowOid);
assertAccountShadowModel(accountShadowYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyYellowType);
assertAccountShadowModel(accountShadowYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME,
getDummyResourceType(RESOURCE_DUMMY_YELLOW_NAME));
assertAdministrativeStatusEnabled(accountShadowYellow);
TestUtil.assertCreateTimestamp(accountShadowYellow, start, end);
assertEnableTimestampShadow(accountShadowYellow, start, end);
Expand Down Expand Up @@ -1108,7 +1109,8 @@ private void checkAdminStatusFor15x(PrismObject<UserType> user, boolean userStat
assertDisableReasonShadow(account, SchemaConstants.MODEL_DISABLE_REASON_EXPLICIT);
}

assertAccountShadowModel(accountYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME, resourceDummyYellowType);
assertAccountShadowModel(accountYellow, accountYellowOid, ACCOUNT_JACK_DUMMY_USERNAME,
getDummyResourceType(RESOURCE_DUMMY_YELLOW_NAME));
assertAdministrativeStatus(accountYellow, accountStatusYellow ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED);
if (!accountStatusYellow) {
assertDisableReasonShadow(accountYellow, SchemaConstants.MODEL_DISABLE_REASON_EXPLICIT);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2016 Evolveum
* Copyright (c) 2010-2017 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 @@ -64,13 +64,6 @@ public class TestConnectorMultiInstance extends AbstractConfiguredModelIntegrati

protected DummyResource dummyResourceYellow;
protected DummyResourceContoller dummyResourceCtlYellow;
protected ResourceType resourceDummyYellowType;
protected PrismObject<ResourceType> resourceDummyYellow;

protected DummyResource dummyResourceBlack;
protected DummyResourceContoller dummyResourceCtlBlack;
protected ResourceType resourceDummyBlackType;
protected PrismObject<ResourceType> resourceDummyBlack;

private String accountJackYellowOid;
private String initialConnectorStaticVal;
Expand All @@ -82,19 +75,10 @@ public class TestConnectorMultiInstance extends AbstractConfiguredModelIntegrati
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

dummyResourceCtlYellow = DummyResourceContoller.create(RESOURCE_DUMMY_YELLOW_NAME, resourceDummyYellow);
dummyResourceCtlYellow.extendSchemaPirate();
dummyResourceYellow = dummyResourceCtlYellow.getDummyResource();
resourceDummyYellow = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_YELLOW_FILENAME, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult);
resourceDummyYellowType = resourceDummyYellow.asObjectable();
dummyResourceCtlYellow.setResource(resourceDummyYellow);
dummyResourceCtlYellow = initDummyResourcePirate(RESOURCE_DUMMY_YELLOW_NAME, RESOURCE_DUMMY_YELLOW_FILE, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult);
dummyResourceYellow = dummyResourceCtlYellow.getDummyResource();

dummyResourceCtlBlack = DummyResourceContoller.create(RESOURCE_DUMMY_BLACK_NAME, resourceDummyBlack);
dummyResourceCtlBlack.extendSchemaPirate();
dummyResourceBlack = dummyResourceCtlBlack.getDummyResource();
resourceDummyBlack = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_BLACK_FILENAME, RESOURCE_DUMMY_BLACK_OID, initTask, initResult);
resourceDummyBlackType = resourceDummyBlack.asObjectable();
dummyResourceCtlBlack.setResource(resourceDummyBlack);
initDummyResourcePirate(RESOURCE_DUMMY_BLACK_NAME, RESOURCE_DUMMY_BLACK_FILE, RESOURCE_DUMMY_BLACK_OID, initTask, initResult);

repoAddObjectFromFile(USER_JACK_FILE, true, initResult);
repoAddObjectFromFile(USER_GUYBRUSH_FILE, true, initResult);
Expand Down Expand Up @@ -365,9 +349,9 @@ public void test200GuybrushAssignDummyBlack() throws Exception {
assertConnectorInstances("black", RESOURCE_DUMMY_BLACK_OID, 0, 1);
assertConnectorInstances("yellow", RESOURCE_DUMMY_YELLOW_OID, 0, 2);

assertConnectorToStringDifferent(shadowBlack, dummyResourceCtlBlack, initialConnectorStaticVal);
assertConnectorToStringDifferent(shadowBlack, dummyResourceCtlBlack, initialConnectorToString);
assertConnectorStaticVal(shadowBlack, dummyResourceCtlBlack, initialConnectorStaticVal);
assertConnectorToStringDifferent(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorStaticVal);
assertConnectorToStringDifferent(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorToString);
assertConnectorStaticVal(shadowBlack, getDummyResourceController(RESOURCE_DUMMY_BLACK_NAME), initialConnectorStaticVal);

}

Expand Down
Expand Up @@ -1523,7 +1523,7 @@ public void test382AddAccountYellow() throws Exception {
Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

ObjectDelta<UserType> userDelta = createModifyUserAddAccount(USER_JACK_OID, resourceDummyYellow);
ObjectDelta<UserType> userDelta = createModifyUserAddAccount(USER_JACK_OID, getDummyResourceObject(RESOURCE_DUMMY_YELLOW_NAME));

// WHEN
TestUtil.displayWhen(TEST_NAME);
Expand Down
Expand Up @@ -94,10 +94,10 @@ public class TestPreviewChanges extends AbstractInitializedModelIntegrationTest
public static final File TEST_DIR = new File("src/test/resources/preview");

// YELLOW dummy resource has a STRICT dependency on default dummy resource
protected static final File RESOURCE_DUMMY_YELLOW_FILE = new File(TEST_DIR, "resource-dummy-yellow.xml");
protected static final String RESOURCE_DUMMY_YELLOW_OID = "10000000-0000-0000-0000-000000000504";
protected static final String RESOURCE_DUMMY_YELLOW_NAME = "yellow";
protected static final String RESOURCE_DUMMY_YELLOW_NAMESPACE = MidPointConstants.NS_RI;
protected static final File RESOURCE_DUMMY_LEMON_FILE = new File(TEST_DIR, "resource-dummy-lemon.xml");
protected static final String RESOURCE_DUMMY_LEMON_OID = "10000000-0000-0000-0000-000000000504";
protected static final String RESOURCE_DUMMY_LEMON_NAME = "lemon";
protected static final String RESOURCE_DUMMY_LEMON_NAMESPACE = MidPointConstants.NS_RI;

private static final String USER_MORGAN_OID = "c0c010c0-d34d-b33f-f00d-171171117777";
private static final String USER_BLACKBEARD_OID = "c0c010c0-d34d-b33f-f00d-161161116666";
Expand All @@ -110,12 +110,8 @@ public class TestPreviewChanges extends AbstractInitializedModelIntegrationTest
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);

dummyResourceCtlYellow = DummyResourceContoller.create(RESOURCE_DUMMY_YELLOW_NAME, resourceDummyYellow);
dummyResourceCtlYellow.extendSchemaPirate();
dummyResourceYellow = dummyResourceCtlYellow.getDummyResource();
resourceDummyYellow = importAndGetObjectFromFile(ResourceType.class, RESOURCE_DUMMY_YELLOW_FILE, RESOURCE_DUMMY_YELLOW_OID, initTask, initResult);
resourceDummyYellowType = resourceDummyYellow.asObjectable();
dummyResourceCtlYellow.setResource(resourceDummyYellow);
initDummyResourcePirate(RESOURCE_DUMMY_LEMON_NAME,
RESOURCE_DUMMY_LEMON_FILE, RESOURCE_DUMMY_LEMON_OID, initTask, initResult);
}

@Test
Expand Down Expand Up @@ -1347,16 +1343,16 @@ public void test630AddUserRogers() throws Exception {
// administrativeStatus (ENABLED), enableTimestamp, ship (from organizationalUnit), name, gossip, water, iteration, iterationToken, password/value
PrismAsserts.assertModifications(accountSecondaryDelta, 9);
PrismAsserts.assertPropertyReplace(accountSecondaryDelta,
getAttributePath(resourceDummyYellow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME),
getAttributePath(getDummyResourceObject(RESOURCE_DUMMY_LEMON_NAME), DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME),
"The crew of The Sea Monkey");
PrismAsserts.assertPropertyReplace(accountSecondaryDelta,
new ItemPath(ShadowType.F_ATTRIBUTES, SchemaConstants.ICFS_NAME),
"rogers");
PrismAsserts.assertPropertyAdd(accountSecondaryDelta,
getAttributePath(resourceDummyYellow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME),
getAttributePath(getDummyResourceObject(RESOURCE_DUMMY_LEMON_NAME), DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME),
"Rum Rogers Sr. must be the best pirate the has ever seen");
PrismAsserts.assertPropertyReplace(accountSecondaryDelta,
getAttributePath(resourceDummyYellow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WATER_NAME),
getAttributePath(getDummyResourceObject(RESOURCE_DUMMY_LEMON_NAME), DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WATER_NAME),
"pirate Rum Rogers Sr. drinks only rum!");
}

Expand Down

0 comments on commit 73526af

Please sign in to comment.