Search in sources :

Example 1 with BootstrapNormal

use of org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal in project incubator-servicecomb-java-chassis by apache.

the class TestInvoker method testConsumerInterfaceAsSchemaId.

@Test
public void testConsumerInterfaceAsSchemaId(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
    new Expectations() {

        {
            manager.getReferenceConfig("test");
            result = config;
            config.getMicroserviceMeta();
            result = microserviceMeta;
            microserviceMeta.findSchemaMeta(IPerson.class);
            result = null;
            microserviceMeta.ensureFindSchemaMeta(IPerson.class.getName());
        }
    };
    CseContext.getInstance().setConsumerProviderManager(manager);
    CseContext.getInstance().setConsumerSchemaFactory(factory);
    CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
    Invoker invoker = new Invoker("test", null, IPerson.class);
    invoker.prepare();
    SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
    Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
Also used : Expectations(mockit.Expectations) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) BootstrapNormal(org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal) Test(org.junit.Test)

Example 2 with BootstrapNormal

use of org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal in project incubator-servicecomb-java-chassis by apache.

the class TestInvoker method testNormalSchemaId.

@Test
public void testNormalSchemaId(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
    new Expectations() {

        {
            manager.getReferenceConfig("test");
            result = config;
            config.getMicroserviceMeta();
            result = microserviceMeta;
            microserviceMeta.ensureFindSchemaMeta("schemaId");
        }
    };
    CseContext.getInstance().setConsumerProviderManager(manager);
    CseContext.getInstance().setConsumerSchemaFactory(factory);
    CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
    Invoker invoker = new Invoker("test", "schemaId", IPerson.class);
    invoker.prepare();
    SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
    Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
Also used : Expectations(mockit.Expectations) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) BootstrapNormal(org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal) Test(org.junit.Test)

Example 3 with BootstrapNormal

use of org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal in project incubator-servicecomb-java-chassis by apache.

the class TestInvoker method testFindSchemaByConsumerInterface.

@Test
public void testFindSchemaByConsumerInterface(@Injectable ConsumerProviderManager manager, @Injectable ReferenceConfig config, @Injectable MicroserviceMeta microserviceMeta, @Injectable ConsumerSchemaFactory factory) {
    new Expectations() {

        {
            manager.getReferenceConfig("test");
            result = config;
            config.getMicroserviceMeta();
            result = microserviceMeta;
            microserviceMeta.findSchemaMeta(IPerson.class);
        }
    };
    CseContext.getInstance().setConsumerProviderManager(manager);
    CseContext.getInstance().setConsumerSchemaFactory(factory);
    CseContext.getInstance().setSwaggerEnvironment(new BootstrapNormal().boot());
    Invoker invoker = new Invoker("test", null, IPerson.class);
    invoker.prepare();
    SwaggerConsumer swaggerConsumer = Deencapsulation.getField(invoker, "swaggerConsumer");
    Assert.assertEquals(IPerson.class, swaggerConsumer.getConsumerIntf());
}
Also used : Expectations(mockit.Expectations) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) BootstrapNormal(org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal) Test(org.junit.Test)

Example 4 with BootstrapNormal

use of org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal in project incubator-servicecomb-java-chassis by apache.

the class TestPojoConsumerEqualProducer method init.

@BeforeClass
public static void init() {
    env = new BootstrapNormal().boot();
    producer = env.createProducer(new PojoImpl());
    consumer = env.createConsumer(PojoConsumerIntf.class, producer.getSwaggerIntf());
    invoker = new LocalProducerInvoker(consumer, producer);
    proxy = invoker.getProxy();
}
Also used : PojoConsumerIntf(org.apache.servicecomb.swagger.invocation.models.PojoConsumerIntf) PojoImpl(org.apache.servicecomb.swagger.invocation.models.PojoImpl) BootstrapNormal(org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal) LocalProducerInvoker(org.apache.servicecomb.swagger.engine.unittest.LocalProducerInvoker) BeforeClass(org.junit.BeforeClass)

Example 5 with BootstrapNormal

use of org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal in project incubator-servicecomb-java-chassis by apache.

the class TestPojoConsumerEqualSwagger method init.

@BeforeClass
public static void init() {
    env = new BootstrapNormal().boot();
    producer = env.createProducer(new JaxrsImpl());
    consumer = env.createConsumer(PojoConsumerIntf.class, producer.getSwaggerIntf());
    invoker = new LocalProducerInvoker(consumer, producer);
    proxy = invoker.getProxy();
}
Also used : PojoConsumerIntf(org.apache.servicecomb.swagger.invocation.models.PojoConsumerIntf) JaxrsImpl(org.apache.servicecomb.swagger.invocation.models.JaxrsImpl) BootstrapNormal(org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal) LocalProducerInvoker(org.apache.servicecomb.swagger.engine.unittest.LocalProducerInvoker) BeforeClass(org.junit.BeforeClass)

Aggregations

BootstrapNormal (org.apache.servicecomb.swagger.engine.bootstrap.BootstrapNormal)5 Expectations (mockit.Expectations)3 SwaggerConsumer (org.apache.servicecomb.swagger.engine.SwaggerConsumer)3 Test (org.junit.Test)3 LocalProducerInvoker (org.apache.servicecomb.swagger.engine.unittest.LocalProducerInvoker)2 PojoConsumerIntf (org.apache.servicecomb.swagger.invocation.models.PojoConsumerIntf)2 BeforeClass (org.junit.BeforeClass)2 JaxrsImpl (org.apache.servicecomb.swagger.invocation.models.JaxrsImpl)1 PojoImpl (org.apache.servicecomb.swagger.invocation.models.PojoImpl)1