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


Java Component.stop方法代码示例

本文整理汇总了Java中org.restlet.Component.stop方法的典型用法代码示例。如果您正苦于以下问题:Java Component.stop方法的具体用法?Java Component.stop怎么用?Java Component.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.Component的用法示例。


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

示例1: testListPaging

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testListPaging() throws Exception {
	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupAppPaging());
	component.start();

	try {
		Client client = new Client(Protocol.HTTP);

		long count = getCount(client, "READY");
		assertEquals(pagingTotal, count);

		Collection<FileTrackingStatus> statusObjColl = getStatusObject(
				client, "READY", 0, 30);

		assertEquals(30, statusObjColl.size());
	} finally {
		component.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:23,代码来源:TestFileTrackerStatusResource.java

示例2: testGetsStatus

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testGetsStatus() throws Exception {
	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupApp());
	component.start();

	try {
		Client client = new Client(Protocol.HTTP);
		
		for(File file: Arrays.asList(new File("test1.txt"), new File("test2.txt"), new File("test3.txt"))){
		
			FileTrackingStatus status = getStatusObject(client, file.getAbsolutePath());
			
			assertNotNull(status);
			assertEquals(file.getAbsolutePath(), status.getPath());
			
		}
		
	} finally {
		component.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:25,代码来源:TestFileTrackerStatusPathResource.java

示例3: testPingCheckOK

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * Tests that the PingCheck does not through errors when the ping service is
 * running
 * 
 * @throws Exception
 */
@Test
public void testPingCheckOK() throws Exception {

	Component pingComp = (Component) bootstrap
			.getBean("restletPingComponent");

	pingComp.start();
	try {

		PingCheck pingCheck = bootstrap.getBean(PingCheck.class);

		pingCheck.runCheck();
		assertTrue(true);

	} catch (Throwable t) {
		t.printStackTrace();
		assertTrue(false);
	} finally {
		pingComp.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:29,代码来源:TestPingCheck.java

示例4: testCountAllHttp

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testCountAllHttp() throws Exception {

	final CountCommand countCmd = new CountCommand(createMemory(), null,
			null);

	Bootstrap bootstrap = new Bootstrap();
	bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.REST_CLIENT,
			CommandLineProcessorFactory.PROFILE.CLI,
			CommandLineProcessorFactory.PROFILE.DB,
			CommandLineProcessorFactory.PROFILE.AGENT);

	Component comp = bootstrap.getBean(Component.class);

	CommandLineParser parser = bootstrap
			.agentCommandLineParser(new CommandLineProcessorFactory() {

				@Override
				public CommandLineProcessor create(String name,
						PROFILE... profiles) {
					return countCmd;
				}

			});

	try {
		comp.start();
		validateCount(parser, fileCount, null, true);
	} finally {
		comp.stop();
		while(! (comp.isStopped() ) ){
			Thread.sleep(1000);
			System.out.println("Waiting for http server to shutdown");
		}
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:TestCountCommand.java

示例5: testCountStatusHttp

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testCountStatusHttp() throws Exception {

	final CountCommand countCmd = new CountCommand(createMemory(), null,
			null);

	Bootstrap bootstrap = new Bootstrap();
	bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.REST_CLIENT,
			CommandLineProcessorFactory.PROFILE.CLI,
			CommandLineProcessorFactory.PROFILE.DB,
			CommandLineProcessorFactory.PROFILE.AGENT);

	Component comp = bootstrap.getBean(Component.class);

	CommandLineParser parser = bootstrap
			.agentCommandLineParser(new CommandLineProcessorFactory() {

				@Override
				public CommandLineProcessor create(String name,
						PROFILE... profiles) {
					return countCmd;
				}

			});

	try {
		comp.start();
		validateCount(parser, fileCount / 2, "READY", true);
	} finally {
		comp.stop();
		while(! (comp.isStopped() ) ){
			Thread.sleep(1000);
			System.out.println("Waiting for http server to shutdown");
		}
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:38,代码来源:TestCountCommand.java

示例6: testListReady

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * Test that we can find all of the ready objects
 * @throws Exception
 */
@Test
public void testListReady() throws Exception {

	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupApp());
	component.start();
	try {

		Client client = new Client(Protocol.HTTP);
		ObjectMapper om = new ObjectMapper();

		Collection<FileTrackingStatus> statusObjColl = getStatusObject(	client, "READY", -1, -1);
		assertNotNull(statusObjColl);

		assertEquals(totalReady, statusObjColl.size());
		Iterator<FileTrackingStatus> it = statusObjColl.iterator();
		
		while(it.hasNext()){
		FileTrackingStatus statusObj = om.convertValue(it.next(), FileTrackingStatus.class);

			assertEquals("READY", statusObj.getStatus().toString()
					.toUpperCase());
		}
	} finally {
		component.stop();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:33,代码来源:TestFileTrackerStatusResourceByStatus.java

示例7: testLSCommandFilterQueryPagingRest

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * This test runs the LSCommand via the Resource and not via the -o option.<br/>
 * The LSCommand should print out a line for each of the FileTrackingStatus
 * in the memory filtered by READY by using a query string and paged at 0 to
 * 10.<br/>
 * 
 * @throws Exception
 */
@Test
public void testLSCommandFilterQueryPagingRest() throws Exception {

	Bootstrap bootstrap = new Bootstrap();

	bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.DB,
			CommandLineProcessorFactory.PROFILE.REST_CLIENT,
			CommandLineProcessorFactory.PROFILE.AGENT);
	bootstrap.printBeans();

	// setup resource
	Component component = (Component) bootstrap.getBean("restletComponent");
	component.start();

	// set the memory used in this test to the FileTrackingStatusResource
	FileTrackingStatusResource resource = (FileTrackingStatusResource) bootstrap
			.getBean(FileTrackingStatusResource.class);
	resource.setMemory(createMemory());

	try {
		// get client and create LSCommand
		// use DI to test the correct configuration and restlet client is
		// returned
		Configuration conf = bootstrap.getBean(Configuration.class);
		org.restlet.Client client = bootstrap
				.getBean(org.restlet.Client.class);
		final LSCommand lsCmd = new LSCommand(null, client, conf);

		CommandLineParser parser = new AgentCommandLineParser(
				new CommandLineProcessorFactory() {

					@Override
					public CommandLineProcessor create(String name,
							PROFILE... profiles) {
						return lsCmd;
					}

				});

		Map<String, FileTrackingStatus> statusMap = new HashMap<String, FileTrackingStatus>();

		String query = "status='READY'";
		doPaging(statusMap, parser, 0, 10, query, false);
		doPaging(statusMap, parser, 11, 10, query, false);

	} finally {
		component.stop();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:58,代码来源:TestLSCommand.java

示例8: testWithStatusNotFoundRest

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * 
 * Count all
 * 
 * @throws Exception
 */
@Test
public void testWithStatusNotFoundRest() throws Exception {

	Bootstrap bootstrap = new Bootstrap();

	bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.REST_CLIENT, CommandLineProcessorFactory.PROFILE.DB, CommandLineProcessorFactory.PROFILE.AGENT);
	
	// setup resource
	Component component = bootstrap.getBean(Component.class);
	component.start();

	// set the memory used in this test to the FileTrackingStatusResource
	FileTrackingStatusPathResource resource = bootstrap
			.getBean(FileTrackingStatusPathResource.class);
	resource.setMemory(createMemory());

	try {
		// get client and create LSCommand
		// use DI to test the correct configuration and restlet client is
		// returned
		Configuration conf = bootstrap.getBean(Configuration.class);
		org.restlet.Client client = bootstrap
				.getBean(org.restlet.Client.class);

		final StatusCommand statusCmd = new StatusCommand(createMemory(), client,
				conf);

		
		CommandLineParser parser = new AgentCommandLineParser(
				new CommandLineProcessorFactory() {

					@Override
					public CommandLineProcessor create(String name,
							PROFILE... profiles) {
						return statusCmd;
					}

				});


		ByteArrayOutputStream out = new ByteArrayOutputStream();

		//we expect a FileNotFoundException to be thrown here.
		try{
			parser.parse(out, new String[] { "-status", "nofile" });
			assertTrue(false);
		}catch(FileNotFoundException fnfExcp){
			assertTrue(true);
		}
		

	} finally {
		component.stop();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:62,代码来源:TestStatusCommand.java

示例9: testWithStatusRest

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * 
 * Count all
 * 
 * @throws Exception
 */
@Test
public void testWithStatusRest() throws Exception {

	Bootstrap bootstrap = new Bootstrap();

	bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.REST_CLIENT, CommandLineProcessorFactory.PROFILE.DB, CommandLineProcessorFactory.PROFILE.AGENT);
	
	// setup resource
	Component component = bootstrap.getBean(Component.class);
	component.start();

	// set the memory used in this test to the FileTrackingStatusResource
	FileTrackingStatusPathResource resource = bootstrap
			.getBean(FileTrackingStatusPathResource.class);
	resource.setMemory(createMemory());

	try {
		// get client and create LSCommand
		// use DI to test the correct configuration and restlet client is
		// returned
		Configuration conf = bootstrap.getBean(Configuration.class);
		org.restlet.Client client = bootstrap
				.getBean(org.restlet.Client.class);

		final StatusCommand statusCmd = new StatusCommand(createMemory(), client,
				conf);

		CommandLineParser parser = new AgentCommandLineParser(
				new CommandLineProcessorFactory() {

					@Override
					public CommandLineProcessor create(String name,
							PROFILE... profiles) {
						return statusCmd;
					}

				});

		ByteArrayOutputStream out = new ByteArrayOutputStream();

		parser.parse(out, new String[] { "-status", testFileReadyPath });

		BufferedReader reader = new BufferedReader(new InputStreamReader(
				new ByteArrayInputStream(out.toByteArray())));

		String line = reader.readLine();
		assertNotNull(line);
		System.out.println("testFileReadyPath:" + testFileReadyPath);
		System.out.println("Line: " + line);
		assertTrue(line.contains(testFileReadyPath));

		FileTrackingStatus file = new FileTrackingStatusFormatter().read(
				FileTrackingStatusFormatter.FORMAT.TXT, line);

		assertNotNull(file);

		// no new lines expected
		assertNull(reader.readLine());

	} finally {
		component.stop();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:70,代码来源:TestStatusCommand.java

示例10: testList

import org.restlet.Component; //导入方法依赖的package包/类
/**
 * Test end to end of the FileTrackingStatusResource.
 * 
 * @throws Exception
 */
@Test
public void testList() throws Exception {

	Component component = new Component();
	component.getServers().add(Protocol.HTTP, port);
	component.getDefaultHost().attach(setupApp());
	component.start();
	try {

		Client client = new Client(Protocol.HTTP);

		String[] statusArr = new String[] { "READY", "READING", "DONE" };
		String[] fileNamesArr = new String[] { "test1.txt", "test2.txt",
				"test3.txt" };
		String[] logTypesArr = new String[] { "testType1", "testType2",
				"testType3" };

		int counter = 0;

		ObjectMapper om = new ObjectMapper();
		for (String status : statusArr) {

			Collection<FileTrackingStatus> statusObjColl = getStatusObject(
					client, status, -1, -1);
			assertNotNull(statusObjColl);

			assertEquals(1, statusObjColl.size());

			FileTrackingStatus statusObj = om.convertValue(statusObjColl
					.iterator().next(), FileTrackingStatus.class);

			assertEquals(status, statusObj.getStatus().toString()
					.toUpperCase());
			assertEquals(fileNamesArr[counter], statusObj.getPath());
			assertEquals(1L, statusObj.getLastModificationTime());
			assertEquals(3, statusObj.getLinePointer());
			assertEquals(4L, statusObj.getFilePointer());
			assertEquals(logTypesArr[counter], statusObj.getLogType());

			counter++;
		}
	} finally {
		component.stop();
	}
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:51,代码来源:TestFileTrackerStatusResource.java

示例11: stop

import org.restlet.Component; //导入方法依赖的package包/类
static void stop( String[] args ) throws Exception
{
	Component component = InstanceUtil.getComponent();
	if( component != null )
		component.stop();
}
 
开发者ID:tliron,项目名称:prudence,代码行数:7,代码来源:PrudenceDaemon.java

示例12: testPingResource

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testPingResource() throws Exception{
	
	Configuration conf = bootstrap.getBean(Configuration.class);
	
	int pingport = conf.getInt(
			CollectorProperties.WRITER.PING_PORT.toString(),
			(Integer)CollectorProperties.WRITER.PING_PORT.getDefaultValue()
			);
	
	Component pingComp = (Component)bootstrap.getBean("restletPingComponent");
	
	pingComp.start();
	try{
		
		
		Client client = bootstrap.getBean(Client.class);
		
		Response resp = client.get("http://localhost:" + pingport);
		
		assertNotNull(resp);
		assertTrue(resp.getStatus().isSuccess());
		assertNotNull(resp.getEntityAsText());
		
	}finally{
		pingComp.stop();
	}
	
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:30,代码来源:TestPingOKResource.java

示例13: testCollectorStatus

import org.restlet.Component; //导入方法依赖的package包/类
@Test
public void testCollectorStatus() throws Exception {

	Configuration conf = bootstrap.getBean(Configuration.class);

	int port = conf.getInt(CollectorProperties.WRITER.COLLECTOR_MON_PORT
			.toString(),
			(Integer) CollectorProperties.WRITER.COLLECTOR_MON_PORT
					.getDefaultValue());

	Component pingComp = (Component) bootstrap.getBean("restletComponent");

	pingComp.start();

	try {

		Client client = bootstrap.getBean(Client.class);

		Response resp = client.get("http://localhost:" + port
				+ "/collector/status");

		assertNotNull(resp);
		assertTrue(resp.getStatus().isSuccess());

		String entity = resp.getEntityAsText();

		assertNotNull(entity);

		ObjectMapper objMapper = new ObjectMapper();
		System.out.println("Status: " + entity);
		
		CollectorStatus status = objMapper.readValue(entity,
				CollectorStatusImpl.class);

		assertNotNull(status);

	} finally {
		pingComp.stop();
	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:42,代码来源:TestCollectorResource.java


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