java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java | 8 +
java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java | 7 -
java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java | 22 ++++-
java/code/src/com/redhat/rhn/domain/server/test/ServerGroupTest.java | 44
+++-------
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 16 ---
java/code/src/com/redhat/rhn/testing/ServerGroupTestUtils.java | 1
6 files changed, 46 insertions(+), 52 deletions(-)
New commits:
commit d6f6cea0cc6e3d4e4be88daa3aabf222be15ff76
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Jun 29 15:32:06 2010 -0400
Fixed fve unit tests Hopefully...
diff --git a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
index a361e7d..d5d012c 100644
--- a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
+++ b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
@@ -36,6 +36,7 @@ import com.redhat.rhn.domain.user.legacy.UserImpl;
import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.UserTestUtils;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -218,9 +219,9 @@ public class AccessTest extends RhnBaseTestCase {
Server s = ServerFactoryTest.createTestServer(user, false,
ServerConstants.getServerGroupTypeMonitoringEntitled());
context.put("sid", new String[] {s.getId().toString()});
- boolean rc = acl.evalAcl(context,
"system_feature(ftr_package_remove)");
+ boolean rc = acl.evalAcl(context, "system_feature(ftr_config)");
assertFalse(rc);
- rc = acl.evalAcl(context, "not system_feature(ftr_package_remove)");
+ rc = acl.evalAcl(context, "not system_feature(ftr_config)");
assertTrue(rc);
}
@@ -235,7 +236,8 @@ public class AccessTest extends RhnBaseTestCase {
context.put("user", user);
assertTrue(acl.evalAcl(context,
"system_has_management_entitlement()"));
- s = ServerFactoryTest.createTestServer(user, true);
+ s = ServerFactoryTest.createUnentitledTestServer(user, true,
+ ServerFactoryTest.TYPE_SERVER_NORMAL, new Date());
context.put("sid", new String[] {s.getId().toString()});
assertFalse(acl.evalAcl(context,
"system_has_management_entitlement()"));
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
index c2b2b17..ab6920c 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/HostBuilder.java
@@ -22,6 +22,7 @@ import com.redhat.rhn.domain.server.VirtualInstance;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.manager.entitlement.EntitlementManager;
import com.redhat.rhn.manager.system.SystemManager;
+import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.TestUtils;
import org.hibernate.Session;
@@ -173,14 +174,14 @@ public class HostBuilder {
if (register) {
guest = ServerFactoryTest.createUnentitledTestServer(owner, true,
- ServerFactoryTest.TYPE_SERVER_NORMAL , new Date());
+ ServerFactoryTest.TYPE_SERVER_NORMAL, new Date());
+ RhnBaseTestCase.assertNotNull(guest);
virtualInstance.setGuestSystem(guest);
}
if (host != null) {
host.addGuest(virtualInstance);
- TestUtils.saveAndFlush(host);
+ HibernateFactory.getSession().save(host);
}
- TestUtils.saveAndFlush(guest);
guests.add(virtualInstance);
}
return guests;
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
index 42ef538..30e2c0b 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/ServerFactoryTest.java
@@ -53,6 +53,7 @@ import com.redhat.rhn.domain.server.UndefinedCustomDataKeyException;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
import com.redhat.rhn.manager.entitlement.EntitlementManager;
+import com.redhat.rhn.manager.org.UpdateOrgSystemEntitlementsCommand;
import com.redhat.rhn.manager.rhnset.RhnSetDecl;
import com.redhat.rhn.manager.rhnset.RhnSetManager;
import com.redhat.rhn.manager.system.ServerGroupManager;
@@ -548,9 +549,26 @@ public class ServerFactoryTest extends RhnBaseTestCase {
Server newS = createUnentitledTestServer(owner, ensureOwnerAccess, stype,
dateCreated);
-
+
if (!type.getAssociatedEntitlement().isBase()) {
- SystemManager.entitleServer(newS, EntitlementManager.MANAGEMENT);
+ EntitlementServerGroup mgmt = ServerGroupFactory.lookupEntitled(
+ EntitlementManager.MANAGEMENT, owner.getOrg());
+ if (mgmt == null) {
+ assertNull(new UpdateOrgSystemEntitlementsCommand(
+ EntitlementManager.MANAGEMENT, owner.getOrg(), 10L).store());
+ newS = (Server)TestUtils.saveAndReload(newS);
+ mgmt = ServerGroupFactory.lookupEntitled(
+ EntitlementManager.MANAGEMENT,
+ owner.getOrg());
+ newS = ServerFactory.lookupById(newS.getId());
+ }
+ assertNotNull(mgmt);
+ assertNotNull(mgmt.getMaxMembers());
+ assertTrue(mgmt.getMaxMembers() > 0);
+ assertTrue(mgmt.getMaxMembers() - mgmt.getCurrentMembers() > 0);
+ assertNotNull(mgmt.getGroupType().getAssociatedEntitlement());
+ SystemManager.entitleServer(newS,
+ mgmt.getGroupType().getAssociatedEntitlement());
}
diff --git a/java/code/src/com/redhat/rhn/domain/server/test/ServerGroupTest.java
b/java/code/src/com/redhat/rhn/domain/server/test/ServerGroupTest.java
index 10a13b7..f597748 100644
--- a/java/code/src/com/redhat/rhn/domain/server/test/ServerGroupTest.java
+++ b/java/code/src/com/redhat/rhn/domain/server/test/ServerGroupTest.java
@@ -14,8 +14,6 @@
*/
package com.redhat.rhn.domain.server.test;
-import com.redhat.rhn.common.db.datasource.ModeFactory;
-import com.redhat.rhn.common.db.datasource.WriteMode;
import com.redhat.rhn.common.hibernate.HibernateFactory;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.role.RoleFactory;
@@ -25,6 +23,7 @@ import com.redhat.rhn.domain.server.ServerGroup;
import com.redhat.rhn.domain.server.ServerGroupFactory;
import com.redhat.rhn.domain.server.ServerGroupType;
import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.manager.org.UpdateOrgSystemEntitlementsCommand;
import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.ServerGroupTestUtils;
import com.redhat.rhn.testing.TestUtils;
@@ -32,16 +31,12 @@ import com.redhat.rhn.testing.UserTestUtils;
import org.hibernate.Session;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* ServerGroupTest
* @version $Rev$
*/
public class ServerGroupTest extends RhnBaseTestCase {
-
+ public static final long DEFAULT_MAX_MEMBERS = 10;
public void testEquals() throws Exception {
User user = UserTestUtils.findNewUser("testUser",
"testorg");
@@ -85,37 +80,28 @@ public class ServerGroupTest extends RhnBaseTestCase {
return existingGroup;
}
else {
- EntitlementServerGroup group = new EntitlementServerGroup();
- group.setMaxMembers(new Long(10));
- group.setName(typeIn.getName());
- group.setDescription(typeIn.getName());
- group.setOrg(org);
- ServerGroupFactory.save(group);
- return updateGroupType(group, typeIn);
+ assertNull(new UpdateOrgSystemEntitlementsCommand(
+ typeIn.getAssociatedEntitlement(), org,
+ DEFAULT_MAX_MEMBERS).store());
+ EntitlementServerGroup group = ServerGroupFactory.lookupEntitled(
+ typeIn.getAssociatedEntitlement(), org);
+ assertNotNull(group);
+ assertNotNull(group.getMaxMembers());
+ assertTrue(group.getMaxMembers() > 0);
+ assertTrue(group.getMaxMembers() - group.getCurrentMembers() > 0);
+ assertNotNull(group.getGroupType().getAssociatedEntitlement());
+ return group;
}
}
- ManagedServerGroup sg = ServerGroupFactory.create("NewGroup",
+ ManagedServerGroup sg = ServerGroupFactory.create("NewGroup" +
+ TestUtils.randomString(),
"RHN Managed
Group",
org);
assertNotNull(sg.getId());
return sg;
}
-
- private static EntitlementServerGroup updateGroupType(EntitlementServerGroup sg,
- ServerGroupType type)
- throws SQLException {
-
- WriteMode m = ModeFactory.getWriteMode("test_queries",
- "update_group_type");
- Map params = new HashMap();
- params.put("sgid", sg.getId());
- params.put("type_id", type.getId());
- m.executeUpdate(params);
- return (EntitlementServerGroup) TestUtils.reload(sg);
- }
-
public void testGetServerGroupTypeFeatures() throws Exception {
Org org1 = UserTestUtils.findNewOrg("testOrg");
assertTrue(org1.getEntitledServerGroups().size() > 0);
diff --git a/java/code/src/com/redhat/rhn/testing/ServerGroupTestUtils.java
b/java/code/src/com/redhat/rhn/testing/ServerGroupTestUtils.java
index 4cc15e2..f42ccb4 100644
--- a/java/code/src/com/redhat/rhn/testing/ServerGroupTestUtils.java
+++ b/java/code/src/com/redhat/rhn/testing/ServerGroupTestUtils.java
@@ -74,5 +74,4 @@ public class ServerGroupTestUtils {
create(user, NAME + TestUtils.randomString(),
DESCRIPTION);
}
-
}
commit e5f2554bbc97d6892f8ddad781bc839852c68017
Author: Partha Aji <paji(a)redhat.com>
Date: Tue Jun 29 13:45:45 2010 -0400
Fixed a dupe key issue
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index b317046..499fca3 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4487,6 +4487,7 @@ button below, and <b>will be unable to log back
in</b>.</source>
<source>Regular Usage</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
</context-group>
</trans-unit>
<trans-unit id="Flex Counts">
@@ -4500,6 +4501,7 @@ button below, and <b>will be unable to log back
in</b>.</source>
<source>Flex Usage</source>
<context-group name="ctx">
<context
context-type="sourcefile">/rhn/admin/multiorg/SoftwareEntitlements</context>
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
</context-group>
</trans-unit>
@@ -4602,13 +4604,6 @@ deducted from the default organization.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
</context-group>
</trans-unit>
-
- <trans-unit id="Regular Usage">
-<source>Regular Usage</source>
- <context-group name="ctx">
- <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
- </context-group>
- </trans-unit>
<trans-unit id="Regular Proposed Total">
<source>Regular Proposed Total</source>
@@ -4617,13 +4612,6 @@ deducted from the default organization.</source>
</context-group>
</trans-unit>
- <trans-unit id="Flex Usage">
-<source>Flex Usage</source>
- <context-group name="ctx">
- <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
- </context-group>
- </trans-unit>
-
<trans-unit id="Flex Proposed Total">
<source>Flex Proposed Total</source>
<context-group name="ctx">