@Test public void testProvide() throws Exception { final XStreamProvider<List<Node>> provider = new NodeConfigurationXStreamProvider(); final String xml = new Scanner(new File("src/test/resources/cluster.xml")).useDelimiter("\\Z").next(); final List<Node> cluster = provider.fromXML(xml); assertNotNull(cluster); assertEquals(3, cluster.size()); final Node node0 = cluster.get(0); assertEquals("TESTCLUSTER.SF0", node0.getId()); assertEquals("TESTCLUSTER", node0.getClusterId()); assertEquals("SF0", node0.getNodeId()); assertEquals("SFW", node0.getNodeType()); assertEquals("DEFAULT", node0.getNodeConfig()); assertFalse(node0.isFtIndexDisabled()); assertEquals("http: final Node node1 = cluster.get(1); assertEquals("TESTCLUSTER.SF1", node1.getId()); assertEquals("TESTCLUSTER", node1.getClusterId()); assertEquals("SF1", node1.getNodeId()); assertEquals("API", node1.getNodeType()); assertEquals("DEFAULT", node1.getNodeConfig()); assertTrue(node1.isFtIndexDisabled()); assertEquals("http: final Node admin = cluster.get(2); assertEquals("TESTCLUSTER.JAM", admin.getId()); assertEquals("TESTCLUSTER", admin.getClusterId()); assertEquals("JAM", admin.getNodeId()); assertEquals("ADM", admin.getNodeType()); assertEquals("DEFAULT", admin.getNodeConfig()); assertTrue(admin.isFtIndexDisabled()); assertNull(admin.getChannel()); }
private XStream provide() { if (this.xStream == null) { XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.alias("nodes", ArrayList.class); xStream.alias("node", NodeImpl.class); xStream.aliasField("node-id", NodeImpl.class, "nodeId"); xStream.aliasField("node-type", NodeImpl.class, "nodeType"); xStream.aliasField("node-config", NodeImpl.class, "nodeConfig"); xStream.aliasField("cluster-id", NodeImpl.class, "clusterId"); xStream.aliasField("lucene-index-disabled", NodeImpl.class, "ftIndexDisabled"); xStream.aliasField("channel", NodeImpl.class, "channel"); xStream.aliasField("version", NodeImpl.class, "version"); xStream.aliasField("build-number", NodeImpl.class, "buildNo"); xStream.addDefaultImplementation(NodeImpl.class, Node.class); xStream.addDefaultImplementation(ArrayList.class, List.class); this.xStream = xStream; } return this.xStream; }
NodeConfigurationXStreamProvider implements XStreamProvider<List<Node>> { private XStream provide() { if (this.xStream == null) { XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.alias("nodes", ArrayList.class); xStream.alias("node", NodeImpl.class); xStream.aliasField("node-id", NodeImpl.class, "nodeId"); xStream.aliasField("node-type", NodeImpl.class, "nodeType"); xStream.aliasField("node-config", NodeImpl.class, "nodeConfig"); xStream.aliasField("cluster-id", NodeImpl.class, "clusterId"); xStream.aliasField("lucene-index-disabled", NodeImpl.class, "ftIndexDisabled"); xStream.aliasField("channel", NodeImpl.class, "channel"); xStream.aliasField("version", NodeImpl.class, "version"); xStream.aliasField("build-number", NodeImpl.class, "buildNo"); xStream.addDefaultImplementation(NodeImpl.class, Node.class); xStream.addDefaultImplementation(ArrayList.class, List.class); this.xStream = xStream; } return this.xStream; } }
NodeConfigurationXStreamProvider implements XStreamProvider<List<Node>> { private XStream provide() { if (this.xStream == null) { XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.alias("nodes", ArrayList.class); xStream.alias("node", NodeImpl.class); xStream.aliasField("node-id", NodeImpl.class, "nodeId"); xStream.aliasField("node-type", NodeImpl.class, "nodeType"); xStream.aliasField("node-config", NodeImpl.class, "nodeConfig"); xStream.aliasField("cluster-id", NodeImpl.class, "clusterId"); xStream.aliasField("lucene-index-disabled", NodeImpl.class, "ftIndexDisabled"); xStream.aliasField("channel", NodeImpl.class, "channel"); xStream.aliasField("version", NodeImpl.class, "version"); xStream.aliasField("build-number", NodeImpl.class, "buildNo"); xStream.addDefaultImplementation(NodeImpl.class, Node.class); xStream.addDefaultImplementation(ArrayList.class, List.class); this.xStream = xStream; } return this.xStream; }  }
NodeConfigurationXStreamProvider implements XStreamProvider<List<Node>> { private XStream provide() { if (this.xStream == null) { XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.alias("nodes", ArrayList.class); xStream.alias("node", NodeImpl.class); xStream.aliasField("node-id", NodeImpl.class, "nodeId"); xStream.aliasField("node-type", NodeImpl.class, "nodeType"); xStream.aliasField("node-config", NodeImpl.class, "nodeConfig"); xStream.aliasField("cluster-id", NodeImpl.class, "clusterId"); xStream.aliasField("lucene-index-disabled", NodeImpl.class, "ftIndexDisabled"); xStream.aliasField("channel", NodeImpl.class, "channel"); xStream.aliasField("version", NodeImpl.class, "version"); xStream.aliasField("build-number", NodeImpl.class, "buildNo"); xStream.addDefaultImplementation(NodeImpl.class, Node.class); xStream.addDefaultImplementation(ArrayList.class, List.class); this.xStream = xStream; } return this.xStream; }  @Override List<Node> fromXML(final String xml); @Override List<Node> fromXML(final InputStream is); @Override String toXML(final List<Node> object); }
NodeConfigurationXStreamProvider implements XStreamProvider<List<Node>> { private XStream provide() { if (this.xStream == null) { XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.alias("nodes", ArrayList.class); xStream.alias("node", NodeImpl.class); xStream.aliasField("node-id", NodeImpl.class, "nodeId"); xStream.aliasField("node-type", NodeImpl.class, "nodeType"); xStream.aliasField("node-config", NodeImpl.class, "nodeConfig"); xStream.aliasField("cluster-id", NodeImpl.class, "clusterId"); xStream.aliasField("lucene-index-disabled", NodeImpl.class, "ftIndexDisabled"); xStream.aliasField("channel", NodeImpl.class, "channel"); xStream.aliasField("version", NodeImpl.class, "version"); xStream.aliasField("build-number", NodeImpl.class, "buildNo"); xStream.addDefaultImplementation(NodeImpl.class, Node.class); xStream.addDefaultImplementation(ArrayList.class, List.class); this.xStream = xStream; } return this.xStream; }  @Override List<Node> fromXML(final String xml); @Override List<Node> fromXML(final InputStream is); @Override String toXML(final List<Node> object);  }