//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: protected static String getResponseText(final org.neo4j.server.rest.JaxRsResponse response) protected internal static string GetResponseText(JaxRsResponse response) { string body = response.Entity; assertEquals(body, 200, response.Status); return(body); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAdvertiseExtensionThatPluginCreates() throws org.neo4j.server.rest.domain.JsonParseException, com.sun.jersey.api.client.ClientHandlerException, com.sun.jersey.api.client.UniformInterfaceException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAdvertiseExtensionThatPluginCreates() { int originalCount = NodeCount(); // Find the start node URI from the server JaxRsResponse response = (new RestRequest()).get(_functionalTestHelper.dataUri() + "node/1"); string entity = response.Entity; IDictionary <string, object> map = JsonHelper.jsonToMap(entity); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.HashMap<?, ?> extensionsMap = (java.util.HashMap<?, ?>) map.get("extensions"); Dictionary <object, ?> extensionsMap = (Dictionary <object, ?>)map["extensions"]; assertNotNull(extensionsMap); assertFalse(extensionsMap.Count == 0); const string graphClonerKey = "GraphCloner"; assertTrue(extensionsMap.Keys.Contains(graphClonerKey)); const string cloneSubgraphKey = "clonedSubgraph"; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: String clonedSubgraphUri = (String)((java.util.HashMap<?, ?>) extensionsMap.get(GRAPH_CLONER_KEY)).get(CLONE_SUBGRAPH_KEY); string clonedSubgraphUri = ( string )((Dictionary <object, ?>)extensionsMap[graphClonerKey])[cloneSubgraphKey];
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPassHeaders() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPassHeaders() { int httpPort = LocalHttpPort; string jsonData = (new PrettyJSON()).array().@object().key("method").value("GET").key("to").value("../.." + DUMMY_WEB_SERVICE_MOUNT_POINT + "/needs-auth-header").key("body").@object().endObject().endObject().endArray().ToString(); JaxRsResponse response = (new RestRequest(null, "user", "pass")).post(_server.baseUri() + "db/data/batch", jsonData); assertEquals(200, response.Status); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<java.util.Map<String, Object>> responseData = jsonToList(response.getEntity()); IList <IDictionary <string, object> > responseData = jsonToList(response.Entity); IDictionary <string, object> res = (IDictionary <string, object>)responseData[0]["body"]; /* * { * Accept=[application/json], * Content-Type=[application/json], * Authorization=[Basic dXNlcjpwYXNz], * User-Agent=[Java/1.6.0_27] <-- ignore that, it changes often * Host=[localhost:7474], * Connection=[keep-alive], * Content-Length=[86] * } */ assertEquals("Basic dXNlcjpwYXNz", res["Authorization"]); assertEquals("application/json", res["Accept"]); assertEquals("application/json", res["Content-Type"]); assertEquals("localhost:" + httpPort, res["Host"]); assertEquals("keep-alive", res["Connection"]); }
// It has to be possible to create relationships among created and not-created nodes // in batch operation. Tests the fix for issue #690. //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToReferToNotCreatedUniqueEntities() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToReferToNotCreatedUniqueEntities() { string jsonString = (new PrettyJSON()).array().@object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").@object().key("key").value("name").key("value").value("tobias").key("properties").@object().key("name").value("Tobias Tester").endObject().endObject().key("id").value(0).endObject().@object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").@object().key("key").value("name").key("value").value("andres").key("properties").@object().key("name").value("Andres Tester").endObject().endObject().key("id").value(1).endObject().@object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").@object().key("key").value("name").key("value").value("andres").key("properties").@object().key("name").value("Andres Tester").endObject().endObject().key("id").value(2).endObject().@object().key("method").value("POST").key("to").value("/index/relationship/my_rels/?unique").key("body").@object().key("key").value("name").key("value").value("tobias-andres").key("start").value("{0}").key("end").value("{1}").key("type").value("FRIENDS").endObject().key("id").value(3).endObject().@object().key("method").value("POST").key("to").value("/index/relationship/my_rels/?unique").key("body").@object().key("key").value("name").key("value").value("andres-tobias").key("start").value("{2}").key("end").value("{0}").key("type").value("FRIENDS").endObject().key("id").value(4).endObject().@object().key("method").value("POST").key("to").value("/index/relationship/my_rels/?unique").key("body").@object().key("key").value("name").key("value").value("andres-tobias").key("start").value("{1}").key("end").value("{0}").key("type").value("FRIENDS").endObject().key("id").value(5).endObject().endArray().ToString(); JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), jsonString); assertEquals(200, response.Status); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String entity = response.getEntity(); string entity = response.Entity; IList <IDictionary <string, object> > results = JsonHelper.jsonToList(entity); assertEquals(6, results.Count); IDictionary <string, object> andresResult1 = results[1]; IDictionary <string, object> andresResult2 = results[2]; IDictionary <string, object> secondRelationship = results[4]; IDictionary <string, object> thirdRelationship = results[5]; // Same people IDictionary <string, object> body1 = (IDictionary <string, object>)andresResult1["body"]; IDictionary <string, object> body2 = (IDictionary <string, object>)andresResult2["body"]; assertEquals(body1["id"], body2["id"]); // Same relationship body1 = (IDictionary <string, object>)secondRelationship["body"]; body2 = (IDictionary <string, object>)thirdRelationship["body"]; assertEquals(body1["self"], body2["self"]); // Created for {2} {0} assertTrue((( string )secondRelationship["location"]).Length > 0); // {2} = {1} = Andres body1 = (IDictionary <string, object>)secondRelationship["body"]; body2 = (IDictionary <string, object>)andresResult1["body"]; assertEquals(body1["start"], body2["self"]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testIsMasterOnStandaloneReturns403() public virtual void TestIsMasterOnStandaloneReturns403() { FunctionalTestHelper helper = new FunctionalTestHelper(_server); JaxRsResponse response = RestRequest.req().get(GetBasePath(helper) + IS_MASTER_PATH); assertEquals(SC_FORBIDDEN, response.Status); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToReferToUniquelyCreatedEntities() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToReferToUniquelyCreatedEntities() { string jsonString = (new PrettyJSON()).array().@object().key("method").value("POST").key("to").value("/index/node/Cultures?unique").key("body").@object().key("key").value("ID").key("value").value("fra").key("properties").@object().key("ID").value("fra").endObject().endObject().key("id").value(0).endObject().@object().key("method").value("POST").key("to").value("/node").key("id").value(1).endObject().@object().key("method").value("POST").key("to").value("{1}/relationships").key("body").@object().key("to").value("{0}").key("type").value("has").endObject().key("id").value(2).endObject().endArray().ToString(); JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), jsonString); assertEquals(200, response.Status); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldForwardUnderlyingErrors() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldForwardUnderlyingErrors() { JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), new PrettyJSON() .array().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").array().value(true).value("hello").endArray().endObject().endObject().endArray().ToString()); IDictionary <string, object> res = SingleResult(response, 0); assertTrue((( string )res["message"]).StartsWith("Invalid JSON array in POST body", StringComparison.Ordinal)); assertEquals(400, res["status"]); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void canListAllAvailableServerExtensions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CanListAllAvailableServerExtensions() { JaxRsResponse response = RestRequest.req().get(_functionalTestHelper.extensionUri()); assertThat(response.Status, equalTo(200)); IDictionary <string, object> json = JsonHelper.jsonToMap(response.Entity); assertFalse(json.Count == 0); response.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void datarootContainsReferenceToExtensions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DatarootContainsReferenceToExtensions() { JaxRsResponse response = RestRequest.req().get(_functionalTestHelper.dataUri()); assertThat(response.Status, equalTo(200)); IDictionary <string, object> json = JsonHelper.jsonToMap(response.Entity); new URI(( string )json["extensions_info"]); // throws on error response.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDiscoveryListingOnStandaloneDoesNotContainHA() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestDiscoveryListingOnStandaloneDoesNotContainHA() { FunctionalTestHelper helper = new FunctionalTestHelper(_server); JaxRsResponse response = RestRequest.req().get(helper.ManagementUri()); IDictionary <string, object> map = JsonHelper.jsonToMap(response.Entity); assertEquals(2, ((System.Collections.IDictionary)map["services"]).Count); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected static java.util.Map<String, Object> makePostMap(String url) throws org.neo4j.server.rest.domain.JsonParseException protected internal static IDictionary <string, object> MakePostMap(string url) { JaxRsResponse response = (new RestRequest()).post(url, null); string body = GetResponseText(response); response.Close(); return(DeserializeMap(body)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static java.util.Map<String, Object> makeGet(String url) throws org.neo4j.server.rest.domain.JsonParseException public static IDictionary <string, object> MakeGet(string url) { JaxRsResponse response = (new RestRequest()).get(url); string body = GetResponseText(response); response.Close(); return(DeserializeMap(body)); }
public virtual void Should401WithBasicChallengeWhenASecurityRuleFails() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyFailingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse response = Gen.get().expectedStatus(401).expectedHeader("WWW-Authenticate").post(_functionalTestHelper.nodeUri()).response(); assertThat(response.Headers.getFirst("WWW-Authenticate"), containsString("Basic realm=\"" + PermanentlyFailingSecurityRule.REALM + "\"")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleNullPath() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleNullPath() { long n = _functionalTestHelper.GraphDbHelper.createNode(); string url = GetPluginMethodUri(_functionalTestHelper.nodeUri(n), "pathToReference"); JaxRsResponse response = (new RestRequest()).post(url, null); assertThat(response.Entity, response.Status, @is(204)); response.Close(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected static java.util.List<java.util.Map<String, Object>> makePostList(String url, java.util.Map<String, Object> params) throws org.neo4j.server.rest.domain.JsonParseException protected internal static IList <IDictionary <string, object> > MakePostList(string url, IDictionary <string, object> @params) { string json = JsonHelper.createJsonFrom(@params); JaxRsResponse response = (new RestRequest()).post(url, json); string body = GetResponseText(response); response.Close(); return(DeserializeList(body)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected static java.util.Map<String, Object> makePostMap(String url, java.util.Map<String, Object> params) throws org.neo4j.server.rest.domain.JsonParseException protected internal static IDictionary <string, object> MakePostMap(string url, IDictionary <string, object> @params) { string json = JsonHelper.createJsonFrom(@params); JaxRsResponse response = (new RestRequest()).post(url, json, MediaType.APPLICATION_JSON_TYPE); string body = GetResponseText(response); response.Close(); return(DeserializeMap(body)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void should403WhenAuthenticatedButForbidden() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Should403WhenAuthenticatedButForbidden() { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withSecurityRules(typeof(PermanentlyForbiddenSecurityRule).FullName, typeof(PermanentlyPassingSecurityRule).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse clientResponse = Gen.get().expectedStatus(403).expectedType(MediaType.APPLICATION_JSON_TYPE).get(TrimTrailingSlash(_functionalTestHelper.baseUri())).response(); assertEquals(403, clientResponse.Status); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRollbackAllOnSingle404() throws org.neo4j.server.rest.domain.JsonParseException, com.sun.jersey.api.client.ClientHandlerException, com.sun.jersey.api.client.UniformInterfaceException, org.json.JSONException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRollbackAllOnSingle404() { string jsonString = (new PrettyJSON()).array().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").value(1).endObject().endObject().@object().key("method").value("POST").key("to").value("www.google.com").endObject().endArray().ToString(); long originalNodeCount = CountNodes(); JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), jsonString); assertEquals(200, response.Status); assertEquals(404, SingleResult(response, 1)["status"]); assertEquals(originalNodeCount, CountNodes()); }
public virtual void ASimpleWildcardUriPathShould401OnAccessToProtectedSubPath() { string mountPoint = "/protected/tree/starts/here" + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT; //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: _server = CommunityServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().withThirdPartyJaxRsPackage("org.dummy.web.service", mountPoint).withSecurityRules(typeof(PermanentlyFailingSecurityRuleWithWildcardPath).FullName).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build(); _server.start(); _functionalTestHelper = new FunctionalTestHelper(_server); JaxRsResponse clientResponse = Gen.get().expectedStatus(401).expectedType(MediaType.APPLICATION_JSON_TYPE).expectedHeader("WWW-Authenticate").get(TrimTrailingSlash(_functionalTestHelper.baseUri()) + mountPoint + "/more/stuff").response(); assertEquals(401, clientResponse.Status); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void boltAddressShouldComeFromConnectorAdvertisedAddress() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void BoltAddressShouldComeFromConnectorAdvertisedAddress() { // Given string host = "neo4j.com"; StartServerWithBoltEnabled(host, 9999, "localhost", 0); RestRequest request = (new RestRequest(_server.baseUri())).host(host); // When JaxRsResponse response = request.Get(); // Then IDictionary <string, object> map = JsonHelper.jsonToMap(response.Entity); assertThat(map["bolt"].ToString(), containsString("bolt://" + host + ":" + 9999)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Test public void canListExtensionMethodsForServerExtension() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CanListExtensionMethodsForServerExtension() { JaxRsResponse response = RestRequest.req().get(_functionalTestHelper.extensionUri()); assertThat(response.Status, equalTo(200)); IDictionary <string, object> json = JsonHelper.jsonToMap(response.Entity); string refNodeService = ( string )json[typeof(FunctionalTestPlugin).Name]; response.Close(); response = RestRequest.req().get(refNodeService); string result = response.Entity; assertThat(response.Status, equalTo(200)); json = JsonHelper.jsonToMap(result); json = (IDictionary <string, object>)json["graphdb"]; assertThat(json, hasKey(FunctionalTestPlugin.CREATE_NODE)); response.Close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRollbackAllWhenGivenIncorrectRequest() throws org.neo4j.server.rest.domain.JsonParseException, com.sun.jersey.api.client.ClientHandlerException, com.sun.jersey.api.client.UniformInterfaceException, org.json.JSONException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRollbackAllWhenGivenIncorrectRequest() { string jsonString = (new PrettyJSON()).array().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").value("1").endObject().endObject().@object().key("method").value("POST").key("to").value("/node").key("body").array().value("a_list").value("this_makes_no_sense").endArray().endObject().endArray().ToString(); long originalNodeCount = CountNodes(); JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), jsonString); assertEquals(200, response.Status); // Message of the ClassCastException differs in Oracle JDK [typeX cannot be cast to typeY] // and IBM JDK [typeX incompatible with typeY]. That is why we check parts of the message and exception class. IDictionary <string, string> body = (System.Collections.IDictionary)SingleResult(response, 1)["body"]; assertEquals(typeof(BadInputException).Name, body["exception"]); assertThat(body["message"], containsString("java.util.ArrayList")); assertThat(body["message"], containsString("java.util.Map")); assertEquals(400, SingleResult(response, 1)["status"]); assertEquals(originalNodeCount, CountNodes()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetLocationHeadersWhenCreatingThings() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGetLocationHeadersWhenCreatingThings() { long originalNodeCount = CountNodes(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String jsonString = new org.neo4j.server.rest.PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value(1).endObject().endObject().endArray().toString(); string jsonString = (new PrettyJSON()).array().@object().key("method").value("POST").key("to").value("/node").key("body").@object().key("age").value(1).endObject().endObject().endArray().ToString(); JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(Org.Neo4j.Server.rest.repr.StreamingFormat_Fields.STREAM_HEADER, "true").post(BatchUri(), jsonString); assertEquals(200, response.Status); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String entity = response.getEntity(); string entity = response.Entity; IList <IDictionary <string, object> > results = JsonHelper.jsonToList(entity); assertEquals(originalNodeCount + 1, CountNodes()); assertEquals(1, results.Count); IDictionary <string, object> result = results[0]; assertTrue((( string )result["location"]).Length > 0); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.util.Map<String, Object> singleResult(org.neo4j.server.rest.JaxRsResponse response, int i) throws org.neo4j.server.rest.domain.JsonParseException private IDictionary <string, object> SingleResult(JaxRsResponse response, int i) { return(JsonHelper.jsonToList(response.Entity)[i]); }