當前位置: 首頁>>代碼示例>>Java>>正文


Java SerializerUtil.serializeECSpec方法代碼示例

本文整理匯總了Java中org.fosstrak.ale.util.SerializerUtil.serializeECSpec方法的典型用法代碼示例。如果您正苦於以下問題:Java SerializerUtil.serializeECSpec方法的具體用法?Java SerializerUtil.serializeECSpec怎麽用?Java SerializerUtil.serializeECSpec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.fosstrak.ale.util.SerializerUtil的用法示例。


在下文中一共展示了SerializerUtil.serializeECSpec方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testReadECSpecs

import org.fosstrak.ale.util.SerializerUtil; //導入方法依賴的package包/類
/**
 * test the creation of persisted ECSpecs.
 * @throws Exception test failure.
 */
@Test
public void testReadECSpecs() throws Exception {
	tempFolder.create();
	File f = tempFolder.newFile("ecspec.xml");
	final String fileName = f.getName();
	// absolute path encodes the filename, thus remove it.
	final String path = f.getAbsolutePath().replace(fileName, "");
	
	ECSpec spec = ECElementsUtils.createECSpec();
	SerializerUtil.serializeECSpec(spec, new FileOutputStream(f));
	
	FileUtils fileUtils = EasyMock.createMock(FileUtils.class);
	EasyMock.expect(fileUtils.getFilesName(path, FileUtils.FILE_ENDING_XML)).andReturn(Arrays.asList(new String[] { fileName } ));
	EasyMock.replay(fileUtils);
	
	PersistenceConfig persistenceConfig = EasyMock.createMock(PersistenceConfig.class);
	EasyMock.expect(persistenceConfig.getRealPathECSpecDir()).andReturn(path).atLeastOnce();
	EasyMock.replay(persistenceConfig);
	
	ALE ale = EasyMock.createMock(ALE.class);
	ale.define(EasyMock.eq("ecspec"), EasyMock.isA(ECSpec.class));
	EasyMock.expectLastCall();
	EasyMock.replay(ale);
	
	ReadConfigImpl readConfig = new ReadConfigImpl();
	readConfig.setFileUtils(fileUtils);
	readConfig.setPersistenceConfig(persistenceConfig);
	readConfig.setAle(ale);
	
	// TEST
	readConfig.readECSpecs();
	
	EasyMock.verify(fileUtils);
	EasyMock.verify(persistenceConfig);
	EasyMock.verify(ale);
}
 
開發者ID:Auto-ID-Lab-Japan,項目名稱:fosstrak-fc,代碼行數:41,代碼來源:ReadConfigTest.java

示例2: testSerializeECSpec

import org.fosstrak.ale.util.SerializerUtil; //導入方法依賴的package包/類
@Test
public void testSerializeECSpec() throws Exception {
	ECSpec ecSpec = createDummyECSpec();
	CharArrayWriter writer = new CharArrayWriter();
	SerializerUtil.serializeECSpec(ecSpec, writer);
	String str = writer.toString();
	ECSpec ecSpec2 = DeserializerUtil.deserializeECSpec(new ByteArrayInputStream(str.getBytes()));
	ensureSame(ecSpec, ecSpec2);
}
 
開發者ID:Auto-ID-Lab-Japan,項目名稱:fosstrak-fc,代碼行數:10,代碼來源:SerializerAndDeserializerUtilsTest.java

示例3: testSerializeECSpecWithOutputStream

import org.fosstrak.ale.util.SerializerUtil; //導入方法依賴的package包/類
@Test
public void testSerializeECSpecWithOutputStream() throws Exception {
	ECSpec ecSpec = createDummyECSpec();
	ByteArrayOutputStream bous = new ByteArrayOutputStream();
	SerializerUtil.serializeECSpec(ecSpec, bous);
	String str = bous.toString();
	ECSpec ecSpec2 = DeserializerUtil.deserializeECSpec(new ByteArrayInputStream(str.getBytes()));
	ensureSame(ecSpec, ecSpec2);
}
 
開發者ID:Auto-ID-Lab-Japan,項目名稱:fosstrak-fc,代碼行數:10,代碼來源:SerializerAndDeserializerUtilsTest.java

示例4: testDeserializeECSpec

import org.fosstrak.ale.util.SerializerUtil; //導入方法依賴的package包/類
/**
 * test the deserialization of the ECSpec from File.
 * @throws Exception test failure.
 */
@Test
public void testDeserializeECSpec() throws Exception {
	ECSpec ecSpec = createDummyECSpec();
	File f = File.createTempFile("testDeserializeECSpec", ".xml");
	FileOutputStream fof = new FileOutputStream(f);
	SerializerUtil.serializeECSpec(ecSpec, fof);
	fof.close();
	
	ECSpec deserialized = DeserializerUtil.deserializeECSpec(f.getAbsolutePath());
	ensureSame(ecSpec, deserialized);		
}
 
開發者ID:Auto-ID-Lab-Japan,項目名稱:fosstrak-fc,代碼行數:16,代碼來源:SerializerAndDeserializerUtilsTest.java

示例5: test_R2

import org.fosstrak.ale.util.SerializerUtil; //導入方法依賴的package包/類
@Test
public void test_R2() throws DuplicateNameException, ECSpecValidationException, ImplementationException, Exception {
	/** 
	 * precondition
	 * No ECSpecs are defined.
	 * Ensure all specName parameters accept as a name any non-empty string of Unicode characters that does not include Pattern_White_Space or Pattern_Syntax characters (see GM6)
	 * The Writing API must be supported for Step 7. Otherwise, Step 7 is optional.
	 **/ 

	CCSpec ccspec = DeserializerUtil.deserializeCCSpec(ALEConformanceTest.class.getResourceAsStream("/ccspecs/CCSpec_R2_1.xml"));
	ECSpec ecspec = DeserializerUtil.deserializeECSpec(ALEConformanceTest.class.getResourceAsStream("/ecspecs/ECSpec_R2_1.xml"));

	//System.out.println(spec.getBoundarySpec().getExtension().isWhenDataAvailable());
	
	//System.out.println(spec.getBoundarySpec().getExtension().isWhenDataAvailable());

	//step 1, 6
	ale.define("eventcycle1", ecspec);
	String[] ecspecNames = ale.getECSpecNames();
	for(String ecspecName : ecspecNames) assertEquals("eventcycle1", ecspecName);

	//step 2, 6
	ECSpec defined = ale.getECSpec("eventcycle1");

	//step 3, 6
	StringWriter expectedsw = new StringWriter();
	SerializerUtil.serializeECSpec(ecspec, expectedsw);
	String outExpectedString = expectedsw.toString();

	StringWriter sw = new StringWriter();
	SerializerUtil.serializeECSpec(defined, sw);
	String outString = sw.toString();

	//SerializerUtil.serializeECReportsPretty(ecreports, new OutputStreamWriter(System.out));
	Assert.assertEquals(outExpectedString, outString);

	//step 4, 6
	//step 4, 6
	ale.undefine("eventcycle1");

	//step 5, 6
	String[] ecspecNames2 = ale.getECSpecNames();
	if (ecspecNames2.length != 0)
		Assert.fail();

	//step 7
	try
	{
		alecc.define("foo", ccspec);
		ale.define("foo", ecspec);
	}
	catch (DuplicateNameException e)
	{
		System.out.println("fsdafd");
		Assert.fail();
	}

	alecc.undefine("foo");
	ale.undefine("foo");

}
 
開發者ID:gs1oliot,項目名稱:oliot-fc,代碼行數:62,代碼來源:ALEConformanceTest.java


注:本文中的org.fosstrak.ale.util.SerializerUtil.serializeECSpec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。