本文整理汇总了Java中org.mozilla.javascript.NativeJavaObject.unwrap方法的典型用法代码示例。如果您正苦于以下问题:Java NativeJavaObject.unwrap方法的具体用法?Java NativeJavaObject.unwrap怎么用?Java NativeJavaObject.unwrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.NativeJavaObject
的用法示例。
在下文中一共展示了NativeJavaObject.unwrap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHiveInput
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testHiveInput() throws Exception {
String tableCreationScript = "table creation script";
String js = "ci.hiveInput(\"dbname\", \"tablename\", ci.fixFile(\"" + tableCreationScript + "\"))";
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader(js), "string");
HiveTableDeployer hiveTableDeployer = (HiveTableDeployer) creatorObj.unwrap();
FixFile tableCreationFile = hiveTableDeployer.getTableCreationScriptFile().create(null);
Assert.assertEquals(hiveTableDeployer.getDatabaseName(), new DatabaseName("dbname"));
Assert.assertEquals(hiveTableDeployer.getTableName(), "tablename");
Assert.assertEquals(IOUtils.toString(tableCreationFile.getContent()), tableCreationScript);
Assert.assertNull(hiveTableDeployer.getDataFileCreator());
}
示例2: testTakesDefaultUsername
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testTakesDefaultUsername() throws Exception {
URL resource = Thread.currentThread().getContextClassLoader().getResource("com/collective/celos/defaults-oozie-props");
File defaults = new File(resource.toURI());
WorkflowConfigurationParser parser = new WorkflowConfigurationParser(defaults, ImmutableMap.of("var1", "val1"));
String func = "function (slotId) {" +
" return {" +
" \"oozie.wf.application.path\": \"/workflow.xml\"," +
" \"inputDir\": \"/input\"," +
" \"outputDir\": \"/output\"" +
" }" +
" }";
String str = "importDefaults(\"test\"); celos.makePropertiesGen(" + func + "); ";
NativeJavaObject jsResult = (NativeJavaObject) parser.evaluateReader(new StringReader(str), "string", new MemoryStateDatabase().openConnection());
PropertiesGenerator generator = (PropertiesGenerator) jsResult.unwrap();
Assert.assertEquals(generator.getProperties(null).get("user.name").asText(), "default");
}
示例3: testFixTableFromTSV
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testFixTableFromTSV() throws Exception {
String js = "ci.fixTableFromTsv(ci.fixFile(\"A\\tB\\n1\\t2\\n11\\t22\"))";
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader(js), "string");
FileFixTableCreator creator = (FileFixTableCreator) creatorObj.unwrap();
TestRun testRun = mock(TestRun.class);
FixTable t = creator.create(testRun);
FixTable.FixRow r1 = t.getRows().get(0);
FixTable.FixRow r2 = t.getRows().get(1);
Assert.assertEquals("1", r1.getCells().get("A"));
Assert.assertEquals("2", r1.getCells().get("B"));
Assert.assertEquals("11", r2.getCells().get("A"));
Assert.assertEquals("22", r2.getCells().get("B"));
}
示例4: testTakesChangesUsername
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testTakesChangesUsername() throws Exception {
URL resource = Thread.currentThread().getContextClassLoader().getResource("com/collective/celos/defaults-oozie-props");
File defaults = new File(resource.toURI());
WorkflowConfigurationParser parser = new WorkflowConfigurationParser(defaults, ImmutableMap.of("CELOS_USER_JS_VAR", "nameIsChanged"));
String func = "function (slotId) {" +
" return {" +
" \"oozie.wf.application.path\": \"/workflow.xml\"," +
" \"inputDir\": \"/input\"," +
" \"outputDir\": \"/output\"" +
" }" +
" }";
String str = "importDefaults(\"test\"); celos.makePropertiesGen(" + func + "); ";
NativeJavaObject jsResult = (NativeJavaObject) parser.evaluateReader(new StringReader(str), "string", new MemoryStateDatabase().openConnection());
PropertiesGenerator generator = (PropertiesGenerator) jsResult.unwrap();
Assert.assertEquals(generator.getProperties(null).get("user.name").asText(), "nameIsChanged");
}
示例5: testFixTableComparerOrdered
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testFixTableComparerOrdered() throws IOException {
String js =
"var table1 = ci.fixTable([\"col1\", \"col2\"], [[\"row1\", \"row2\"],[\"row11\", \"row22\"]]);" +
"var table2 = ci.fixTable([\"col1\", \"col2\"], [[\"row1\", \"row2\"],[\"row11\", \"row22\"]]);" +
"ci.fixTableCompare(table1, table2, true, true);";
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader(js), "string");
FixTableComparer comparer = (FixTableComparer) creatorObj.unwrap();
Assert.assertEquals(true, comparer.isColumnNamesOrdered());
Assert.assertEquals(true, comparer.isRespectRowOrder());
}
示例6: fixFileFromResourceFails
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test(expected = JavaScriptException.class)
public void fixFileFromResourceFails() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.fixFileFromResource()"), "string");
FixFileFromResourceCreator creator = (FixFileFromResourceCreator) creatorObj.unwrap();
Assert.assertEquals(new File("stuff"), creator.getPath(testRun));
}
示例7: testHdfsInputDeployerCall1
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test(expected = JavaScriptException.class)
public void testHdfsInputDeployerCall1() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.hdfsInput()"), "string");
HdfsInputDeployer creator = (HdfsInputDeployer) creatorObj.unwrap();
Assert.assertEquals(new File("stuff"), creator.getPath());
}
示例8: testRecursiveFsObjectComparer1
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test(expected = JavaScriptException.class)
public void testRecursiveFsObjectComparer1() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.plainCompare()"), "string");
RecursiveFsObjectComparer creator = (RecursiveFsObjectComparer) creatorObj.unwrap();
}
示例9: testRecursiveFsObjectComparer2
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testRecursiveFsObjectComparer2() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.plainCompare(ci.fixDirFromResource(\"stuff\"), \"here\")"), "string");
RecursiveFsObjectComparer comparer = (RecursiveFsObjectComparer) creatorObj.unwrap();
OutputFixDirFromHdfsCreator actualCreator = (OutputFixDirFromHdfsCreator) comparer.getActualDataCreator();
FixDirFromResourceCreator expectedDataCreator = (FixDirFromResourceCreator) comparer.getExpectedDataCreator();
Assert.assertEquals(new Path("here"), actualCreator.getPath());
Assert.assertEquals(new File("/stuff"), expectedDataCreator.getPath(testRun));
}
示例10: testRecursiveFsObjectComparer3
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test(expected = JavaScriptException.class)
public void testRecursiveFsObjectComparer3() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.plainCompare(ci.fixFileFromResource(\"stuff\"))"), "string");
RecursiveFsObjectComparer creator = (RecursiveFsObjectComparer) creatorObj.unwrap();
}
示例11: testAvroToJson
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testAvroToJson() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.avroToJson(\"1\")"), "string");
ConversionCreator converter = (ConversionCreator) creatorObj.unwrap();
Assert.assertTrue(converter.getFixObjectConverter() instanceof FixDirRecursiveConverter);
FixDirRecursiveConverter fixDirRecursiveConverter = (FixDirRecursiveConverter) converter.getFixObjectConverter();
Assert.assertTrue(fixDirRecursiveConverter.getFixFileConverter() instanceof AvroToJsonConverter);
Assert.assertTrue(converter.getCreator() instanceof OutputFixDirFromHdfsCreator);
}
示例12: testJsonCompare
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testJsonCompare() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.jsonCompare(ci.fixDirFromResource(\"stuff\"), ci.fixDirFromResource(\"stuff\"))"), "string");
JsonContentsComparer comparer = (JsonContentsComparer) creatorObj.unwrap();
Assert.assertEquals(comparer.getIgnorePaths(), new HashSet<String>());
}
示例13: testExpandJson
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test
public void testExpandJson() throws IOException {
String js = "ci.expandJson(ci.tableToJson(ci.hiveTable(\"dbname\", \"tablename\")), [\"field1\", \"field2\"])";
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader(js), "string");
ConversionCreator creator = (ConversionCreator) creatorObj.unwrap();
Assert.assertEquals(JsonExpandConverter.class, creator.getFixObjectConverter().getClass());
}
示例14: testJsonCompareFails
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
@Test(expected = JavaScriptException.class)
public void testJsonCompareFails() throws IOException {
TestConfigurationParser parser = new TestConfigurationParser();
NativeJavaObject creatorObj = (NativeJavaObject) parser.evaluateTestConfig(new StringReader("ci.jsonCompare(ci.fixDirFromResource(\"stuff\"))"), "string");
JsonContentsComparer comparer = (JsonContentsComparer) creatorObj.unwrap();
Assert.assertEquals(comparer.getIgnorePaths(), new HashSet(Lists.newArrayList("path1", "path2")));
}
示例15: getExpressionValueString
import org.mozilla.javascript.NativeJavaObject; //导入方法依赖的package包/类
private String getExpressionValueString(String expression, Context context) {
Object value = context.getValue(expression);
if (value == null) {
//Looking for value in properties
if (properties != null) {
value = properties.getProperty(expression);
}
if (value == null) {
value = System.getProperty(expression);
}
}
if (value == null){
value = readJsExpression(expression);
}
if (value instanceof NativeJavaObject) {
NativeJavaObject javaObject = (NativeJavaObject) value;
value = javaObject.unwrap();
}
if (value == null) {
return "";
} else {
return value.toString();
}
}