@Test
  public void testArrayResponse() {
    Swagger swagger = new Swagger();

    ArrayProperty schema = new ArrayProperty();
    schema.setItems(new ObjectProperty().property("name", new StringProperty()));

    swagger.path(
        "/foo/baz",
        new Path()
            .get(
                new Operation()
                    .response(
                        200,
                        new Response()
                            .vendorExtension("x-foo", "bar")
                            .description("it works!")
                            .schema(schema))));
    new InlineModelResolver().flatten(swagger);

    Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");
    assertTrue(response.getSchema() instanceof ArrayProperty);

    ArrayProperty am = (ArrayProperty) response.getSchema();
    Property items = am.getItems();
    assertTrue(items instanceof ObjectProperty);
    ObjectProperty op = (ObjectProperty) items;
    Property name = op.getProperties().get("name");
    assertTrue(name instanceof StringProperty);
  }
 public void verifyCommentRowContent(
     String commentRowIdSuffix, String commentText, String giverName) {
   WebDriverWait wait = new WebDriverWait(browser.driver, 30);
   WebElement commentRow;
   try {
     commentRow =
         wait.until(
             ExpectedConditions.presenceOfElementLocated(
                 By.id("responseCommentRow" + commentRowIdSuffix)));
   } catch (TimeoutException e) {
     fail("Timeout!");
     commentRow = null;
   }
   try {
     wait.until(
         ExpectedConditions.textToBePresentInElement(
             commentRow.findElement(By.id("plainCommentText" + commentRowIdSuffix)), commentText));
   } catch (TimeoutException e) {
     fail("Not expected message");
   }
   try {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains(giverName));
   } catch (AssertionError e) {
     assertTrue(commentRow.findElement(By.className("text-muted")).getText().contains("you"));
   }
 }
 @Test
 /** Tests the comparison tool. */
 public void compare() {
   // Matrix with itself
   final FXMatrix fxMatrix1 = new FXMatrix();
   fxMatrix1.addCurrency(GBP, EUR, GBP_EUR);
   fxMatrix1.addCurrency(USD, EUR, 1.0d / EUR_USD);
   assertTrue(
       "FXMatrixUtils - compare", FXMatrixUtils.compare(fxMatrix1, fxMatrix1, TOLERANCE_RATE));
   // Matrix in a different order
   final FXMatrix fxMatrix2 = new FXMatrix();
   fxMatrix2.addCurrency(EUR, USD, EUR_USD);
   fxMatrix2.addCurrency(GBP, EUR, GBP_EUR);
   assertTrue(
       "FXMatrixUtils - compare", FXMatrixUtils.compare(fxMatrix1, fxMatrix2, TOLERANCE_RATE));
   // Matrix with different order rate
   final FXMatrix fxMatrix3 = new FXMatrix();
   fxMatrix3.addCurrency(EUR, USD, EUR_USD + 1.0E-5);
   fxMatrix3.addCurrency(GBP, EUR, GBP_EUR);
   assertFalse(
       "FXMatrixUtils - compare", FXMatrixUtils.compare(fxMatrix1, fxMatrix3, TOLERANCE_RATE));
   // Matrix with different currencies
   final FXMatrix fxMatrix4 = new FXMatrix();
   fxMatrix4.addCurrency(GBP, EUR, GBP_EUR);
   fxMatrix4.addCurrency(USD, EUR, 1.0d / EUR_USD);
   fxMatrix4.addCurrency(KRW, USD, 1.0 / USD_KRW);
   assertFalse(
       "FXMatrixUtils - compare", FXMatrixUtils.compare(fxMatrix1, fxMatrix4, TOLERANCE_RATE));
 }
 @Test
 public void testMixed() {
   final DoubleMatrix2D jacobian = MIXED.evaluate(XNM);
   assertEquals(N + M, jacobian.getNumberOfRows());
   assertEquals(N + M, jacobian.getNumberOfColumns());
   for (int i = 0; i < N; i++) {
     for (int j = 0; j < N + M; j++) {
       if (i == j) {
         assertTrue(jacobian.getEntry(i, j) > 0.0);
       } else if (i == (j + 1)) {
         assertTrue(jacobian.getEntry(i, j) < 0.0);
       } else {
         assertEquals(0.0, jacobian.getEntry(i, j), 0.0);
       }
     }
   }
   for (int i = N; i < N + M; i++) {
     for (int j = 0; j < N + M; j++) {
       if (i == j) {
         assertEquals(Math.exp(XNM.getEntry(i) * (i - N)), jacobian.getEntry(i, i), 1e-8);
       } else {
         assertEquals(0.0, jacobian.getEntry(i, j), 0.0);
       }
     }
   }
 }
 @Test(dependsOnMethods = {"testMetadataLevel"})
 public void testLogicalChannelRefs() {
   Class<? extends IObject> klass = LogicalChannel.class;
   List<IObjectContainer> containers = store.getIObjectContainers(klass);
   referenceCache = store.getReferenceCache();
   for (IObjectContainer container : containers) {
     LSID lsid = new LSID(container.LSID);
     if (!referenceCache.containsKey(lsid)) {
       continue;
     }
     List<LSID> references = referenceCache.get(lsid);
     assertTrue(references.size() > 0);
     for (LSID referenceLSID : references) {
       String asString = referenceLSID.toString();
       if (asString.endsWith(OMEROMetadataStoreClient.OMERO_EMISSION_FILTER_SUFFIX)
           || asString.endsWith(OMEROMetadataStoreClient.OMERO_EXCITATION_FILTER_SUFFIX)) {
         int index = asString.lastIndexOf(':');
         referenceLSID = new LSID(asString.substring(0, index));
       }
       assertNotNull(referenceLSID);
       List<Class<? extends IObject>> klasses = new ArrayList<Class<? extends IObject>>();
       klasses.add(Filter.class);
       klasses.add(FilterSet.class);
       String e = String.format("LSID %s not found in container cache", referenceLSID);
       assertTrue(e, authoritativeLSIDExists(klasses, referenceLSID));
     }
   }
 }
  public void testQueryForListOnCobarSqlMapClientTemplate() {
    // 1. initialize data
    String[] names = {"Aaron", "Amily", "Aragon", "Darren", "Darwin"};
    batchInsertMultipleFollowersAsFixture(names);

    // 2. perform assertion
    @SuppressWarnings("unchecked")
    List<Follower> resultList =
        (List<Follower>)
            getSqlMapClientTemplate()
                .queryForList("com.alibaba.cobar.client.entities.Follower.findAll");
    assertTrue(CollectionUtils.isNotEmpty(resultList));
    assertEquals(5, resultList.size());
    for (Follower f : resultList) {
      assertTrue(ArrayUtils.contains(names, f.getName()));
    }

    // 3. perform assertion with another different query
    @SuppressWarnings("unchecked")
    List<Follower> followersWithNameStartsWithA =
        (List<Follower>)
            getSqlMapClientTemplate()
                .queryForList("com.alibaba.cobar.client.entities.Follower.finaByNameAlike", "A");
    assertTrue(CollectionUtils.isNotEmpty(followersWithNameStartsWithA));
    assertEquals(3, followersWithNameStartsWithA.size());
    for (Follower f : followersWithNameStartsWithA) {
      assertTrue(ArrayUtils.contains(names, f.getName()));
    }
  }
  @Test
  public void testSingleViewMultipleClients() {
    ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    env.init();
    ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();

    ViewClient client1 = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    assertNotNull(client1.getUniqueId());

    client1.attachToViewProcess(
        env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));
    ViewProcessImpl client1Process = env.getViewProcess(vp, client1.getUniqueId());
    assertTrue(client1Process.getState() == ViewProcessState.RUNNING);

    ViewClient client2 = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    assertNotNull(client2.getUniqueId());
    assertFalse(client1.getUniqueId().equals(client2.getUniqueId()));

    client2.attachToViewProcess(
        env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));
    ViewProcessImpl client2Process = env.getViewProcess(vp, client2.getUniqueId());
    assertEquals(client1Process, client2Process);
    assertTrue(client2Process.getState() == ViewProcessState.RUNNING);

    client1.detachFromViewProcess();
    assertTrue(client2Process.getState() == ViewProcessState.RUNNING);

    client2.detachFromViewProcess();
    assertTrue(client2Process.getState() == ViewProcessState.TERMINATED);

    client1.shutdown();
    client2.shutdown();
  }
  private void assertCreationOfNodes(String firstNodeId, String secondNodeId) {
    // group1 started first, then cluster started later
    long startTime = System.currentTimeMillis();
    Map<String, Long> activeMembers = TopologyHandler.getInstance().getActivateddMembers();
    Map<String, Long> createdMembers = TopologyHandler.getInstance().getCreatedMembers();
    // Active member should be available at the time cluster is started to create.
    while (!activeMembers.containsKey(firstNodeId)) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignored) {
      }
      activeMembers = TopologyHandler.getInstance().getActivateddMembers();
      if ((System.currentTimeMillis() - startTime) > GROUP_ACTIVE_TIMEOUT) {
        break;
      }
    }
    assertTrue(activeMembers.containsKey(firstNodeId));

    while (!createdMembers.containsKey(secondNodeId)) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignore) {
      }
      createdMembers = TopologyHandler.getInstance().getCreatedMembers();
      if ((System.currentTimeMillis() - startTime) > GROUP_ACTIVE_TIMEOUT) {
        break;
      }
    }

    assertTrue(createdMembers.containsKey(secondNodeId));

    assertTrue(createdMembers.get(secondNodeId) > activeMembers.get(firstNodeId));
  }
  @Test
  public void test() {
    final int n = 12;
    final GaussianQuadratureData f1 = GAUSS_LEGENDRE.generate(n);
    final GaussianQuadratureData f2 = GAUSS_JACOBI_GL_EQUIV.generate(n);
    final GaussianQuadratureData f3 = GAUSS_JACOBI_CHEBYSHEV_EQUIV.generate(n);
    final double[] w1 = f1.getWeights();
    final double[] w2 = f2.getWeights();
    final double[] x1 = f1.getAbscissas();
    final double[] x2 = f2.getAbscissas();
    assertTrue(w1.length == w2.length);
    assertTrue(x1.length == x2.length);
    for (int i = 0; i < n; i++) {
      assertEquals(w1[i], w2[i], EPS);
      assertEquals(x1[i], -x2[i], EPS);
    }
    final double[] w3 = f3.getWeights();
    final double[] x3 = f3.getAbscissas();
    final double chebyshevWeight = Math.PI / n;
    final Function1D<Integer, Double> chebyshevAbscissa =
        new Function1D<Integer, Double>() {

          @Override
          public Double evaluate(final Integer x) {
            return -Math.cos(Math.PI * (x + 0.5) / n);
          }
        };
    for (int i = 0; i < n; i++) {
      assertEquals(chebyshevWeight, w3[i], EPS);
      assertEquals(chebyshevAbscissa.evaluate(i), -x3[i], EPS);
    }
  }
Example #10
0
  @Test
  public void testConstructorReaderTimeElapsedDirectory() throws Exception {

    String uuid = UUID.randomUUID().toString();
    File directory = new File(System.getProperty("java.io.tmpdir"), uuid);
    memoizer = new Memoizer(reader, 0, directory);

    // Check non-existing memo directory returns null
    assertEquals(memoizer.getMemoFile(id), null);

    // Create memoizer directory and memoizer reader
    directory.mkdirs();

    String memoDir = idDir.getAbsolutePath();
    memoDir = memoDir.substring(memoDir.indexOf(File.separator) + 1);
    File memoFile = new File(directory, memoDir);
    memoFile = new File(memoFile, "." + TEST_FILE + ".bfmemo");
    File f = memoizer.getMemoFile(id);
    assertEquals(f.getAbsolutePath(), memoFile.getAbsolutePath());

    // Test multiple setId invocations
    memoizer.setId(id);
    assertFalse(memoizer.isLoadedFromMemo());
    assertTrue(memoizer.isSavedToMemo());
    memoizer.close();
    memoizer.setId(id);
    assertTrue(memoizer.isLoadedFromMemo());
    assertFalse(memoizer.isSavedToMemo());
    memoizer.close();
  }
  @Test
  public void resolveInlineBodyParameter() throws Exception {
    Swagger swagger = new Swagger();

    swagger.path(
        "/hello",
        new Path()
            .get(
                new Operation()
                    .parameter(
                        new BodyParameter()
                            .name("body")
                            .schema(
                                new ModelImpl()
                                    .property(
                                        "address",
                                        new ObjectProperty()
                                            .property("street", new StringProperty()))
                                    .property("name", new StringProperty())))));

    new InlineModelResolver().flatten(swagger);

    Operation operation = swagger.getPaths().get("/hello").getGet();
    BodyParameter bp = (BodyParameter) operation.getParameters().get(0);
    assertTrue(bp.getSchema() instanceof RefModel);

    Model body = swagger.getDefinitions().get("body");
    assertTrue(body instanceof ModelImpl);

    ModelImpl impl = (ModelImpl) body;
    assertNotNull(impl.getProperties().get("address"));
  }
  @Test
  public void testInlineMapResponse() throws Exception {
    Swagger swagger = new Swagger();

    MapProperty schema = new MapProperty();
    schema.setAdditionalProperties(new StringProperty());

    swagger.path(
        "/foo/baz",
        new Path()
            .get(
                new Operation()
                    .response(
                        200,
                        new Response()
                            .vendorExtension("x-foo", "bar")
                            .description("it works!")
                            .schema(schema))));
    new InlineModelResolver().flatten(swagger);
    Json.prettyPrint(swagger);

    Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200");

    Property property = response.getSchema();
    assertTrue(property instanceof MapProperty);
    assertTrue(swagger.getDefinitions().size() == 0);
  }
