summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevan Goodwin <dgoodwin@redhat.com>2009-11-03 12:04:53 -0400
committerDevan Goodwin <dgoodwin@redhat.com>2009-11-03 12:04:53 -0400
commit76ff79cad1f44a193356f9c456053eda599a088c (patch)
treea9c2461a7625366858c0e31fade6fe8ff0870cd6
parent700733cb5b7055006918ad680090a0b842d4e133 (diff)
downloadcobbler-76ff79cad1f44a193356f9c456053eda599a088c.tar.gz
cobbler-76ff79cad1f44a193356f9c456053eda599a088c.tar.xz
cobbler-76ff79cad1f44a193356f9c456053eda599a088c.zip
cobbler4j: Testing new object defaults.
This is just testing the behavior, which isn't optimal. Just a fact of life, at least for now.
-rw-r--r--cobbler4j/src/org/fedorahosted/cobbler/CobblerObject.java26
-rw-r--r--cobbler4j/src/org/fedorahosted/cobbler/test/RepoTests.java10
2 files changed, 21 insertions, 15 deletions
diff --git a/cobbler4j/src/org/fedorahosted/cobbler/CobblerObject.java b/cobbler4j/src/org/fedorahosted/cobbler/CobblerObject.java
index 5f5cf421..b177e82d 100644
--- a/cobbler4j/src/org/fedorahosted/cobbler/CobblerObject.java
+++ b/cobbler4j/src/org/fedorahosted/cobbler/CobblerObject.java
@@ -15,14 +15,9 @@
package org.fedorahosted.cobbler;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.lang.reflect.Constructor;
@@ -54,12 +49,7 @@ public abstract class CobblerObject {
}
}
- /**
- * @return the name
- */
- public String getName() {
- return (String)dataMap.get(NAME);
- }
+ public abstract String getName();
/**
* Helper method used by all cobbler objects to
@@ -165,6 +155,12 @@ public abstract class CobblerObject {
return getObjectType() + "\n" + dataMap.toString();
}
+ /**
+ * Commit this object to the cobbler server.
+ *
+ * If this object is new, it will be created, otherwise an edit will be
+ * performed.
+ */
public void commit() {
// Old way:
//client.invokeMethod("commit_" + getObjectType().getName(), getHandle(),
@@ -177,7 +173,7 @@ public abstract class CobblerObject {
newObject = false;
}
else {
- client.invokeMethod("xapi_object_edit", getObjectType().getName(),
+ client.invokeMethod("xapi_object_edit", getObjectType().getName(),
getName(), "edit", dataMap);
}
}
@@ -203,15 +199,15 @@ public abstract class CobblerObject {
Map<String, Object> dataMap) {
try
{
- Constructor ctor = type.getObjectClass().getConstructor(
+ Constructor<CobblerObject> ctor = type.getObjectClass().getConstructor(
new Class [] {CobblerConnection.class, Map.class});
- CobblerObject obj = (CobblerObject) ctor.newInstance(
+ CobblerObject obj = ctor.newInstance(
new Object [] {client, dataMap});
return obj;
}
catch(Exception e) {
- throw new XmlRpcException("Class instantiation expcetion.", e);
+ throw new XmlRpcException("Class instantiation exception.", e);
}
}
}
diff --git a/cobbler4j/src/org/fedorahosted/cobbler/test/RepoTests.java b/cobbler4j/src/org/fedorahosted/cobbler/test/RepoTests.java
index b239b99a..ba393642 100644
--- a/cobbler4j/src/org/fedorahosted/cobbler/test/RepoTests.java
+++ b/cobbler4j/src/org/fedorahosted/cobbler/test/RepoTests.java
@@ -71,5 +71,15 @@ public class RepoTests extends Fixture {
ObjectType.REPO, TEST_REPO_NAME);
assertTrue(lookedUp.getKeepUpdated());
}
+
+ @Test
+ public void testUnsetParamsOnNewRepo() {
+ // Testing behavior here, new objects don't have default attributes set
+ // in the java object they were created from.
+ Repo lookedUp = (Repo)finder.findItemByName(xmlrpc,
+ ObjectType.REPO, TEST_REPO_NAME);
+ assertNull(testRepo.getPriority());
+ assertEquals(new Integer(99), lookedUp.getPriority());
+ }
}