Search in sources :

Example 66 with AssertionFailedError

use of junit.framework.AssertionFailedError in project ignite by apache.

the class IgniteCacheManyClientsTest method manyClientsPutGet.

/**
     * @throws Exception If failed.
     */
private void manyClientsPutGet() throws Throwable {
    client = true;
    final AtomicInteger idx = new AtomicInteger(SRVS);
    final AtomicBoolean stop = new AtomicBoolean();
    final AtomicReference<Throwable> err = new AtomicReference<>();
    final int THREADS = 50;
    final CountDownLatch latch = new CountDownLatch(THREADS);
    try {
        IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                boolean counted = false;
                try {
                    int nodeIdx = idx.getAndIncrement();
                    Thread.currentThread().setName("client-thread-node-" + nodeIdx);
                    try (Ignite ignite = startGrid(nodeIdx)) {
                        log.info("Started node: " + ignite.name());
                        assertTrue(ignite.configuration().isClientMode());
                        IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME);
                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
                        int iter = 0;
                        Integer key = rnd.nextInt(0, 1000);
                        cache.put(key, iter++);
                        assertNotNull(cache.get(key));
                        latch.countDown();
                        counted = true;
                        while (!stop.get() && err.get() == null) {
                            key = rnd.nextInt(0, 1000);
                            cache.put(key, iter++);
                            assertNotNull(cache.get(key));
                            Thread.sleep(1);
                        }
                        log.info("Stopping node: " + ignite.name());
                    }
                    return null;
                } catch (Throwable e) {
                    err.compareAndSet(null, e);
                    log.error("Unexpected error in client thread: " + e, e);
                    throw e;
                } finally {
                    if (!counted)
                        latch.countDown();
                }
            }
        }, THREADS, "client-thread");
        assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS));
        log.info("All clients started.");
        Thread.sleep(10_000);
        Throwable err0 = err.get();
        if (err0 != null)
            throw err0;
        boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {

            @Override
            public boolean apply() {
                try {
                    checkNodes(SRVS + THREADS);
                    return true;
                } catch (AssertionFailedError e) {
                    log.info("Check failed, will retry: " + e);
                }
                return false;
            }
        }, 10_000);
        if (!wait)
            checkNodes(SRVS + THREADS);
        log.info("Stop clients.");
        stop.set(true);
        fut.get();
    } catch (Throwable e) {
        log.error("Unexpected error: " + e, e);
        throw e;
    } finally {
        stop.set(true);
    }
}
Also used : GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) IgniteCache(org.apache.ignite.IgniteCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Ignite(org.apache.ignite.Ignite) AssertionFailedError(junit.framework.AssertionFailedError)

Example 67 with AssertionFailedError

use of junit.framework.AssertionFailedError in project jackrabbit by apache.

the class TestAll method getChildNode.

/**
     * Returns the named child node definition from the named node type
     * definition. If either of the definitions do not exist, an assertion
     * failure is generated.
     *
     * @param typeName node type name
     * @param nodeName child node name
     * @return child node definition
     */
private QNodeDefinition getChildNode(String typeName, String nodeName) {
    Name name = FACTORY.create(TEST_NAMESPACE, nodeName);
    QNodeTypeDefinition def = getNodeType(typeName);
    QNodeDefinition[] defs = def.getChildNodeDefs();
    for (int i = 0; i < defs.length; i++) {
        if (name.equals(defs[i].getName())) {
            return defs[i];
        }
    }
    throw new AssertionFailedError("Child node " + nodeName + " does not exist");
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QNodeDefinition(org.apache.jackrabbit.spi.QNodeDefinition) AssertionFailedError(junit.framework.AssertionFailedError) Name(org.apache.jackrabbit.spi.Name)

Example 68 with AssertionFailedError

use of junit.framework.AssertionFailedError in project jmeter by apache.

the class JUnitSampler method sample.

/** {@inheritDoc} */
@Override
public SampleResult sample(Entry entry) {
    if (getCreateOneInstancePerSample()) {
        initializeTestObject();
    }
    SampleResult sresult = new SampleResult();
    // Bug 41522 - don't use rlabel here
    sresult.setSampleLabel(getName());
    sresult.setSamplerData(className + "." + methodName);
    sresult.setDataType(SampleResult.TEXT);
    // Assume success
    sresult.setSuccessful(true);
    sresult.setResponseMessage(getSuccess());
    sresult.setResponseCode(getSuccessCode());
    if (this.testCase != null) {
        // create a new TestResult
        TestResult tr = new TestResult();
        final TestCase theClazz = this.testCase;
        try {
            if (setUpMethod != null) {
                setUpMethod.invoke(this.testObject, new Object[0]);
            }
            sresult.sampleStart();
            tr.startTest(this.testCase);
            // Do not use TestCase.run(TestResult) method, since it will
            // call setUp and tearDown. Doing that will result in calling
            // the setUp and tearDown method twice and the elapsed time
            // will include setup and teardown.
            tr.runProtected(theClazz, protectable);
            tr.endTest(this.testCase);
            sresult.sampleEnd();
            if (tearDownMethod != null) {
                tearDownMethod.invoke(testObject, new Object[0]);
            }
        } catch (InvocationTargetException e) {
            Throwable cause = e.getCause();
            if (cause instanceof AssertionFailedError) {
                tr.addFailure(theClazz, (AssertionFailedError) cause);
            } else if (cause instanceof AssertionError) {
                // Convert JUnit4 failure to Junit3 style
                AssertionFailedError afe = new AssertionFailedError(cause.toString());
                // copy the original stack trace
                afe.setStackTrace(cause.getStackTrace());
                tr.addFailure(theClazz, afe);
            } else if (cause != null) {
                tr.addError(theClazz, cause);
            } else {
                tr.addError(theClazz, e);
            }
        } catch (IllegalAccessException | IllegalArgumentException e) {
            tr.addError(theClazz, e);
        }
        if (!tr.wasSuccessful()) {
            sresult.setSuccessful(false);
            StringBuilder buf = new StringBuilder();
            StringBuilder buftrace = new StringBuilder();
            Enumeration<TestFailure> en;
            if (getAppendError()) {
                en = tr.failures();
                if (en.hasMoreElements()) {
                    sresult.setResponseCode(getFailureCode());
                    buf.append(getFailure());
                    buf.append("\n");
                }
                while (en.hasMoreElements()) {
                    TestFailure item = en.nextElement();
                    buf.append("Failure -- ");
                    buf.append(item.toString());
                    buf.append("\n");
                    buftrace.append("Failure -- ");
                    buftrace.append(item.toString());
                    buftrace.append("\n");
                    buftrace.append("Trace -- ");
                    buftrace.append(item.trace());
                }
                en = tr.errors();
                if (en.hasMoreElements()) {
                    sresult.setResponseCode(getErrorCode());
                    buf.append(getError());
                    buf.append("\n");
                }
                while (en.hasMoreElements()) {
                    TestFailure item = en.nextElement();
                    buf.append("Error -- ");
                    buf.append(item.toString());
                    buf.append("\n");
                    buftrace.append("Error -- ");
                    buftrace.append(item.toString());
                    buftrace.append("\n");
                    buftrace.append("Trace -- ");
                    buftrace.append(item.trace());
                }
            }
            sresult.setResponseMessage(buf.toString());
            sresult.setResponseData(buftrace.toString(), null);
        }
    } else {
        // we should log a warning, but allow the test to keep running
        sresult.setSuccessful(false);
        // this should be externalized to the properties
        sresult.setResponseMessage("Failed to create an instance of the class:" + getClassname() + ", reasons may be missing both empty constructor and one " + "String constructor or failure to instantiate constructor," + " check warning messages in jmeter log file");
        sresult.setResponseCode(getErrorCode());
    }
    return sresult;
}
Also used : TestFailure(junit.framework.TestFailure) TestResult(junit.framework.TestResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) TestCase(junit.framework.TestCase) SampleResult(org.apache.jmeter.samplers.SampleResult) AssertionFailedError(junit.framework.AssertionFailedError)

Example 69 with AssertionFailedError

use of junit.framework.AssertionFailedError in project lucene-solr by apache.

the class DistributedFacetPivotSmallTest method testFacetPivotRange.

private void testFacetPivotRange() throws Exception {
    final ModifiableSolrParams params = new ModifiableSolrParams();
    setDistributedParams(params);
    params.add("q", "*:*");
    params.add("facet", "true");
    params.add("facet.pivot", "{!range=s1}place_t,company_t");
    params.add("facet.range", "{!tag=s1 key=price}price_ti");
    params.add("facet.range.start", "0");
    params.add("facet.range.end", "100");
    params.add("facet.range.gap", "20");
    QueryResponse rsp = queryServer(params);
    List<PivotField> expectedPlacePivots = new UnorderedEqualityArrayList<PivotField>();
    List<PivotField> expectedCardiffPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "microsoft", 2, null, null, createExpectedRange("price", 0, 100, 20, 1, 0, 0, 0, 0)));
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "null", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "bbc", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "polecat", 3, null, null, createExpectedRange("price", 0, 100, 20, 1, 1, 0, 0, 0)));
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "fujitsu", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    List<PivotField> expectedDublinPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedDublinPivots.add(new ComparablePivotField("company_t", "polecat", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "microsoft", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 1, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "bbc", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    List<PivotField> expectedLondonPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedLondonPivots.add(new ComparablePivotField("company_t", "polecat", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "microsoft", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "bbc", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    List<PivotField> expectedLAPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedLAPivots.add(new ComparablePivotField("company_t", "microsoft", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLAPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLAPivots.add(new ComparablePivotField("company_t", "null", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLAPivots.add(new ComparablePivotField("company_t", "bbc", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    expectedLAPivots.add(new ComparablePivotField("company_t", "polecat", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    List<PivotField> expectedKrakowPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "polecat", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "bbc", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "fujitsu", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "microsoft", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    List<PivotField> expectedCorkPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedCorkPivots.add(new ComparablePivotField("company_t", "fujitsu", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    expectedCorkPivots.add(new ComparablePivotField("company_t", "rte", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "dublin", 4, expectedDublinPivots, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "cardiff", 3, expectedCardiffPivots, null, createExpectedRange("price", 0, 100, 20, 1, 1, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "london", 4, expectedLondonPivots, null, createExpectedRange("price", 0, 100, 20, 0, 3, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "la", 3, expectedLAPivots, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "krakow", 3, expectedKrakowPivots, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "cork", 1, expectedCorkPivots, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    List<PivotField> placePivots = rsp.getFacetPivot().get("place_t,company_t");
    // Useful to check for errors, orders lists and does toString() equality
    // check
    testOrderedPivotsStringEquality(expectedPlacePivots, placePivots);
    assertEquals(expectedPlacePivots, placePivots);
    // Test sorting by count
    params.set(FacetParams.FACET_SORT, FacetParams.FACET_SORT_COUNT);
    rsp = queryServer(params);
    placePivots = rsp.getFacetPivot().get("place_t,company_t");
    testCountSorting(placePivots);
    // Test limit
    params.set(FacetParams.FACET_LIMIT, 2);
    rsp = queryServer(params);
    expectedPlacePivots = new UnorderedEqualityArrayList<PivotField>();
    expectedDublinPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedDublinPivots.add(new ComparablePivotField("company_t", "polecat", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "microsoft", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedLondonPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedLondonPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "polecat", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "dublin", 4, expectedDublinPivots, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "london", 4, expectedLondonPivots, null, createExpectedRange("price", 0, 100, 20, 0, 3, 0, 0, 0)));
    placePivots = rsp.getFacetPivot().get("place_t,company_t");
    assertEquals(expectedPlacePivots, placePivots);
    // Test individual facet.limit values
    params.remove(FacetParams.FACET_LIMIT);
    params.set("f.place_t." + FacetParams.FACET_LIMIT, 1);
    params.set("f.company_t." + FacetParams.FACET_LIMIT, 4);
    rsp = queryServer(params);
    expectedPlacePivots = new UnorderedEqualityArrayList<PivotField>();
    expectedDublinPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedDublinPivots.add(new ComparablePivotField("company_t", "microsoft", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "polecat", 4, null, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 1, 1, 0, 0, 0)));
    expectedDublinPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLondonPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedLondonPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "polecat", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 2, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "bbc", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLondonPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedCardiffPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedCardiffPivots.add(new ComparablePivotField("company_t", "polecat", 3, null, null, createExpectedRange("price", 0, 100, 20, 1, 1, 0, 0, 0)));
    expectedKrakowPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedKrakowPivots.add(new ComparablePivotField("company_t", "null", 3, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedLAPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedLAPivots.add(new ComparablePivotField("company_t", "fujitsu", 2, null, null, createExpectedRange("price", 0, 100, 20, 0, 1, 0, 0, 0)));
    expectedCorkPivots = new UnorderedEqualityArrayList<PivotField>();
    expectedCorkPivots.add(new ComparablePivotField("company_t", "fujitsu", 1, null, null, createExpectedRange("price", 0, 100, 20, 0, 0, 0, 0, 0)));
    expectedPlacePivots.add(new ComparablePivotField("place_t", "dublin", 4, expectedDublinPivots, null, createExpectedRange("price", 0, 100, 20, 2, 1, 0, 0, 0)));
    placePivots = rsp.getFacetPivot().get("place_t,company_t");
    assertEquals(expectedPlacePivots, placePivots);
    params.remove("f.company_t." + FacetParams.FACET_LIMIT);
    params.remove("f.place_t." + FacetParams.FACET_LIMIT);
    params.set(FacetParams.FACET_LIMIT, 2);
    // Test facet.missing=true with diff sorts
    // NOTE: id=25 has no place as well
    index("id", 777);
    commit();
    SolrParams missingA = params("q", "*:*", "rows", "0", "facet", "true", "facet.pivot", "place_t,company_t", // default facet.sort
    FacetParams.FACET_MISSING, "true");
    SolrParams missingB = SolrParams.wrapDefaults(missingA, params(FacetParams.FACET_LIMIT, "4", "facet.sort", "index"));
    for (SolrParams p : new SolrParams[] { missingA, missingB }) {
        // in either case, the last pivot option should be the same
        rsp = query(p);
        placePivots = rsp.getFacetPivot().get("place_t,company_t");
        assertTrue("not enough values for pivot: " + p + " => " + placePivots, 1 < placePivots.size());
        PivotField missing = placePivots.get(placePivots.size() - 1);
        assertNull("not the missing place value: " + p, missing.getValue());
        assertEquals("wrong missing place count: " + p, 2, missing.getCount());
        assertTrue("not enough sub-pivots for missing place: " + p + " => " + missing.getPivot(), 1 < missing.getPivot().size());
        missing = missing.getPivot().get(missing.getPivot().size() - 1);
        assertNull("not the missing company value: " + p, missing.getValue());
        assertEquals("wrong missing company count: " + p, 1, missing.getCount());
        assertNull("company shouldn't have sub-pivots: " + p, missing.getPivot());
    }
    // sort=index + mincount + limit
    for (SolrParams variableParams : new SolrParams[] { // we should get the same results regardless of overrequest
    params("facet.overrequest.count", "0", "facet.overrequest.ratio", "0"), params() }) {
        SolrParams p = SolrParams.wrapDefaults(params("q", "*:*", "rows", "0", "facet", "true", "facet.pivot", "company_t", "facet.sort", "index", "facet.pivot.mincount", "4", "facet.limit", "4"), variableParams);
        try {
            List<PivotField> pivots = query(p).getFacetPivot().get("company_t");
            assertEquals(4, pivots.size());
            assertEquals("fujitsu", pivots.get(0).getValue());
            assertEquals(4, pivots.get(0).getCount());
            assertEquals("microsoft", pivots.get(1).getValue());
            assertEquals(5, pivots.get(1).getCount());
            assertEquals("null", pivots.get(2).getValue());
            assertEquals(6, pivots.get(2).getCount());
            assertEquals("polecat", pivots.get(3).getValue());
            assertEquals(6, pivots.get(3).getCount());
        } catch (AssertionFailedError ae) {
            throw new AssertionError(ae.getMessage() + " <== " + p.toString(), ae);
        }
    }
    // sort=index + mincount + limit + offset
    for (SolrParams variableParams : new SolrParams[] { // we should get the same results regardless of overrequest
    params("facet.overrequest.count", "0", "facet.overrequest.ratio", "0"), params() }) {
        SolrParams p = SolrParams.wrapDefaults(params("q", "*:*", "rows", "0", "facet", "true", "facet.pivot", "company_t", "facet.sort", "index", "facet.pivot.mincount", "4", "facet.offset", "1", "facet.limit", "4"), variableParams);
        try {
            List<PivotField> pivots = query(p).getFacetPivot().get("company_t");
            // asked for 4, but not enough meet the
            assertEquals(3, pivots.size());
            // mincount
            assertEquals("microsoft", pivots.get(0).getValue());
            assertEquals(5, pivots.get(0).getCount());
            assertEquals("null", pivots.get(1).getValue());
            assertEquals(6, pivots.get(1).getCount());
            assertEquals("polecat", pivots.get(2).getValue());
            assertEquals(6, pivots.get(2).getCount());
        } catch (AssertionFailedError ae) {
            throw new AssertionError(ae.getMessage() + " <== " + p.toString(), ae);
        }
    }
    // sort=index + mincount + limit + offset (more permutations)
    for (SolrParams variableParams : new SolrParams[] { // all of these combinations should result in the same first value
    params("facet.pivot.mincount", "4", "facet.offset", "2"), params("facet.pivot.mincount", "5", "facet.offset", "1"), params("facet.pivot.mincount", "6", "facet.offset", "0") }) {
        SolrParams p = SolrParams.wrapDefaults(params("q", "*:*", "rows", "0", "facet", "true", "facet.limit", "1", "facet.sort", "index", "facet.overrequest.ratio", "0", "facet.pivot", "company_t"), variableParams);
        try {
            List<PivotField> pivots = query(p).getFacetPivot().get("company_t");
            assertEquals(1, pivots.size());
            assertEquals(pivots.toString(), "null", pivots.get(0).getValue());
            assertEquals(pivots.toString(), 6, pivots.get(0).getCount());
        } catch (AssertionFailedError ae) {
            throw new AssertionError(ae.getMessage() + " <== " + p.toString(), ae);
        }
    }
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) PivotField(org.apache.solr.client.solrj.response.PivotField) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) AssertionFailedError(junit.framework.AssertionFailedError) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 70 with AssertionFailedError

use of junit.framework.AssertionFailedError in project poi by apache.

the class TestProper method confirm.

private void confirm(String formulaText, String expectedResult) {
    cell11.setCellFormula(formulaText);
    evaluator.clearAllCachedResultValues();
    CellValue cv = evaluator.evaluate(cell11);
    if (cv.getCellTypeEnum() != CellType.STRING) {
        throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
    }
    String actualValue = cv.getStringValue();
    assertEquals(expectedResult, actualValue);
}
Also used : CellValue(org.apache.poi.ss.usermodel.CellValue) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15