當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。