Skip to content

Commit

Permalink
Upgraded jmh and xmlunit in order to build using jdk9
Browse files Browse the repository at this point in the history
  • Loading branch information
d-michail committed Dec 15, 2017
1 parent 85a1282 commit 99e85b4
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 52 deletions.
4 changes: 2 additions & 2 deletions jgrapht-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.10.3</version>
<version>1.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.10.3</version>
<version>1.19</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
* multiple graphs. Not sure how to achieve that through the JMH framework.
*/
public class GraphPerformanceTest
extends TestCase
extends
TestCase
{

public static final int PERF_BENCHMARK_VERTICES_COUNT = 1000;
Expand All @@ -71,7 +72,8 @@ private static abstract class DirectedGraphBenchmarkBase
@Setup
public void setup()
{
blackhole = new Blackhole();
blackhole = new Blackhole(
"Today's password is swordfish. I understand instantiating Blackholes directly is dangerous.");
}

/**
Expand Down Expand Up @@ -167,7 +169,8 @@ private void destroyRandomEdges(
* optimized for low memory usage, but performs edge retrieval operations fairly slow.
*/
public static class MemoryEfficientDirectedGraphBenchmark
extends DirectedGraphBenchmarkBase
extends
DirectedGraphBenchmarkBase
{
@Override
SimpleDirectedWeightedGraph<Integer, DefaultWeightedEdge> constructGraph()
Expand All @@ -184,7 +187,8 @@ SimpleDirectedWeightedGraph<Integer, DefaultWeightedEdge> constructGraph()
* perform quick edge retrievals.
*/
public static class FastLookupDirectedGraphBenchmark
extends DirectedGraphBenchmarkBase
extends
DirectedGraphBenchmarkBase
{
@Override
SimpleDirectedWeightedGraph<Integer, DefaultWeightedEdge> constructGraph()
Expand Down Expand Up @@ -219,7 +223,8 @@ public void testRandomGraphBenchmark()
* @param <E> the graph edge type
*/
public static class MemoryEfficientDirectedWeightedGraph<V, E>
extends SimpleDirectedWeightedGraph<V, E>
extends
SimpleDirectedWeightedGraph<V, E>
{
private static final long serialVersionUID = -1826738982402033648L;

Expand Down
4 changes: 0 additions & 4 deletions jgrapht-ext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@
<artifactId>jgraph</artifactId>
<version>5.13.0.0</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
10 changes: 6 additions & 4 deletions jgrapht-io/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jgrapht</groupId>
Expand Down Expand Up @@ -36,7 +37,8 @@
</executions>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<!-- Use unique OSGi bundle symbolic name for uber artifact. Otherwise
e.g. jgrapht-io-x.y.z.jar and jgrapht-io-x.y.z-uber.jar could not be deployed
Expand Down Expand Up @@ -169,8 +171,8 @@
<artifactId>jgrapht-core</artifactId>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
101 changes: 68 additions & 33 deletions jgrapht-io/src/test/java/org/jgrapht/io/GraphMLExporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@
*/
package org.jgrapht.io;

import java.io.*;
import java.util.*;

import org.custommonkey.xmlunit.*;
import org.jgrapht.*;
import org.jgrapht.graph.*;
import org.jgrapht.io.GraphMLExporter.*;

import junit.framework.*;
import java.io.ByteArrayOutputStream;
import java.util.LinkedHashMap;
import java.util.Map;

import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleDirectedGraph;
import org.jgrapht.graph.SimpleGraph;
import org.jgrapht.graph.SimpleWeightedGraph;
import org.jgrapht.io.GraphMLExporter.AttributeCategory;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;

import junit.framework.TestCase;

/**
* @author Trevor Harmon
* @author Dimitrios Michail
*/
public class GraphMLExporterTest
extends TestCase
extends
TestCase
{
// ~ Static fields/initializers
// ---------------------------------------------
Expand All @@ -50,7 +57,7 @@ public void testUndirected()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand All @@ -77,15 +84,17 @@ public void testUndirected()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeighted()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -116,14 +125,17 @@ public void testUndirectedWeighted()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testDirected()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -151,14 +163,17 @@ public void testDirected()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedUnweightedWithWeights()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -189,14 +204,17 @@ public void testUndirectedUnweightedWithWeights()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeightedWithWeights()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -230,14 +248,17 @@ public void testUndirectedWeightedWithWeights()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeightedWithCustomNameWeights()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -273,7 +294,10 @@ public void testUndirectedWeightedWithCustomNameWeights()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testNoRegisterWeightAttribute()
Expand Down Expand Up @@ -318,7 +342,7 @@ public void testUndirectedWeightedWithWeightsAndLabels()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -383,14 +407,17 @@ public String getName(DefaultWeightedEdge edge)
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeightedWithWeightsAndLabelsAndCustomNames()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -457,15 +484,17 @@ public String getName(DefaultWeightedEdge edge)
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);


Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeightedWithWeightsAndColor()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -567,14 +596,17 @@ public Map<String, Attribute> getComponentAttributes(DefaultWeightedEdge e)
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

public void testUndirectedWeightedWithNullComponentProvider()
throws Exception
{
String output =
// @formatter:off
// @formatter:off
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL
+ "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" "
+ "xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns "
Expand Down Expand Up @@ -612,8 +644,8 @@ public void testUndirectedWeightedWithNullComponentProvider()

GraphMLExporter<String,
DefaultWeightedEdge> exporter = new GraphMLExporter<>(
new IntegerComponentNameProvider<>(), null, v->null,
new IntegerComponentNameProvider<>(), null, e->null);
new IntegerComponentNameProvider<>(), null, v -> null,
new IntegerComponentNameProvider<>(), null, e -> null);
exporter.setExportEdgeWeights(true);
exporter.registerAttribute(
"color", GraphMLExporter.AttributeCategory.NODE, AttributeType.STRING, "yellow");
Expand All @@ -622,7 +654,10 @@ public void testUndirectedWeightedWithNullComponentProvider()
ByteArrayOutputStream os = new ByteArrayOutputStream();
exporter.exportGraph(g, os);
String res = new String(os.toByteArray(), "UTF-8");
XMLAssert.assertXMLEqual(output, res);

Diff diff = DiffBuilder
.compare(res).withTest(output).ignoreWhitespace().checkForIdentical().build();
assertFalse("XML identical " + diff.toString(), diff.hasDifferences());
}

}
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.3</version>
<scope>test</scope>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>2.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down

0 comments on commit 99e85b4

Please sign in to comment.