@Bean
 @RefreshScope
 public TestService service() {
   TestService service = new TestService();
   service.setMessage(properties().getMessage());
   service.setDelay(properties().getDelay());
   return service;
 }
 @Test
 @DirtiesContext
 public void testSimpleProperties() throws Exception {
   assertEquals("Hello scope!", service.getMessage());
   assertTrue(service instanceof Advised);
   // Change the dynamic property source...
   EnvironmentTestUtils.addEnvironment(environment, "message:Foo");
   // ...but don't refresh, so the bean stays the same:
   assertEquals("Hello scope!", service.getMessage());
   assertEquals(1, TestService.getInitCount());
   assertEquals(0, TestService.getDestroyCount());
 }
  @Test
  public void whenTimeoutNotInterruptible() throws InterruptedException {
    TestService testService = proxyProvider.getProxy(TestService.class);

    try {
      testService.fiveSecondTimeoutNotInterruptible(10000);
      fail();
    } catch (DistributedMethodTimeoutException expected) {

    }
    Thread.sleep(10000);

    assertFalse(pojo.testService.interrupted.get());
  }
Esempio n. 4
0
  public static void main(String args[]) throws Exception {

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getInInterceptors().add(new LoggingInInterceptor());
    factory.getOutInterceptors().add(new LoggingOutInterceptor());
    factory.setServiceClass(TestService.class);
    // factory.setAddress("http://localhost:9098/testService");
    factory.setAddress("http://localhost:9099/testService");

    TestService client = (TestService) factory.create();

    String reply = client.sayHi("HI");
    System.out.println("Server said: " + reply);
    System.exit(0);
  }
  /*
   * Simple end to end test (mostly for debug work)
   */
  public void testHelloOneWay() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    tracker.clearAll();

    TestService_Service service = getService();
    TestService test = getTestStub(service);
    ReportService report = getReportStub(service);

    report.clearHandlerTracker();

    test.testIntOneWay(0);

    // make normal call after
    assertEquals("did not get expected response", 4, test.testInt(4));

    System.out.println("ok");
  }
  /*
   * Simple end to end test (mostly for debug work)
   */
  public void testHello() throws Exception {
    HandlerTracker tracker = HandlerTracker.getClientInstance();
    tracker.clearAll();

    TestService_Service service = getService();
    TestService test = getTestStub(service);
    ReportService report = getReportStub(service);

    report.clearHandlerTracker();

    int foo = -1;
    int bar = test.testInt(foo);
    assertTrue(foo == bar);
    System.out.println("ok");

    List<String> closedHandlers = report.getReport(TestConstants.REPORT_CLOSED_HANDLERS);

    List<String> handlers = report.getReport(TestConstants.REPORT_CALLED_HANDLERS);
    assertNotNull("received null list back from server", handlers);
  }
Esempio n. 7
0
 @java.lang.SuppressWarnings("unchecked")
 public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
   switch (methodId) {
     case METHODID_UNARY_CALL:
       serviceImpl.unaryCall(
           (io.grpc.testing.SimpleRequest) request,
           (io.grpc.stub.StreamObserver<io.grpc.testing.SimpleResponse>) responseObserver);
       break;
     default:
       throw new AssertionError();
   }
 }
 public boolean inDataBase(ProblemEntity problemEntity) {
   List<TestEntity> testEntities = testService.getTestes();
   for (TestEntity testEntity : testEntities) {
     List<String> problemEntities = testEntity.getProblems();
     for (String problemKey : problemEntities) {
       if (problemEntity.getKey().equals(problemKey)) {
         return true;
       }
     }
   }
   return false;
 }
  public List<ProblemEntity> getProblems(String testEntityKey) {
    TestEntity testEntity = testService.getTestById(testEntityKey);
    List<ProblemEntity> problemEntities = new ArrayList<ProblemEntity>();

    List<String> problems = testEntity.getProblems();
    for (String key : problems) {
      ProblemEntity problem = new ProblemEntity();
      problem = (ProblemEntity) persistenceManager.getObjectById(ProblemEntity.class, key);
      problemEntities.add(problem);
    }
    return problemEntities;
  }
