Java Code Examples for io.vertx.core.Context#config()

The following examples show how to use io.vertx.core.Context#config() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRestServerVerticle.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testRestServerVerticleWithRouter(@Mocked Transport transport, @Mocked Vertx vertx,
    @Mocked Context context,
    @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
  URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080");
  new Expectations() {
    {
      transport.parseAddress("http://127.0.0.1:8080");
      result = endpointObject;
    }
  };
  Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080");

  new Expectations() {
    {
      context.config();
      result = jsonObject;
      jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
      result = endpiont;
    }
  };
  RestServerVerticle server = new RestServerVerticle();
  // process stuff done by Expectations
  server.init(vertx, context);
  server.start(startFuture);
}
 
Example 2
Source File: TestRestServerVerticle.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testRestServerVerticleWithRouterSSL(@Mocked Transport transport, @Mocked Vertx vertx,
    @Mocked Context context,
    @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) throws Exception {
  URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?sslEnabled=true");
  new Expectations() {
    {
      transport.parseAddress("http://127.0.0.1:8080?sslEnabled=true");
      result = endpointObject;
    }
  };
  Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?sslEnabled=true");

  new Expectations() {
    {
      context.config();
      result = jsonObject;
      jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
      result = endpiont;
    }
  };
  RestServerVerticle server = new RestServerVerticle();
  // process stuff done by Expectations
  server.init(vertx, context);
  server.start(startFuture);
}
 
Example 3
Source File: Constants.java    From AlipayWechatPlatform with GNU General Public License v3.0 5 votes vote down vote up
public static void init(Context vertxContext) {
    Constants.vertx = vertxContext.owner();
    Constants.vertxContext = vertxContext;
    JsonObject config = vertxContext.config();
    PROJ_URL = config.getString("projectUrl", "http://itq46u.natappfree.cc/");
    CERT_DIR = config.getString("certDir", "/home/leibniz/");
    JDBC_URL = config.getString("jdbcUrl", "jdbc:mysql://127.0.0.1:3306/fission?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false");
    JDBC_USER = config.getString("jdbcUser", "root");
    JDBC_PSWD = config.getString("jdbcPassword", "turingdi");
    JDBC_DRIVER = config.getString("jdbcDriver", "com.mysql.cj.jdbc.Driver");
}
 
Example 4
Source File: TestRestServerVerticle.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testRestServerVerticleWithHttp2(@Mocked Transport transport, @Mocked Vertx vertx,
    @Mocked Context context,
    @Mocked JsonObject jsonObject, @Mocked Future<Void> startFuture) {
  URIEndpointObject endpointObject = new URIEndpointObject("http://127.0.0.1:8080?protocol=http2");
  new Expectations() {
    {
      transport.parseAddress("http://127.0.0.1:8080?protocol=http2");
      result = endpointObject;
    }
  };
  Endpoint endpiont = new Endpoint(transport, "http://127.0.0.1:8080?protocol=http2");

  new Expectations() {
    {
      context.config();
      result = jsonObject;
      jsonObject.getValue(AbstractTransport.ENDPOINT_KEY);
      result = endpiont;
    }
  };
  RestServerVerticle server = new RestServerVerticle();
  boolean status = false;
  try {
    server.init(vertx, context);
    server.start(startFuture);
  } catch (Exception e) {
    status = true;
  }
  Assert.assertFalse(status);
}
 
Example 5
Source File: TestHighwayVerticle.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Test
public void testHighwayVerticle(@Mocked Transport transport, @Mocked Vertx vertx, @Mocked Context context,
    @Mocked JsonObject json) {
  HighwayServerVerticle highwayVerticle = new HighwayServerVerticle();
  URIEndpointObject endpiontObject = new URIEndpointObject("highway://127.0.0.1:9090");
  new Expectations() {
    {
      transport.parseAddress(anyString);
      result = endpiontObject;
    }
  };

  Endpoint endpoint = new Endpoint(transport, "highway://127.0.0.1:9090");

  new Expectations() {
    {
      context.config();
      result = json;
      json.getValue(anyString);
      result = endpoint;
    }
  };

  highwayVerticle.init(vertx, context);
  @SuppressWarnings("unchecked")
  Future<Void> startFuture = Mockito.mock(Future.class);
  highwayVerticle.startListen(startFuture);
  MockUtil.getInstance().mockHighwayConfig();
  try {
    highwayVerticle.startListen(startFuture);
    assertTrue(true);
  } catch (Exception e) {
    Assert.fail();
  }
}
 
Example 6
Source File: NubesServer.java    From nubes with Apache License 2.0 5 votes vote down vote up
@Override
public void init(Vertx vertx, Context context) {
  super.init(vertx, context);
  JsonObject config = context.config();
  options = new HttpServerOptions();
  options.setHost(config.getString("host", "localhost"));
  options.setPort(config.getInteger("port", 9000));
  nubes = new VertxNubes(vertx, config);
}