Ejemplo n.º 1
0
  @Test
  public void testGetCalendar() {
    JEEReportContext context = new JEEReportContext();

    TestPropertiesProvider provider = new TestPropertiesProvider();
    context.setPropertiesProvider(provider);

    java.net.URL url = JEEReportContextTest.class.getResource("/config/TestCalendar.json");

    if (url == null) {
      fail("Failed to find URL for test calendar");
    }

    provider.getProperties().put("calendar.Test", url.getFile());

    Calendar cal = context.getCalendar("Test", null);

    if (cal == null) {
      fail("Failed to get calendar");
    }

    if (!cal.getName().equals("Test")) {
      fail("Calendar name is not Test: " + cal.getName());
    }
  }
Ejemplo n.º 2
0
  @Test
  public void testSimSampleOnEventExternalRequestOperationUnexpected() {
    SCARoleSimulator sim = new SCARoleSimulator();

    try {
      SimulationModel simmodel = new SimulationModel("simsample.composite", null);

      Object model = sim.getModel(simmodel);

      if (model == null) {
        fail("Model is null");
      }

      java.net.URL url = ClassLoader.getSystemResource("req.data");

      java.io.File f = new java.io.File(url.getFile());

      DefaultSimulationContext context = new DefaultSimulationContext(f);
      context.setModel(model);
      sim.initialize(context);

      TestSimulationHandler handler = new TestSimulationHandler();

      Parameter param = new Parameter();
      param.setValue("req.data");

      ReceiveEvent event1 = new ReceiveEvent();
      event1.setOperationName("call");
      event1.getParameter().add(param);

      sim.onEvent(context, event1, handler);

      SendEvent event2 = new SendEvent();
      event2.setOperationName("callOutX");
      event2.getParameter().add(param);

      sim.onEvent(context, event2, handler);

      sim.close(context);

      if (handler.getErrorEvents().size() != 1) {
        fail("Should be 1 errors");
      }

      if (handler.getUnexpectedEvents().size() != 1) {
        fail("Should be 1 unexpected events");
      }

      if (handler.getNoSimulatorEvents().size() > 0) {
        fail("Should be no 'no simulator' events");
      }

      if (handler.getProcessedEvents().size() != 1) {
        fail("Should be 1 processed events");
      }

    } catch (Exception e) {
      fail("Exception occurred: " + e);
    }
  }
Ejemplo n.º 3
0
  @Test
  public void test_javaNetUrl() throws Exception {
    java.net.URL url =
        new java.net.URL(
            "http://*****:*****@10.20.130.230:20880/context/path?version=1.0.0&application=morgan#anchor1");

    assertEquals("http", url.getProtocol());
    assertEquals("admin:hello1234", url.getUserInfo());
    assertEquals("10.20.130.230", url.getHost());
    assertEquals(20880, url.getPort());
    assertEquals("/context/path", url.getPath());
    assertEquals("version=1.0.0&application=morgan", url.getQuery());
    assertEquals("anchor1", url.getRef());

    assertEquals("admin:[email protected]:20880", url.getAuthority());
    assertEquals("/context/path?version=1.0.0&application=morgan", url.getFile());
  }
Ejemplo n.º 4
0
  @Test
  public void testStoreServiceOnEventAllProcessed() {
    SCARoleSimulator sim = new SCARoleSimulator();

    try {
      SimulationModel simmodel = new SimulationModel("store/Store.composite", null);

      Object model = sim.getModel(simmodel);

      if (model == null) {
        fail("Model is null");
      }

      java.net.URL url = ClassLoader.getSystemResource("store/BuyRequest.xml");

      java.io.File f = new java.io.File(url.getFile());

      DefaultSimulationContext context = new DefaultSimulationContext(f);
      context.setModel(model);
      sim.initialize(context);

      TestSimulationHandler handler = new TestSimulationHandler();

      Parameter param = new Parameter();
      param.setValue("BuyRequest.xml");

      ReceiveEvent event2 = new ReceiveEvent();
      event2.setOperationName("buy");
      event2.getParameter().add(param);

      sim.onEvent(context, event2, handler);

      Parameter resp = new Parameter();
      resp.setValue("BuyConfirmed.xml");

      SendEvent event3 = new SendEvent();
      event3.setOperationName("buy");
      event3.getParameter().add(resp);

      sim.onEvent(context, event3, handler);

      sim.close(context);

      if (handler.getErrorEvents().size() > 0) {
        fail("Should be no errors");
      }

      if (handler.getUnexpectedEvents().size() > 0) {
        fail("Should be no unexpected events");
      }

      if (handler.getNoSimulatorEvents().size() > 0) {
        fail("Should be no 'no simulator' events");
      }

      if (handler.getProcessedEvents().size() != 2) {
        fail("Should be 2 processed events");
      }

    } catch (Exception e) {
      e.printStackTrace();
      fail("Exception occurred: " + e);
    }
  }