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


Java NativeJavaObject.unwrap方法代码示例

本文整理汇总了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());
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:19,代码来源:TestConfigurationParserTest.java

示例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");
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:22,代码来源:WorkflowConfigurationParserTest.java

示例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"));
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:20,代码来源:TestConfigurationParserTest.java

示例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");
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:22,代码来源:WorkflowConfigurationParserTest.java

示例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());

}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:16,代码来源:TestConfigurationParserTest.java

示例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));
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:9,代码来源:TestConfigurationParserTest.java

示例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());
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:9,代码来源:TestConfigurationParserTest.java

示例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();
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:8,代码来源:TestConfigurationParserTest.java

示例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));
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:14,代码来源:TestConfigurationParserTest.java

示例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();
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:8,代码来源:TestConfigurationParserTest.java

示例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);
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:14,代码来源:TestConfigurationParserTest.java

示例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>());
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:10,代码来源:TestConfigurationParserTest.java

示例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());
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:11,代码来源:TestConfigurationParserTest.java

示例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")));
}
 
开发者ID:collectivemedia,项目名称:celos,代码行数:10,代码来源:TestConfigurationParserTest.java

示例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();
    }
}
 
开发者ID:galenframework,项目名称:galen,代码行数:29,代码来源:VarsParser.java


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