当前位置: 首页>>代码示例>>Java>>正文


Java Query类代码示例

本文整理汇总了Java中net.i2cat.netconf.rpc.Query的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Query类属于net.i2cat.netconf.rpc包,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareMocks

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
private void prepareMocks() throws ProtocolException {
	mockProtocolSession = EasyMock.createMock(IProtocolSession.class);
	message = new Capture<Query>();
	mockProtocolSession.sendReceive(EasyMock.capture(message));
	EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
		public Object answer() throws Throwable {
			return null;
		}
	});

	mockProtocolSessionManager = EasyMock.createMock(IProtocolSessionManager.class);
	EasyMock.expect(mockProtocolSessionManager.getSessionById(EasyMock.anyObject(String.class), EasyMock.anyBoolean())).andReturn(
			mockProtocolSession);
	EasyMock.expect(mockProtocolSessionManager.obtainSessionByProtocol(EasyMock.anyObject(String.class), EasyMock.anyBoolean())).andReturn(
			mockProtocolSession);
	EasyMock.replay(mockProtocolSession);
	EasyMock.replay(mockProtocolSessionManager);
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:19,代码来源:VRRPActionTest.java

示例2: sendCloseSession

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
private void sendCloseSession() throws IOException {
	log.debug("Sending close session.");
	Query query = new Query();
	query.setMessageId("" + messageCounter++);
	query.setOperation(Operation.CLOSE_SESSION);
	sendQuery(query);
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:8,代码来源:NetconfProcessor.java

示例3: testBehaviours

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Test
public void testBehaviours() {
	Server server = Server.createServerStoringMessages(2222);

	// define behaviours
	Query bQuery = QueryFactory.newGetRouteInformation();
	Reply bReply = new Reply();
	Error error = ErrorFactory.newError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR, null, null, null, null);
	bReply.addError(error);
	Behaviour behaviour = new Behaviour(bQuery, bReply);
	server.defineBehaviour(behaviour);

	// start the server
	server.startServer();

	try {
		SessionContext sessionContext = new SessionContext();
		sessionContext.setURI(new URI("ssh://user:[email protected]:2222/"));

		INetconfSession session = new NetconfSession(sessionContext);

		session.connect();

		// send a message
		Query query = QueryFactory.newGetRouteInformation();
		Reply reply = session.sendSyncQuery(query);

		// assertions
		Assert.assertEquals("Reply must contain 1 error", 1, reply.getErrors().size());
		Assert.assertEquals("Reply error must be of 'type application'", ErrorType.APPLICATION, reply.getErrors().get(0).getType());
		Assert.assertEquals("Error tag must be 'operation-failed'", ErrorTag.OPERATION_FAILED, reply.getErrors().get(0).getTag());
		Assert.assertEquals("Error severity must be 'error'", ErrorSeverity.ERROR, reply.getErrors().get(0).getSeverity());
	} catch (Exception e) {
		Assert.fail("Error creating session: " + e.getMessage());
	} finally {
		server.stopServer();
	}
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:39,代码来源:TestServer.java

示例4: asyncSend

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Override
public void asyncSend(Object requestMessage) throws ProtocolException {
	// Send a message to the device, and don't wait for the response
	RPCElement rpcReply = null;
	try {
		Query rpcQuery = (Query) requestMessage;
		netconfSession.sendAsyncQuery(rpcQuery);
	} catch (Exception ex) {
		throw new ProtocolException(ex);
	}

}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:13,代码来源:NetconfProtocolSession.java

示例5: sendReceive

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Override
public Object sendReceive(Object requestMessage) throws ProtocolException {
	// Send a message to the device, and wait for the response
	RPCElement rpcReply = null;
	try {
		Query rpcQuery = (Query) requestMessage;
		rpcReply = netconfSession.sendSyncQuery(rpcQuery);
	} catch (Exception ex) {
		throw new ProtocolException(ex);
	}
	return rpcReply;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:13,代码来源:NetconfProtocolSession.java

示例6: testPrepareRestoreAction

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Test
public void testPrepareRestoreAction() throws Exception {
	String uri = System.getProperty("protocol.uri");

	if (uri == null || uri.equals("${protocol.uri}")) {
		uri = "mock://user:[email protected]:2212/mocksubsystem";
	}
	String compare = null;
	String toCompare = null;
	Query query = QueryFactory.newGetConfig("running", "<configuration></configuration>", null);
	Reply reply = sendNetconfMessage(query, uri);
	compare = reply.getContain();

	IAction action = new MockAction();
	action.setActionID("mockAction");
	queueManagerCapability.queueAction(action);
	action = new CorruptedAction();
	action.setActionID("corruptedAction");
	queueManagerCapability.queueAction(action);

	boolean isChecked = false;
	try {
		queueManagerCapability.execute();
	} catch (Exception e) {
		if (e instanceof CapabilityException)
			isChecked = true;
	}
	if (!uri.startsWith("mock:"))
		Assert.assertTrue(isChecked);

	reply = sendNetconfMessage(query, uri);
	toCompare = reply.getContain();

	Assert.assertEquals(compare, toCompare);
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:36,代码来源:PrepareCommitRollbackTest.java

示例7: sendNetconfMessage

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
public Reply sendNetconfMessage(Query query, String uri) throws Exception {
	SessionContext sessionContext = new SessionContext();
	sessionContext.setURI(new URI(uri));
	NetconfSession session = new NetconfSession(sessionContext);
	session.connect();
	Reply reply = session.sendSyncQuery(query);
	if (reply.containsErrors())
		throw new Exception();
	session.disconnect();
	return reply;

}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:13,代码来源:PrepareCommitRollbackTest.java

示例8: execute

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Override
public ActionResponse execute(IProtocolSessionManager protocolSessionManager) throws ActionException {
	Response response = null;
	try {

		/*
		 * IT INCLUDES AN ERROR IN THE MASK
		 */
		String netconfXML = "<configuration><interfaces>" +
				"<interface>" +
				"<name>fe-0/1/2</name>" +
				"<unit operation=\"replace\">" +
				"<name>2<name>" +
				"<family><inet><address>192.168.1.3/60</address></inet></family>" +
				"</unit>" +
				"</interface></interfaces></configuration>";

		NetconfProtocolSession protocol = (NetconfProtocolSession) protocolSessionManager.obtainSessionByProtocol("netconf", false);
		Query query = QueryFactory.newEditConfig("candidate", null, null, null, netconfXML);
		Reply reply = (Reply) protocol.sendReceive(query);

		// extra control, it checks if is not null the error list
		response = checkResponse(reply, query);
		validateResponse(response);

	} catch (ProtocolException e) {
		throw new ActionException(e);
	}

	ActionResponse actionResponse = new ActionResponse();
	actionResponse.setActionID(actionID);
	actionResponse.addResponse(response);
	return actionResponse;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:35,代码来源:CorruptedAction.java

示例9: sendFakeConfig

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
public void sendFakeConfig(Query configQuery) throws IOException {
	InputStream configFileIs = this.getClass().getResourceAsStream("/router_configs/router_config_A.xml");
	Reply reply = ReplyFactory.newGetConfigReply(configQuery, null, IOUtils.toString(configFileIs));
	sendReply(reply);
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:6,代码来源:NetconfProcessor.java

示例10: sendOk

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
private void sendOk(Query query) throws IOException {
	log.debug("Sending OK.");
	sendReply(ReplyFactory.newOk(query, null));
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:5,代码来源:NetconfProcessor.java

示例11: sendQuery

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
public void sendQuery(Query query) throws IOException {
	send(query.toXML());
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:4,代码来源:NetconfProcessor.java

示例12: getQuery

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
public Query getQuery() {
	return query;
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:4,代码来源:Behaviour.java

示例13: testConsumingBehaviours

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Test
public void testConsumingBehaviours() {
	Server server = Server.createServerStoringMessages(2222);

	// define behaviours
	Query bQuery = QueryFactory.newGetRouteInformation();
	Reply bReply = new Reply();
	Error error = ErrorFactory.newError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR, null, null, null, null);
	bReply.addError(error);
	Behaviour behaviour = new Behaviour(bQuery, bReply, true);
	server.defineBehaviour(behaviour);

	bQuery = QueryFactory.newDiscardChanges();
	bReply = ReplyFactory.newOk(bQuery, null);
	behaviour = new Behaviour(bQuery, bReply, true);
	server.defineBehaviour(behaviour);

	bQuery = QueryFactory.newGetRouteInformation();
	bReply = ReplyFactory.newOk(bQuery, null);
	behaviour = new Behaviour(bQuery, bReply, true);
	server.defineBehaviour(behaviour);

	// start the server
	server.startServer();

	try {
		SessionContext sessionContext = new SessionContext();
		sessionContext.setURI(new URI("ssh://user:[email protected]:2222/"));

		INetconfSession session = new NetconfSession(sessionContext);

		session.connect();

		// send first query
		Query query = QueryFactory.newGetRouteInformation();
		Reply reply = session.sendSyncQuery(query);

		// assertions
		Assert.assertEquals("Reply must contain 1 error", 1, reply.getErrors().size());
		Assert.assertEquals("Reply error must be of 'type application'", ErrorType.APPLICATION, reply.getErrors().get(0).getType());
		Assert.assertEquals("Error tag must be 'operation-failed'", ErrorTag.OPERATION_FAILED, reply.getErrors().get(0).getTag());
		Assert.assertEquals("Error severity must be 'error'", ErrorSeverity.ERROR, reply.getErrors().get(0).getSeverity());

		// send second query
		query = QueryFactory.newDiscardChanges();
		reply = session.sendSyncQuery(query);

		// assertions
		Assert.assertEquals("Reply must contain 0 errors", 0, reply.getErrors().size());
		Assert.assertEquals("Reply must be OK", true, reply.isOk());

		// send third query
		query = QueryFactory.newGetRouteInformation();
		reply = session.sendSyncQuery(query);

		// assertions
		Assert.assertEquals("Reply must contain 0 errors", 0, reply.getErrors().size());
		Assert.assertEquals("Reply must be OK", true, reply.isOk());

	} catch (Exception e) {
		Assert.fail("Error executing tests: " + e.getMessage());
	} finally {
		server.stopServer();
	}
}
 
开发者ID:dana-i2cat,项目名称:netconf-server,代码行数:66,代码来源:TestServer.java

示例14: message

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Override
public Query message() {
	// setQuery(QueryFactory.newGetInterfaceInformation());
	setQuery(QueryFactory.newGetConfig(source.toString(), netconfXML, attrFilter));
	return query;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:7,代码来源:GetNetconfCommand.java

示例15: message

import net.i2cat.netconf.rpc.Query; //导入依赖的package包/类
@Override
public Query message() {
	setQuery(QueryFactory.newLock(target));
	return query;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:6,代码来源:LockNetconfCommand.java


注:本文中的net.i2cat.netconf.rpc.Query类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。