[jboss-cvs] JBossAS SVN: r110477 - branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 27 16:51:38 EST 2011


Author: thauser at redhat.com
Date: 2011-01-27 16:51:38 -0500 (Thu, 27 Jan 2011)
New Revision: 110477

Modified:
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/test/Test.java
Log:
modify the Testing classes

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/test/Test.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/test/Test.java	2011-01-27 21:51:27 UTC (rev 110476)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/test/Test.java	2011-01-27 21:51:38 UTC (rev 110477)
@@ -47,94 +47,17 @@
 		else if (args[0].equals("testnullpdu")){
 			testnull();
 		}
-		else if (args[0].equals("snmpwalk")){
-			snmpwalk(args);
-		}
 		else 
 		{
 			System.out.println("*Usage*\n" +
 					           "<get/getnext> <oid>\n" +
 							   "<set> <oid> <value>\n" +
 							   "<getbulk> (test snmpReceivedGetBulk)\n" +
-							   "<testnullpdu> (test sending a null pdu)\n" +
-							   "<snmpwalk> <oid> (walk the tree from the given oid.");
+							   "<testnullpdu> (test sending a null pdu)\n");
 		
 			//improper action
 		}
 }	
-		public static void snmpwalk(String [] args){
-			PDU pdu = new PDU();
-			Vector<PDU> pduResp = new Vector<PDU>();
-
-			
-			CommunityTarget target = new CommunityTarget();
-			OctetString community = new OctetString("public");
-			target.setCommunity(community);
-			target.setVersion(SnmpConstants.version2c);
-			Address targetAddress = GenericAddress.parse("udp:127.0.0.1/1161");
-			target.setAddress(targetAddress);
-			target.setRetries(0);
-			target.setTimeout(2000);
-			
-     		pdu.setType(PDU.GETNEXT);
-
-			// initiate parallell walk.
-			for (int i = 1; i < args.length; i++){ //walk each OID.
-				OID treeOID = new OID (args[i]);
-				OID currentOID = new OID(treeOID);
-				
-				// construct the PDU with all values required
-				while (currentOID.leftMostCompare(treeOID.getValue().length, treeOID)==0){
-					pdu.add(new VariableBinding(currentOID));
-					try {
-						DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping();
-						transport.listen();
-						Snmp snmp = new Snmp(transport);
-						
-						System.out.println("Sending PDU: "+pdu);
-						ResponseEvent responseEvent = snmp.send(pdu, target);
-						PDU responsePDU = responseEvent.getResponse();
-						if (responsePDU == null){
-							System.out.println("Request timed out");
-						}
-						else{
-							if (responsePDU.getErrorStatus()!= 0){
-								System.out.println("Received error response: " + responsePDU);
-								pdu.clear();
-								return;
-							}
-						pduResp.add(new PDU(responsePDU));
-						//	System.out.println("Received response "+responsePDU);
-						}	
-						Vector<VariableBinding> vbs = responsePDU.getVariableBindings();
-						currentOID = vbs.get(0).getOid();
-						responsePDU = null;
-						pdu.clear();
-					} catch (UnknownHostException e1) {
-					// 	TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (IOException e1) {
-					// 	TODO Auto-generated catch block
-						e1.printStackTrace();
-					} catch (Exception e) {
-						
-						System.out.println("Some Other exception!!");
-						System.out.println(e);
-					}
-					
-					
-				}
-			}
-			for (PDU response : pduResp){
-				System.out.println("Results of snmpwalk: " + response);
-			}
-			
-			
-
-	}
-	
-	
-	
 	   public static void getbulk(){
 			PDU pdu = new PDU();
 			pdu.setType(PDU.GETBULK);



More information about the jboss-cvs-commits mailing list