org.killbill.xmlloader.XMLLoader.getObjectFromStream()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.killbill.xmlloader.XMLLoader.getObjectFromStream()方法的一些代码示例,展示了XMLLoader.getObjectFromStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLLoader.getObjectFromStream()方法的具体详情如下:
包路径:org.killbill.xmlloader.XMLLoader
类名称:XMLLoader
方法名:getObjectFromStream

XMLLoader.getObjectFromStream介绍

暂无

代码示例

代码示例来源:origin: killbill/killbill

@Override
  public OverdueConfig loadOverdueConfig(final String overdueConfigXML) throws OverdueApiException {
    final InputStream overdueConfigStream = new ByteArrayInputStream(overdueConfigXML.getBytes());
    try {
      return XMLLoader.getObjectFromStream(overdueConfigStream, DefaultOverdueConfig.class);
    } catch (final Exception e) {
      throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, "Problem encountered loading overdue config ", e);
    }
  }
};

代码示例来源:origin: killbill/killbill

for (final String cur : catalogXMLs) {
  final InputStream curCatalogStream = new ByteArrayInputStream(cur.getBytes());
  final StandaloneCatalog catalog = XMLLoader.getObjectFromStream(curCatalogStream, StandaloneCatalog.class);
  if (!filterTemplateCatalog || !catalog.isTemplateCatalog()) {
    result.add(new StandaloneCatalogWithPriceOverride(catalog, priceOverride, tenantRecordId, internalCallContextFactory));

代码示例来源:origin: killbill/killbill

@Test(groups = "fast")
  public void testMarshallUnmarshall() throws Exception {
    final DefaultOverdueConfig overdueConfig = XMLLoader.getObjectFromString(Resources.getResource("OverdueConfig3.xml").toExternalForm(), DefaultOverdueConfig.class);
    final String overdueConfigStr = XMLWriter.writeXML(overdueConfig, DefaultOverdueConfig.class);

    //System.err.println(overdueConfigStr);
    final DefaultOverdueConfig overdueConfig2 = XMLLoader.getObjectFromStream(new ByteArrayInputStream(overdueConfigStr.getBytes(Charset.forName("UTF-8"))), DefaultOverdueConfig.class);
    final String overdueConfigStr2 = XMLWriter.writeXML(overdueConfig2, DefaultOverdueConfig.class);
    Assert.assertEquals(overdueConfigStr, overdueConfigStr2);
  }
}

代码示例来源:origin: killbill/killbill

@Test(groups = "fast")
public void testMarshallUnmarshall() throws Exception {
  final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class);
  final String oldCatalogStr = XMLWriter.writeXML(catalog, StandaloneCatalog.class);
  //System.err.println(oldCatalogStr);
  final StandaloneCatalog oldCatalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(oldCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
  final String oldCatalogStr2 = XMLWriter.writeXML(oldCatalog, StandaloneCatalog.class);
  assertEquals(oldCatalogStr2, oldCatalogStr);
}

代码示例来源:origin: killbill/killbill

@Test(groups = "fast")
public void testEmptyDefaultCatalog() throws Exception {
  final DateTime now = clock.getUTCNow();
  final CatalogUpdater catalogUpdater = new CatalogUpdater(now, null);
  final String catalogXML = catalogUpdater.getCatalogXML();
  final StandaloneCatalog catalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(catalogXML.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
  assertEquals(catalog.getCurrentPlans().size(), 0);
}

代码示例来源:origin: killbill/killbill

final StaticCatalog newCatalogVersion = XMLLoader.getObjectFromStream(stream, StandaloneCatalog.class);

代码示例来源:origin: killbill/killbill

final StandaloneCatalog newCatalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(newCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
assertEquals(newCatalog.getCurrentPlans().size(), catalog.getCurrentPlans().size() + 1);

代码示例来源:origin: killbill/killbill

final StandaloneCatalog newCatalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(newCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);

代码示例来源:origin: killbill/killbill

return XMLLoader.getObjectFromStream(new ByteArrayInputStream(newCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);

代码示例来源:origin: org.kill-bill.commons/killbill-xmlloader

public static <T extends ValidatingConfig<T>> T getObjectFromUri(final URI uri, final Class<T> objectType) throws Exception {
  if (uri == null) {
    return null;
  }
  log.info("Initializing an object of class " + objectType.getName() + " from xml file at: " + uri);
  return getObjectFromStream(UriAccessor.accessUri(uri), objectType);
}

代码示例来源:origin: org.kill-bill.billing/killbill-overdue

@Override
  public OverdueConfig loadOverdueConfig(final String overdueConfigXML) throws OverdueApiException {
    final InputStream overdueConfigStream = new ByteArrayInputStream(overdueConfigXML.getBytes());
    try {
      return XMLLoader.getObjectFromStream(overdueConfigStream, DefaultOverdueConfig.class);
    } catch (final Exception e) {
      throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, "Problem encountered loading overdue config ", e);
    }
  }
};

代码示例来源:origin: org.kill-bill.commons/killbill-xmlloader

public static <T extends ValidatingConfig<T>> T getObjectFromString(final String uri, final Class<T> objectType) throws Exception {
  if (uri == null) {
    return null;
  }
  log.info("Initializing an object of class " + objectType.getName() + " from xml file at: " + uri);
  return getObjectFromStream(UriAccessor.accessUri(uri), objectType);
}

代码示例来源:origin: org.kill-bill.billing/killbill-jaxrs

@TimedResource
@POST
@Consumes(TEXT_XML)
@ApiOperation(value = "Upload the full overdue config as XML", hidden=true)
@ApiResponses(value = {})
public Response uploadOverdueConfigXmlOriginal(final String overdueXML,
                        @HeaderParam(HDR_CREATED_BY) final String createdBy,
                        @HeaderParam(HDR_REASON) final String reason,
                        @HeaderParam(HDR_COMMENT) final String comment,
                        @javax.ws.rs.core.Context final HttpServletRequest request,
                        @javax.ws.rs.core.Context final UriInfo uriInfo) throws Exception {
  // Validation purpose:  Will throw if bad XML or catalog validation fails
  final InputStream stream = new ByteArrayInputStream(overdueXML.getBytes());
  XMLLoader.getObjectFromStream(stream, DefaultOverdueConfig.class);
  final CallContext callContext = context.createCallContextNoAccountId(createdBy, reason, comment, request);
  overdueApi.uploadOverdueConfig(overdueXML, callContext);
  return uriBuilder.buildResponse(uriInfo, OverdueResource.class, null, null, request);
}

代码示例来源:origin: org.kill-bill.billing/killbill-catalog

for (final String cur : catalogXMLs) {
  final InputStream curCatalogStream = new ByteArrayInputStream(cur.getBytes());
  final StandaloneCatalog catalog = XMLLoader.getObjectFromStream(curCatalogStream, StandaloneCatalog.class);
  if (!filterTemplateCatalog || !catalog.isTemplateCatalog()) {
    result.add(new StandaloneCatalogWithPriceOverride(catalog, priceOverride, tenantRecordId, internalCallContextFactory));

代码示例来源:origin: org.kill-bill.billing/killbill-catalog

@Test(groups = "fast")
public void testMarshallUnmarshall() throws Exception {
  final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class);
  final String oldCatalogStr = XMLWriter.writeXML(catalog, StandaloneCatalog.class);
  //System.err.println(oldCatalogStr);
  final StandaloneCatalog oldCatalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(oldCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
  final String oldCatalogStr2 = XMLWriter.writeXML(oldCatalog, StandaloneCatalog.class);
  assertEquals(oldCatalogStr2, oldCatalogStr);
}

代码示例来源:origin: org.kill-bill.commons/killbill-xmlloader

@Test(groups = "fast")
  public void test() throws SAXException, InvalidConfigException, JAXBException, IOException, TransformerException, URISyntaxException, ValidationException {
    final InputStream is = new ByteArrayInputStream(TEST_XML.getBytes());
    final XmlTestClass test = XMLLoader.getObjectFromStream(is, XmlTestClass.class);
    assertEquals(test.getFoo(), "foo");
    assertEquals(test.getBar(), 1.0);
    assertEquals(test.getLala(), 42);
  }
}

代码示例来源:origin: org.kill-bill.commons/killbill-xmlloader

@Test(groups = "fast")
  public void test() throws Exception {
    final InputStream is = new ByteArrayInputStream(TEST_XML.getBytes());
    final XmlTestClass test = XMLLoader.getObjectFromStream(is, XmlTestClass.class);
    assertEquals(test.getFoo(), "foo");
    assertEquals(test.getBar(), 1.0);
    assertEquals(test.getLala(), 42);

    final String output = XMLWriter.writeXML(test, XmlTestClass.class);
    //System.out.println(output);
    assertEquals(output.replaceAll("\\s", ""), TEST_XML.replaceAll("\\s", ""));
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-catalog

@Test(groups = "fast")
public void testEmptyDefaultCatalog() throws Exception {
  final DateTime now = clock.getUTCNow();
  final CatalogUpdater catalogUpdater = new CatalogUpdater(now, null);
  final String catalogXML = catalogUpdater.getCatalogXML();
  final StandaloneCatalog catalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(catalogXML.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);
  assertEquals(catalog.getCurrentPlans().size(), 0);
}

代码示例来源:origin: org.kill-bill.billing/killbill-catalog

final StaticCatalog newCatalogVersion = XMLLoader.getObjectFromStream(stream, StandaloneCatalog.class);

代码示例来源:origin: org.kill-bill.billing/killbill-catalog

final StandaloneCatalog newCatalog = XMLLoader.getObjectFromStream(new ByteArrayInputStream(newCatalogStr.getBytes(Charset.forName("UTF-8"))), StandaloneCatalog.class);

相关文章