Skip to content

Commit

Permalink
fix: some api unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxxoo committed Nov 22, 2021
1 parent 9566c6a commit 5152b3f
Show file tree
Hide file tree
Showing 46 changed files with 94 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
BACKEND: [memory, cassandra, scylladb, hbase, rocksdb, mysql, postgresql]
JAVA_VERSION: ['8', '17']
JAVA_VERSION: ['8', '11']

steps:
- name: Install JDK ${{ matrix.JAVA_VERSION }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.apache.commons.configuration2.YAMLConfiguration;
import org.apache.commons.configuration2.io.FileHandler;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.commons.configuration2.tree.NodeHandler;
import org.apache.commons.configuration2.tree.NodeModel;
import org.slf4j.Logger;

import com.baidu.hugegraph.HugeException;
Expand Down Expand Up @@ -171,15 +173,20 @@ private Map<String, Object> readSubConfig(String sub) {
List<HierarchicalConfiguration<ImmutableNode>> nodes =
this.config.childConfigurationsAt(sub);

E.checkArgument(nodes.size() == 1,
E.checkArgument(nodes.size() >= 1,
"Must contain one '%s' node",
sub);

HierarchicalConfiguration<ImmutableNode> node = nodes.get(0);
Map<String, Object> results = new HashMap<>(node.size());
for (Iterator<String> it = node.getKeys(); it.hasNext(); ) {
String key = it.next();
results.put(key, node.getProperty(key));
ImmutableNode root = null;
NodeModel<ImmutableNode> nodeModel = null;
NodeHandler<ImmutableNode> nodeHandler = null;
Map<String, Object> results = new HashMap<>(nodes.size());
for (HierarchicalConfiguration<ImmutableNode> node : nodes) {
E.checkArgument((nodeModel = node.getNodeModel()) != null
&& (nodeHandler = nodeModel.getNodeHandler()) != null
&& (root = nodeHandler.getRootNode()) != null,
"Node '%s' must contain root", node);
results.put(root.getNodeName(), root.getValue());
}

return results;
Expand Down
7 changes: 6 additions & 1 deletion hugegraph-dist/src/assembly/static/conf/gremlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ evaluationTimeout: 30000

channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
hugegraph: conf/hugegraph.properties
hugegraph: conf/hugegraph.properties,
}
authentication: {
authenticator: com.baidu.hugegraph.auth.StandardAuthenticator,
authenticationHandler: com.baidu.hugegraph.auth.WsAndHttpBasicAuthHandler,
config: {tokens: conf/rest-server.properties}
}
scriptEngines: {
gremlin-groovy: {
Expand Down
4 changes: 2 additions & 2 deletions hugegraph-dist/src/assembly/static/conf/hugegraph.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# gremlin entrance to create graph
# auth config: com.baidu.hugegraph.auth.HugeFactoryAuthProxy
gremlin.graph=com.baidu.hugegraph.HugeFactory
gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy
#gremlin.graph=com.baidu.hugegraph.HugeFactory

# cache config
#schema.cache_capacity=100000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ batch.max_write_threads=0

# authentication configs
# choose 'com.baidu.hugegraph.auth.StandardAuthenticator' or 'com.baidu.hugegraph.auth.ConfigAuthenticator'
#auth.authenticator=
auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator

# for StandardAuthenticator mode
#auth.graph_store=hugegraph
auth.graph_store=hugegraph
# auth client config
#auth.remote_url=127.0.0.1:8899,127.0.0.1:8898,127.0.0.1:8897

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Parameters;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.commons.configuration2.tree.NodeHandler;
import org.apache.commons.configuration2.tree.NodeModel;
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
import org.slf4j.Logger;

Expand Down Expand Up @@ -90,18 +92,20 @@ public static void main(String[] args) throws Exception {

List<HierarchicalConfiguration<ImmutableNode>> nodes =
config.childConfigurationsAt(GRAPHS);
E.checkArgument(nodes.size() == 1,
E.checkArgument(nodes.size() >= 1,
"Must contain one '%s' node in config file '%s'",
GRAPHS, gremlinConfFile);

HierarchicalConfiguration<ImmutableNode> node = nodes.get(0);
E.checkArgument(!node.isEmpty(),
"Must contain at least one graph");

for (Iterator<String> it = node.getKeys(); it.hasNext(); ) {
String graphName = it.next();
HugeFactory.checkGraphName(graphName, "gremlin-server.yaml");
String configPath = node.getProperty(graphName).toString();
ImmutableNode root = null;
NodeModel<ImmutableNode> nodeModel = null;
NodeHandler<ImmutableNode> nodeHandler = null;
for (HierarchicalConfiguration<ImmutableNode> node : nodes) {
E.checkArgument((nodeModel = node.getNodeModel()) != null
&& (nodeHandler = nodeModel.getNodeHandler()) != null
&& (root = nodeHandler.getRootNode()) != null,
"Node '%s' must contain root", node);
HugeFactory.checkGraphName(root.getNodeName(), "gremlin-server.yaml");
String configPath = root.getValue().toString();
initGraph(configPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.apache.http.util.TextUtils;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.glassfish.jersey.client.filter.EncodingFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.io.IOException;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Test;

import com.baidu.hugegraph.testutil.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
import java.nio.file.Paths;
import java.util.Map;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.junit.After;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Test;

import com.baidu.hugegraph.testutil.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Response;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package com.baidu.hugegraph.api;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Test;

import com.baidu.hugegraph.testutil.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package com.baidu.hugegraph.api;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Test;

public class SchemaApiTest extends BaseApiTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import com.google.common.collect.ImmutableMap;
import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.hamcrest.CoreMatchers;
import org.junit.After;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.io.IOException;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package com.baidu.hugegraph.api.traversers;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Before;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.Response;

import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down
Loading

0 comments on commit 5152b3f

Please sign in to comment.