[prev in list] [next in list] [prev in thread] [next in thread]
List: opennms-cvs
Subject: [opennms-cvs] CVS: opennms/src/services/org/opennms/netmgt/collectd/mock TestAgentTest.java,1.3,1.4
From: Matt Brozowski <brozow () users ! sourceforge ! net>
Date: 2005-05-30 23:51:17
Message-ID: E1Dcu2P-0006uW-V3 () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/opennms/opennms/src/services/org/opennms/netmgt/collectd/mock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26553/src/services/org/opennms/netmgt/collectd/mock
Modified Files:
TestAgentTest.java TestAgent.java BulkPdu.java
Log Message:
Make sure V1 Agents don't respond to Bulk requests
Index: TestAgentTest.java
===================================================================
RCS file: /cvsroot/opennms/opennms/src/services/org/opennms/netmgt/collectd/mock/TestAgentTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestAgentTest.java 30 May 2005 20:36:35 -0000 1.3
+++ TestAgentTest.java 30 May 2005 23:51:15 -0000 1.4
@@ -163,8 +163,6 @@
// TODO simulate bad agents by returning data out of order
// TODO simulate bad agents by repeating same oid on getnext, bulk
- // TODO make sure v1 agent fails to respond to getBulk
-
public void testGet() {
GetPdu get = TestPdu.getGet();
get.addVarBind(zeroInst1Base, 0);
@@ -173,7 +171,28 @@
validateGetResponse(get, m_agent.send(get));
}
-
+
+ public void xtestGetTooBig() {
+ m_agent.setBehaviorToV1();
+ m_agent.setMaxResponseSize(5);
+ GetPdu get = TestPdu.getGet();
+ get.addVarBind(zeroInst1Base, 0);
+ get.addVarBind(zeroInst2Base, 0);
+ get.addVarBind(col1Base, 1);
+ get.addVarBind(col1Base, 2);
+ get.addVarBind(col1Base, 3);
+ get.addVarBind(col2Base, 1);
+ get.addVarBind(col2Base, 2);
+ get.addVarBind(col2Base, 3);
+ get.addVarBind(col3Base, 1);
+ get.addVarBind(col3Base, 2);
+ get.addVarBind(col3Base, 3);
+
+ ResponsePdu resp = m_agent.send(get);
+
+ assertEquals(ResponsePdu.TOO_BIG_ERR, resp.getErrorStatus());
+ }
+
public void testGetWithInvalidOidV1() {
m_agent.setBehaviorToV1();
@@ -386,7 +405,7 @@
validateBulkResponse(pdu, m_agent.send(pdu));
}
- public void xtestBulkInV1() {
+ public void testBulkInV1() {
try {
m_agent.setBehaviorToV1();
BulkPdu pdu = TestPdu.getBulk();
Index: TestAgent.java
===================================================================
RCS file: /cvsroot/opennms/opennms/src/services/org/opennms/netmgt/collectd/mock/TestAgent.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestAgent.java 30 May 2005 20:36:35 -0000 1.3
+++ TestAgent.java 30 May 2005 23:51:15 -0000 1.4
@@ -44,9 +44,9 @@
public class TestAgent {
- public static final Object NO_SUCH_INSTANCE = new Object() { public String \
toString() { return "NO_SUCH_INSTANCE"; } };
- public static final Object NO_SUCH_OBJECT = new Object() { public String \
toString() { return "NO_SUCH_OBJECT"; } };
- public static final Object END_OF_MIB = new Object() { public String toString() \
{ return "END_OF_MIB"; } }; + public static final Object NO_SUCH_INSTANCE = new \
Object() { public String toString() { return "noSuchInstance"; } }; + public \
static final Object NO_SUCH_OBJECT = new Object() { public String toString() { return \
"noSuchObect"; } }; + public static final Object END_OF_MIB = new Object() { \
public String toString() { return "endOfMibView"; } };
private TreeMap m_agentData;
private boolean isV1 = true;
@@ -125,7 +125,7 @@
}
Object handleNoSuchObject(SnmpObjId reqObjId, int errIndex) {
- if (isV1)
+ if (isVersion1())
throw new AgentNoSuchNameException(errIndex);
@@ -133,7 +133,7 @@
}
Object handleNoSuchInstance(SnmpObjId reqObjId, int errIndex) {
- if (isV1)
+ if (isVersion1())
throw new AgentNoSuchNameException(errIndex);
return NO_SUCH_INSTANCE;
@@ -163,7 +163,7 @@
}
private TestVarBind handleEndOfMib(SnmpObjId lastOid, int errIndex) {
- if (isV1)
+ if (isVersion1())
throw new AgentNoSuchNameException(errIndex);
return new TestVarBind(lastOid, END_OF_MIB);
@@ -174,6 +174,15 @@
return new TestVarBind(objId, value);
}
+ public boolean isVersion1() {
+ return isV1;
+ }
+
+ public void setMaxResponseSize(int i) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Index: BulkPdu.java
===================================================================
RCS file: /cvsroot/opennms/opennms/src/services/org/opennms/netmgt/collectd/mock/BulkPdu.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BulkPdu.java 30 May 2005 16:38:22 -0000 1.1
+++ BulkPdu.java 30 May 2005 23:51:15 -0000 1.2
@@ -54,4 +54,11 @@
public int getMaxRepititions() {
return m_maxRepititions;
}
+
+ public ResponsePdu send(TestAgent agent) {
+ if (agent.isVersion1())
+ throw new IllegalStateException("can't send a buld pack to a V1 Agent");
+
+ return super.send(agent);
+ }
}
\ No newline at end of file
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://wiki.opennms.org/tiki-index.php?page=MailingListFaq
opennms-cvs mailing list
To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic