本文整理汇总了Java中ca.nrc.cadc.util.FileUtil.getFileFromResource方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getFileFromResource方法的具体用法?Java FileUtil.getFileFromResource怎么用?Java FileUtil.getFileFromResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.nrc.cadc.util.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getFileFromResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadFile
import ca.nrc.cadc.util.FileUtil; //导入方法依赖的package包/类
@Test
public void testLoadFile() {
try {
File cf = FileUtil.getFileFromResource("CaomRepoConfig.properties", CaomRepoConfigTest.class);
List<CaomRepoConfig.Item> items = CaomRepoConfig.loadConfig(cf);
Assert.assertNotNull(items);
Assert.assertEquals(1, items.size());
CaomRepoConfig.Item it = items.get(0);
Assert.assertEquals("TEST_OK", it.getCollection());
Assert.assertEquals("dsname", it.getDataSourceName());
Assert.assertEquals("database", it.getDatabase());
Assert.assertEquals("schema", it.getSchema());
Assert.assertEquals("database.schema.caom2obs", it.getTestTable());
Assert.assertEquals(new GroupURI("ivo://cadc.nrc.ca/gms?group1"), it.getReadOnlyGroup());
Assert.assertEquals(new GroupURI("ivo://cadc.nrc.ca/gms?group2"), it.getReadWriteGroup());
Assert.assertEquals(DummySQLGeneratorImpl.class, it.getSqlGenerator());
Assert.assertEquals(true, it.getProposalGroup());
Assert.assertEquals(new GroupURI("ivo://cadc.nrc.ca/gms?CADC"), it.getOperatorGroup());
Assert.assertEquals(new GroupURI("ivo://cadc.nrc.ca/gms?JCMT-Staff"), it.getStaffGroup());
} catch (Exception unexpected) {
log.error("unexpected exception", unexpected);
Assert.fail("unexpected exception: " + unexpected);
}
}
示例2: CaomRepoBaseIntTests
import ca.nrc.cadc.util.FileUtil; //导入方法依赖的package包/类
/**
* @param resourceID resource identifier of service to test
* @param pem1 PEM file for user with read-write permission
* @param pem2 PEM file for user with read-only permission
* @param pem3 PEM file for user with no permissions
*/
public CaomRepoBaseIntTests(URI resourceID, URI repoStandardID, String pem1, String pem2, String pem3) {
try {
if (pem1 != null) {
File sslCert1 = FileUtil.getFileFromResource(pem1, this.getClass());
subject1 = SSLUtil.createSubject(sslCert1);
}
if (pem2 != null) {
File sslCert2 = FileUtil.getFileFromResource(pem2, this.getClass());
subject2 = SSLUtil.createSubject(sslCert2);
}
if (pem3 != null) {
File sslCert3 = FileUtil.getFileFromResource(pem3, this.getClass());
subject3 = SSLUtil.createSubject(sslCert3);
}
RegistryClient rc = new RegistryClient();
URL serviceURL = rc.getServiceURL(resourceID, repoStandardID, AuthMethod.ANON);
baseHTTPURL = serviceURL.toExternalForm();
serviceURL = rc.getServiceURL(resourceID, repoStandardID, AuthMethod.CERT);
baseHTTPSURL = serviceURL.toExternalForm();
log.debug("test service URL: " + baseHTTPURL);
log.debug("test service URL: " + baseHTTPSURL);
} catch (Throwable t) {
String message = "Failed int-test initialization: " + t.getMessage();
log.fatal(message, t);
throw new ExceptionInInitializerError(message);
}
}
示例3: testWellFormed
import ca.nrc.cadc.util.FileUtil; //导入方法依赖的package包/类
@Test
public void testWellFormed()
{
for (String vodmlFile : VODML_FILES)
{
try
{
File testVODML = FileUtil.getFileFromResource(vodmlFile, VODMLValidationTest.class);
log.info("testWellFormed VO-DML/XML doc: " + testVODML);
VOModelReader wf = new VOModelReader(false, false, false);
Document doc = wf.read(new FileInputStream(testVODML));
Assert.assertNotNull(doc);
VOModelWriter w = new VOModelWriter();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
w.write(doc, bos);
log.debug("well-formed document:\n" + bos.toString());
log.info("testWellFormed VO-DML/XML doc: OK");
}
catch(Exception unexpected)
{
log.error("unexpected exception", unexpected);
Assert.fail("unexpected exception: " + unexpected);
}
}
}
示例4: testSchemaValid
import ca.nrc.cadc.util.FileUtil; //导入方法依赖的package包/类
@Test
public void testSchemaValid()
{
for (String vodmlFile : VODML_FILES)
{
try
{
File testVODML = FileUtil.getFileFromResource(vodmlFile, VODMLValidationTest.class);
log.info("testSchemaValid VO-DML/XML doc: " + testVODML);
VOModelReader wf = new VOModelReader(true, false, false);
Document doc = wf.read(new FileInputStream(testVODML));
Assert.assertNotNull(doc);
VOModelWriter w = new VOModelWriter();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
w.write(doc, bos);
log.debug("schema-valid document:\n" + bos.toString());
log.info("testSchemaValid VO-DML/XML doc: OK");
}
catch(Exception unexpected)
{
log.error("unexpected exception", unexpected);
Assert.fail("unexpected exception: " + unexpected);
}
}
}
示例5: testSchematronValid
import ca.nrc.cadc.util.FileUtil; //导入方法依赖的package包/类
@Test
public void testSchematronValid()
{
for (String vodmlFile : VODML_FILES)
{
try
{
File testVODML = FileUtil.getFileFromResource(vodmlFile, VODMLValidationTest.class);
log.info("testSchematronValid VO-DML/XML doc: " + testVODML);
VOModelReader wf = new VOModelReader(true, true, true);
Document doc = wf.read(new FileInputStream(testVODML));
Assert.assertNotNull(doc);
log.info("testSchematronValid VO-DML/XML doc: OK");
}
catch(SchematronValidationException ex)
{
for (String msg : ex.getFailures())
log.error(msg);
Assert.fail("schematron validation failed: " + ex);
}
catch(Exception unexpected)
{
log.error("unexpected exception", unexpected);
Assert.fail("unexpected exception: " + unexpected);
}
}
}