Commit cf900f40 authored by Thibaut Démare's avatar Thibaut Démare

Add and change some tests

parent a52012b6
......@@ -26,8 +26,6 @@ global {
gs_add_edge gs_sender_id:"test1" gs_edge_id:"edge1" gs_node_id_from:"node1" gs_node_id_to:"node2" gs_is_directed:true;
gs_add_edge gs_sender_id:"test1" gs_edge_id:"edge2" gs_node_id_from:"node2" gs_node_id_to:"node3" gs_is_directed:false;
// Step
gs_step gs_sender_id:"test1" gs_step_number:1;
// Add attributes on edge
// A string attribute
......@@ -42,7 +40,7 @@ global {
//gs_add_edge_attribute gs_sender_id:"test1" gs_edge_id:"edge1" gs_attribute_name:"list" gs_attribute_value:["one","two","three"];
// Step
gs_step gs_sender_id:"test1" gs_step_number:2;
gs_step gs_sender_id:"test1" gs_step_number:1;
// Clear
//gs_clear gs_sender_id:"test1";
......
package org.graphstream.gama.tests;
import org.graphstream.graph.Edge;
import org.graphstream.graph.Graph;
import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.stream.SinkAdapter;
import org.graphstream.stream.netstream.NetStreamReceiver;
public class SimpleSinkAdapter extends SinkAdapter {
private Graph graph;
public SimpleSinkAdapter(NetStreamReceiver receiver) {
graph = new SingleGraph("test", false, false);
receiver.getDefaultStream().addSink(graph);
receiver.getDefaultStream().addSink(this);
}
@Override
public void stepBegins(String sourceId, long timeId, double step) {
System.out.println("Edges attributes :");
for(Edge e : graph.getEachEdge()){
for(Object o : e.getAttributeKeySet()){
System.out.println(e.getAttribute((String)o).getClass() + " et value = " + e.getAttribute((String)o));
}
}
System.out.println("Nodes attributes :");
for(Node e : graph.getEachNode()){
for(Object o : e.getAttributeKeySet()){
System.out.println(e.getAttribute((String)o).getClass() + " et value = " + e.getAttribute((String)o));
}
}
}
public Graph getGraph() {
return graph;
}
public void setGraph(Graph graph) {
this.graph = graph;
}
}
\ No newline at end of file
......@@ -7,15 +7,10 @@ import org.graphstream.stream.netstream.NetStreamReceiver;
public class Tests {
public static void main(String[] args) throws UnknownHostException, IOException {
// System.setProperty("gs.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
// test graph viewer
new SimpleNetStreamViewer(new NetStreamReceiver(2000), true, 500, 500);
// test graph viewer
new SimpleNetStreamViewer(new NetStreamReceiver(2001), true, 500, 500);
public static void main(String[] args) throws InterruptedException, UnknownHostException, IOException {
NetStreamReceiver receiver = new NetStreamReceiver(2001);
new SimpleNetStreamViewer(receiver, true);
new SimpleSinkAdapter(receiver);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment