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


Java ResourcePatternResolver.getResource方法代碼示例

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


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

示例1: mergeArray

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/** Merge array. */
@Test
public void mergeArray() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource resource1 = resourceResolver.getResource("classpath:jsonLever/src1.json");
    Resource resource2 = resourceResolver.getResource("classpath:jsonLever/src2.json");
    Resource resultResource =
        resourceResolver.getResource("classpath:jsonLever/resultArray.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement src1 = jsonParser.parse(new InputStreamReader(resource1.getInputStream()));
    JsonElement src2 = jsonParser.parse(new InputStreamReader(resource2.getInputStream()));
    JsonElement result = jsonParser.parse(new InputStreamReader(resultResource.getInputStream()));

    JsonElement merge = jsonLever.merge(src1, src2, Boolean.TRUE);
    Assert.assertTrue(merge.isJsonObject());

    Assert.assertEquals(result, merge);
  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:24,代碼來源:JsonLeverBDDTest.java

示例2: getFieldEquals

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field equals.
 *
 * @return the field equals
 */
@Test
public void getFieldEquals() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query1.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(1, result.getAsJsonArray().size());

    Assert.assertEquals("prajwal", jsonLever.asString(result.getAsJsonArray().get(0)));
  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:28,代碼來源:JsonQueryBDDTest.java

示例3: getFieldEqualsOr

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field equals or.
 *
 * @return the field equals or
 */
@Test
public void getFieldEqualsOr() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query5.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(2, result.getAsJsonArray().size());

    Assert.assertEquals("prajwal", jsonLever.asString(result.getAsJsonArray().get(0)));
    Assert.assertEquals("paneesh", jsonLever.asString(result.getAsJsonArray().get(1)));
  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:29,代碼來源:JsonQueryBDDTest.java

示例4: getFieldEqualsAnd

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field equals and.
 *
 * @return the field equals and
 */
@Test
public void getFieldEqualsAnd() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query6.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(1, result.getAsJsonArray().size());

    Assert.assertEquals("prajwal", jsonLever.asString(result.getAsJsonArray().get(0)));
  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:28,代碼來源:JsonQueryBDDTest.java

示例5: getFieldEqualsAndFailure

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field equals and failure.
 *
 * @return the field equals and failure
 */
@Test
public void getFieldEqualsAndFailure() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query7.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(0, result.getAsJsonArray().size());

  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:27,代碼來源:JsonQueryBDDTest.java

示例6: getFieldNotEquals

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field not equals.
 *
 * @return the field not equals
 */
@Test
public void getFieldNotEquals() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query2.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(2, result.getAsJsonArray().size());

  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:27,代碼來源:JsonQueryBDDTest.java

示例7: getFieldNotEqualsAsync

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field not equals async.
 *
 * @return the field not equals async
 */
@Test
public void getFieldNotEqualsAsync() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query2.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    Flux<JsonElement> queryAsync = jq.queryAsync(query.getAsJsonObject());
    queryAsync.subscribe(
        json -> {
          Assert.assertTrue(jsonLever.isString(json));
          String str = jsonLever.asString(json);
          Assert.assertNotEquals("prajwal", str);
        });
  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:29,代碼來源:JsonQueryBDDTest.java

示例8: getFieldIn

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field in.
 *
 * @return the field in
 */
@Test
public void getFieldIn() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query3.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(2, result.getAsJsonArray().size());

  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:27,代碼來源:JsonQueryBDDTest.java

示例9: getFieldNotIn

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field not in.
 *
 * @return the field not in
 */
@Test
public void getFieldNotIn() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query4.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(3, result.getAsJsonArray().size());

  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:27,代碼來源:JsonQueryBDDTest.java

示例10: getFieldNotInLimit

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Gets the field not in limit.
 *
 * @return the field not in limit
 */
@Test
public void getFieldNotInLimit() {
  try {
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource samres = resourceResolver.getResource("classpath:jsonQuery/sample1.json");
    Resource qres = resourceResolver.getResource("classpath:jsonQuery/query4.json");

    JsonParser jsonParser = jsonLever.getJsonParser();
    JsonElement sample = jsonParser.parse(new InputStreamReader(samres.getInputStream()));
    JsonElement query = jsonParser.parse(new InputStreamReader(qres.getInputStream()));
    jsonLever.asJsonObject(query).add("from", sample);
    jsonLever.asJsonObject(query).add("limit", new JsonPrimitive(2));

    JsonElement result = jq.query(query.getAsJsonObject());

    Assert.assertTrue(jsonLever.isArray(result));
    Assert.assertEquals(2, result.getAsJsonArray().size());

  } catch (Exception e) {
    Assert.assertFalse(e.getMessage(), true);
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:28,代碼來源:JsonQueryBDDTest.java

示例11: testEqual

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Test equal.
 *
 * @param test the test
 * @param inputPattern the input pattern
 * @param outputPattern the output pattern
 */
protected void testEqual(String test, String inputPattern, String outputPattern) {

  try {
    JsonElement transform = transform(test, inputPattern);
    outputPattern =
        null == outputPattern
            ? String.format(outputFormat, test)
            : String.format(outputFormat, outputPattern);
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource outputRes = resourceResolver.getResource(outputPattern);
    JsonElement output =
        jsonLever.getJsonParser().parse(new InputStreamReader(outputRes.getInputStream()));
    Assert.assertEquals(output, transform);
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail(e.getMessage());
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:26,代碼來源:JsonMystiquePositiveBDD.java

示例12: testSubset

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/**
 * Test subset.
 *
 * @param test the test
 * @param inputPattern the input pattern
 * @param outputPattern the output pattern
 */
protected void testSubset(String test, String inputPattern, String outputPattern) {
  try {
    JsonElement transform = transform(test, inputPattern);
    outputPattern =
        null == outputPattern
            ? String.format(outputFormat, test)
            : String.format(outputFormat, outputPattern);
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource outputRes = resourceResolver.getResource(outputPattern);
    JsonElement output =
        jsonLever.getJsonParser().parse(new InputStreamReader(outputRes.getInputStream()));
    Comparison subset = jsonComparator.isSubset(output, transform);
    Assert.assertTrue(subset.getResult());
  } catch (Exception e) {
    e.printStackTrace();
    Assert.fail(e.getMessage());
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:26,代碼來源:JsonMystiquePositiveBDD.java

示例13: jacksonGsonTest

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
/** Jackson gson test. */
@Test
public void jacksonGsonTest() {
  try {
    String locationPattern = "classpath:gsonJackson/gsonJackson.json";
    ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    Resource resource = resourceResolver.getResource(locationPattern);

    JsonNode jacksonObject = instance.deserialize(resource.getInputStream(), JsonNode.class);
    JsonElement gsonObject = instance.deserialize(resource.getInputStream(), JsonElement.class);
    JsonElement transGsonObject = instance.deserialize(jacksonObject, JsonElement.class);
    JsonNode transJacksonObject = instance.deserialize(gsonObject, JsonNode.class);

    Assert.assertEquals(gsonObject, transGsonObject);
    Assert.assertEquals(jacksonObject, transJacksonObject);
  } catch (Exception e) {
    Assert.fail(e.getMessage());
  }
}
 
開發者ID:balajeetm,項目名稱:json-mystique,代碼行數:20,代碼來源:GsonJacksonConvertorBDDTest.java

示例14: exists

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
@Override
public boolean exists(String classpath)
{
    ClassLoader cl = this.getClass().getClassLoader();
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
    Resource resource = resolver.getResource("classpath:" + classpath);
    return resource.exists();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:9,代碼來源:AlfrescoEnviroment.java

示例15: testResolveResourceWithFilePrefix

import org.springframework.core.io.support.ResourcePatternResolver; //導入方法依賴的package包/類
public void testResolveResourceWithFilePrefix() throws Exception {
	Bundle bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, EXPANDED_BUNDLE_SYM_NAME);
	assertTrue(bundle.getLocation().startsWith(REFERENCE_PROTOCOL));
	ResourcePatternResolver resolver = new OsgiBundleResourcePatternResolver(bundle);
	Resource res = resolver.getResource("resource.res");
	assertTrue(res.getFile().exists());
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:8,代碼來源:EquinoxFileTests.java


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