Example #13
0
  @Test
  public void testReadDomainsAndGuids() throws Exception {
    CustomerDAO dao = new CustomerDAO();
    IConfiguration configuration = EasyMock.createStrictMock(IConfiguration.class);
    dao.setConfiguration(configuration);
    ResultSet resultSet = EasyMock.createStrictMock(ResultSet.class);
    Set<String> domains = new HashSet<String>();
    Set<GlobalIdentifier> guids = new HashSet<GlobalIdentifier>();
    int custId = 34;
    int cloudService = 2;
    int replicationZone = 453;

    int cloudService2 = 1;
    int replicationZone2 = 13;

    int cloudService3 = 3;

    // first exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain123");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid123");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // second exec of loop
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid456");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService2);
    EasyMock.expect(resultSet.getInt(13)).andReturn(replicationZone2);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId);

    // third exec of loop (guid not valid with no cloud service)
    EasyMock.expect(resultSet.getString(10)).andReturn("domain456");
    EasyMock.expect(resultSet.getString(11)).andReturn("guid789");
    EasyMock.expect(resultSet.getInt(12)).andReturn(cloudService3);
    EasyMock.expect(resultSet.next()).andReturn(true);
    EasyMock.expect(resultSet.getInt(1)).andReturn(custId + 1); // ends loop with mismatched custid

    EasyMock.replay(resultSet);
    assertTrue(
        "Should have another item even.",
        dao.readDomainsAndGuids(resultSet, custId, domains, guids));
    EasyMock.verify(resultSet);
    assertEquals("Should have 2 domains.", 2, domains.size());
    assertTrue("Domain123 not found.", domains.contains("domain123"));
    assertTrue("Domain456 not found.", domains.contains("domain456"));

    assertEquals("Should have 2 guids.", 2, guids.size());
    for (GlobalIdentifier guid : guids) {
      if (guid.getGuid().equals("guid123")) {
        assertEquals("Wrong cloud service in guid123", CloudService.GOOGLE, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone, guid.getReplicationZone());
      } else {
        assertEquals("Wrong cloud service in guid456", CloudService.OFFICE365, guid.getService());
        assertEquals("Wrong replication zone.", replicationZone2, guid.getReplicationZone());
      }
    }
  }
  /**
   * Simple call to connector test() method.
   *
   * @throws Exception
   */
  @Test
  public void test310TestConnectionNegative() throws Exception {
    final String TEST_NAME = "test310TestConnectionNegative";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN

    OperationResult result = new OperationResult(TEST_NAME);

    ConnectorInstance badConnector =
        factory.createConnectorInstance(
            connectorType,
            ResourceTypeUtil.getResourceNamespace(badResourceType),
            "test connector");
    badConnector.configure(
        badResourceType.getConnectorConfiguration().asPrismContainerValue(), result);

    // WHEN

    badConnector.test(result);

    // THEN
    result.computeStatus("test failed");
    display("Test result (FAILURE EXPECTED)", result);
    AssertJUnit.assertNotNull(result);
    OperationResult connectorConnectionResult = result.getSubresults().get(1);
    AssertJUnit.assertNotNull(connectorConnectionResult);
    System.out.println(
        "Test \"connector connection\" result: "
            + connectorConnectionResult
            + " (FAILURE EXPECTED)");
    AssertJUnit.assertTrue(
        "Unexpected success of bad connector test", !connectorConnectionResult.isSuccess());
    AssertJUnit.assertTrue(!result.isSuccess());
  }
 @Test
 public void hashCodeEqualsTest() {
   final OptionFunctionProvider1D ref =
       new EuropeanVanillaOptionFunctionProvider(100., 1., 53, true);
   final OptionFunctionProvider1D[] function =
       new OptionFunctionProvider1D[] {
         ref,
         new EuropeanVanillaOptionFunctionProvider(100., 1., 53, true),
         new EuropeanVanillaOptionFunctionProvider(100., 1., 53, false),
         new EuropeanVanillaOptionFunctionProvider(110., 1., 53, true),
         new EuropeanVanillaOptionFunctionProvider(100., 2., 53, true),
         new EuropeanVanillaOptionFunctionProvider(100., 2., 54, true),
         new AmericanVanillaOptionFunctionProvider(100., 1., 53, true),
         null
       };
   final int len = function.length;
   for (int i = 0; i < len; ++i) {
     if (ref.equals(function[i])) {
       assertTrue(ref.hashCode() == function[i].hashCode());
     }
   }
   for (int i = 0; i < len - 1; ++i) {
     assertTrue(function[i].equals(ref) == ref.equals(function[i]));
   }
   assertFalse(ref.equals(new EuropeanSpreadOptionFunctionProvider(110., 1., 53, true)));
 }
 @Test
 public void httpMethod() {
   InputStream is = getClass().getResourceAsStream("/method.xml");
   PolicyRestrictor res = new PolicyRestrictor(is);
   assertTrue(res.isHttpMethodAllowed(HttpMethod.GET));
   assertTrue(res.isHttpMethodAllowed(HttpMethod.POST));
 }
  @Test
  public void allow() throws MalformedObjectNameException {
    InputStream is = getClass().getResourceAsStream("/access-sample5.xml");
    PolicyRestrictor restrictor = new PolicyRestrictor(is);
    assertTrue(
        restrictor.isAttributeReadAllowed(
            new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage"));
    assertTrue(
        restrictor.isAttributeWriteAllowed(
            new ObjectName("java.lang:type=Memory"), "HeapMemoryUsage"));
    assertTrue(
        restrictor.isAttributeReadAllowed(
            new ObjectName("java.lang:type=Memory"), "NonHeapMemoryUsage"));
    assertFalse(
        restrictor.isAttributeWriteAllowed(
            new ObjectName("java.lang:type=Memory"), "NonHeapMemoryUsage"));
    assertFalse(
        restrictor.isAttributeReadAllowed(new ObjectName("java.lang:type=Memory"), "BlaUsage"));

    assertTrue(restrictor.isAttributeReadAllowed(new ObjectName("jolokia:type=Config"), "Debug"));

    assertTrue(
        restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"), "gc"));
    assertFalse(
        restrictor.isOperationAllowed(new ObjectName("java.lang:type=Blubber,name=x"), "xavier"));
  }
 @Test
 public void testYandexPropertyReader() {
   String expectedElectronics = YandexReader.load().getElectronics();
   assertTrue("electronics".equals(expectedElectronics));
   String expectedCategoryComputer = YandexReader.load().getCategoryComputer();
   assertTrue("computer".equals(expectedCategoryComputer));
 }
  /**
   * Test entry.
   *
   * @throws Exception If the test failed unexpectedly.
   */
  @Test()
  public void testEntryToAndFromDatabase() throws Exception {
    // Make sure that the server is up and running.
    TestCaseUtils.startServer();

    // Convert the test LDIF string to a byte array
    byte[] originalLDIFBytes = StaticUtils.getBytes(ldifString);

    LDIFReader reader =
        new LDIFReader(new LDIFImportConfig(new ByteArrayInputStream(originalLDIFBytes)));

    Entry entryBefore, entryAfter;
    while ((entryBefore = reader.readEntry(false)) != null) {
      ByteString bytes = ID2Entry.entryToDatabase(entryBefore, new DataConfig(false, false, null));

      entryAfter = ID2Entry.entryFromDatabase(bytes, DirectoryServer.getDefaultCompressedSchema());

      // check DN and number of attributes
      assertEquals(entryBefore.getAttributes().size(), entryAfter.getAttributes().size());

      assertEquals(entryBefore.getDN(), entryAfter.getDN());

      // check the object classes were not changed
      for (String ocBefore : entryBefore.getObjectClasses().values()) {
        ObjectClass objectClass = DirectoryServer.getObjectClass(ocBefore.toLowerCase());
        if (objectClass == null) {
          objectClass = DirectoryServer.getDefaultObjectClass(ocBefore);
        }
        String ocAfter = entryAfter.getObjectClasses().get(objectClass);

        assertEquals(ocBefore, ocAfter);
      }

      // check the user attributes were not changed
      for (AttributeType attrType : entryBefore.getUserAttributes().keySet()) {
        List<Attribute> listBefore = entryBefore.getAttribute(attrType);
        List<Attribute> listAfter = entryAfter.getAttribute(attrType);

        assertTrue(listAfter != null);

        assertEquals(listBefore.size(), listAfter.size());

        for (Attribute attrBefore : listBefore) {
          boolean found = false;

          for (Attribute attrAfter : listAfter) {
            if (attrAfter.optionsEqual(attrBefore.getOptions())) {
              // Found the corresponding attribute

              assertEquals(attrBefore, attrAfter);
              found = true;
            }
          }

          assertTrue(found);
        }
      }
    }
    reader.close();
  }
 @Test
 public void testEmptyExtrapolatorName() {
   final CombinedInterpolatorExtrapolator combined =
       CombinedInterpolatorExtrapolatorFactory.getInterpolator(Interpolator1DFactory.LINEAR, "");
   assertEquals(combined.getInterpolator().getClass(), LinearInterpolator1D.class);
   assertTrue(combined.getLeftExtrapolator() instanceof InterpolatorExtrapolator);
   assertTrue(combined.getRightExtrapolator() instanceof InterpolatorExtrapolator);
 }
 @Test
 public void testEnsureMachineisLaunchedAndSessionIsUnlocked() {
   cloneFromMaster();
   ISession cloneMachineSession = machineController.ensureMachineIsLaunched(instanceName);
   assertTrue(cloneMachineSession.getState() == SessionState.Unlocked);
   cloneMachineSession = machineController.ensureMachineHasPowerDown(instanceName);
   assertTrue(cloneMachineSession.getState() == SessionState.Unlocked);
 }
 static void assertEuropeanVanillaEquityIndexOptionSecurity(
     EquityIndexOptionSecurity expectedOption, Security sec) {
   // check specific bits we want to spot failures on quickly
   assertNotNull(sec);
   assertTrue(sec instanceof EquityIndexOptionSecurity);
   final EquityIndexOptionSecurity equityIndexOption = (EquityIndexOptionSecurity) sec;
   assertTrue(equityIndexOption.getExerciseType() instanceof EuropeanExerciseType);
   assertEquityIndexOptionSecurity(expectedOption, sec);
 }
  @Test
  public void corsWildCard() {
    InputStream is = getClass().getResourceAsStream("/allow-origin2.xml");
    PolicyRestrictor restrictor = new PolicyRestrictor(is);

    assertTrue(restrictor.isOriginAllowed("http://bla.com", false));
    assertTrue(restrictor.isOriginAllowed("http://www.jolokia.org", false));
    assertTrue(restrictor.isOriginAllowed("http://www.consol.de", false));
  }
  @Test
  public void corsNoTags() {
    InputStream is = getClass().getResourceAsStream("/access-sample1.xml");
    PolicyRestrictor restrictor = new PolicyRestrictor(is);

    assertTrue(restrictor.isOriginAllowed("http://bla.com", false));
    assertTrue(restrictor.isOriginAllowed("http://www.jolokia.org", false));
    assertTrue(restrictor.isOriginAllowed("https://www.consol.de", false));
  }
 // -------------------------------------------------------------------------
 public void test_withExternalIdAdded() {
   ExternalIdSearch base = ExternalIdSearch.of(ExternalId.of("A", "B"));
   assertEquals(1, base.size());
   ExternalIdSearch test = base.withExternalIdAdded(ExternalId.of("A", "C"));
   assertEquals(1, base.size());
   assertEquals(2, test.size());
   assertTrue(test.getExternalIds().contains(ExternalId.of("A", "B")));
   assertTrue(test.getExternalIds().contains(ExternalId.of("A", "C")));
 }
 @Test
 public void testFloatsSortByInts() {
   final int n = X1F.length;
   final float[] x2 = Arrays.copyOf(X2F, n);
   final int[] y2 = Arrays.copyOf(Y2I, n);
   ParallelArrayBinarySort.parallelBinarySort(x2, y2);
   assertTrue(Arrays.equals(X1F, x2));
   assertTrue(Arrays.equals(Y1I, y2));
 }
 @Test
 public void testLongsSortByDouble() {
   final int n = X1L.length;
   final long[] x2 = Arrays.copyOf(X2L, n);
   final double[] y2 = Arrays.copyOf(Y2D, n);
   ParallelArrayBinarySort.parallelBinarySort(x2, y2);
   assertTrue(Arrays.equals(X1L, x2));
   assertTrue(Arrays.equals(Y1D, y2));
 }
 @Test
 public void testDoublesSortByInts() {
   final int n = X1D.length;
   final double[] x2 = Arrays.copyOf(X2D, n);
   final int[] y2 = Arrays.copyOf(Y2I, n);
   ParallelArrayBinarySort.parallelBinarySort(x2, y2);
   assertTrue(Arrays.equals(X1D, x2));
   assertTrue(Arrays.equals(Y1I, y2));
 }
  @Test
  public void corsStrictCheckingOff() {
    InputStream is = getClass().getResourceAsStream("/allow-origin1.xml");
    PolicyRestrictor restrictor = new PolicyRestrictor(is);

    // Allways true since we want a strict check but strict checking is off.
    assertTrue(restrictor.isOriginAllowed("http://bla.com", true));
    assertTrue(restrictor.isOriginAllowed("http://www.jolokia.org", true));
    assertTrue(restrictor.isOriginAllowed("https://www.consol.de", true));
  }
Example #30
0
 @Test
 public void testCurve1() {
   final double spot = 100;
   final ForwardCurve curve1 = new ForwardCurve(spot);
   final ForwardCurve curve2 = cycleObject(ForwardCurve.class, curve1);
   assertEquals(curve1.getSpot(), curve2.getSpot(), EPS);
   assertTrue(curve2.getForwardCurve() instanceof ConstantDoublesCurve);
   assertTrue(curve2.getDriftCurve() instanceof FunctionalDoublesCurve);
   assertCurveEquals(curve1.getForwardCurve(), curve2.getForwardCurve());
   assertCurveEquals(curve1.getDriftCurve(), curve2.getDriftCurve());
 }