Esempio n. 10
0
 @java.lang.SuppressWarnings("unchecked")
 public io.grpc.stub.StreamObserver<Req> invoke(
     io.grpc.stub.StreamObserver<Resp> responseObserver) {
   switch (methodId) {
     case METHODID_STREAMING_CALL:
       return (io.grpc.stub.StreamObserver<Req>)
           serviceImpl.streamingCall(
               (io.grpc.stub.StreamObserver<io.grpc.testing.SimpleResponse>) responseObserver);
     default:
       throw new AssertionError();
   }
 }
 @Test
 @DirtiesContext
 public void testRefreshFails() throws Exception {
   assertEquals("Hello scope!", service.getMessage());
   // Change the dynamic property source...
   EnvironmentTestUtils.addEnvironment(environment, "message:Foo", "delay:foo");
   // ...and then refresh, so the bean is re-initialized:
   scope.refreshAll();
   try {
     // If a refresh fails (e.g. a binding error in this case) the application is
     // basically hosed.
     assertEquals("Hello scope!", service.getMessage());
     fail("expected BeanCreationException");
   } catch (BeanCreationException e) {
   }
   // But we can fix it by fixing the binding error:
   EnvironmentTestUtils.addEnvironment(environment, "delay:0");
   // ...and then refresh, so the bean is re-initialized:
   scope.refreshAll();
   assertEquals("Foo", service.getMessage());
 }
Esempio n. 12
0
  @Test
  public void sample_save_should_form_test_to_sample_associations() throws Exception {
    testService.createOrUpdate(referenceDataTest);
    us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name");
    assertEquals("Test Name", savedTest.getTestName());
    assertEquals("New", savedTest.getTestSection().getTestSectionName());

    referenceDataSample.addTest(
        new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName()));
    typeOfSampleService.createOrUpdate(referenceDataSample);
    TypeOfSample savedSample = typeOfSampleDAO.getTypeOfSampleByUUID(sampleUuid);
    assertEquals("Sample Name", savedSample.getDescription());
    assertEquals("Sample Name", savedSample.getLocalAbbreviation());
    TypeOfSampleTest sampleTestAssoc =
        typeOfSampleTestDAO.getTypeOfSampleTestForTest(savedTest.getId());
    assertNotNull(sampleTestAssoc);
    assertEquals(savedTest.getId(), sampleTestAssoc.getTestId());
    assertEquals(savedSample.getId(), sampleTestAssoc.getTypeOfSampleId());
  }
 @Test
 @DirtiesContext
 public void testRefresh() throws Exception {
   assertEquals("Hello scope!", service.getMessage());
   String id1 = service.toString();
   // Change the dynamic property source...
   EnvironmentTestUtils.addEnvironment(environment, "message:Foo");
   // ...and then refresh, so the bean is re-initialized:
   scope.refreshAll();
   String id2 = service.toString();
   assertEquals("Foo", service.getMessage());
   assertEquals(2, TestService.getInitCount());
   assertEquals(1, TestService.getDestroyCount());
   assertNotSame(id1, id2);
 }
Esempio n. 14
0
  @Test
  public void associate_tests_with_panel() throws Exception {
    testService.createOrUpdate(referenceDataTest);

    us.mn.state.health.lims.test.valueholder.Test savedTest = testDAO.getTestByName("Test Name");
    assertEquals("Test Name", savedTest.getTestName());
    assertEquals("New", savedTest.getTestSection().getTestSectionName());

    referenceDataPanel.addTest(
        new MinimalResource(referenceDataTest.getId(), referenceDataTest.getName()));
    panelService.createOrUpdate(referenceDataPanel);

    Panel savedPanel = panelDAO.getPanelByName("Panel Name");
    assertNotNull(savedPanel);
    assertEquals("Panel Name", savedPanel.getDescription());

    List panelTestAssoc = panelItemDAO.getPanelItemsForPanel(savedPanel.getId());
    assertNotNull(panelTestAssoc);
    assertEquals(1, panelTestAssoc.size());
    PanelItem panelItem = (PanelItem) panelTestAssoc.get(0);
    assertEquals(savedTest.getId(), panelItem.getTest().getId());
  }
 @Before
 public void init() {
   TestService.reset();
 }
 @Test
 public void whenCallDoesntTimeout() {
   TestService testService = proxyProvider.getProxy(TestService.class);
   testService.fiveSecondTimeoutAndInterruptible(1000);
 }
 @Test
 public void testRegisterBean() {
   IocManager.getManager().registBean(TestService.class);
   TestService service = IocManager.getManager().getBean(TestService.class);
   Assert.assertEquals("Hello IOC", service.printHello());
 }