Java Examples for junit.framework.AssertionFailedError

The following java examples will help you to understand the usage of junit.framework.AssertionFailedError. These source code samples are taken from different open source projects.

Example 1
Project: android-15-master  File: VCardTestUtilsTests.java View source code
public void testShouldFailAtPropertyNodeVerification() {
    boolean failureDetected = false;
    try {
        final VCardVerifier verifier = new VCardVerifier(this);
        verifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_backslash);
        verifier.addPropertyNodesVerifierElem().addExpectedNodeWithOrder(// wrong
        "N", // wrong
        ";A;B\\;C\\;;D;:E;\\\\;--", Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", "")).addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\");
        verifier.verify();
    } catch (AssertionFailedError e) {
        failureDetected = true;
    }
    if (!failureDetected) {
        TestCase.fail("Test case that should fail actually succeeded.");
    }
}
Example 2
Project: property-db-master  File: VCardTestUtilsTests.java View source code
public void testShouldFailAtPropertyNodeVerification() {
    boolean failureDetected = false;
    try {
        final VCardVerifier verifier = new VCardVerifier(this);
        verifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_backslash);
        verifier.addPropertyNodesVerifierElem().addExpectedNodeWithOrder(// wrong
        "N", // wrong
        ";A;B\\;C\\;;D;:E;\\\\;--", Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", "")).addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\");
        verifier.verify();
    } catch (AssertionFailedError e) {
        failureDetected = true;
    }
    if (!failureDetected) {
        TestCase.fail("Test case that should fail actually succeeded.");
    }
}
Example 3
Project: android-sdk-sources-for-api-level-23-master  File: VCardTestUtilsTests.java View source code
public void testShouldFailAtPropertyNodeVerification() {
    boolean failureDetected = false;
    try {
        final VCardVerifier verifier = new VCardVerifier(this);
        verifier.initForImportTest(VCardConfig.VCARD_TYPE_V21_GENERIC, R.raw.v21_backslash);
        verifier.addPropertyNodesVerifierElem().addExpectedNodeWithOrder(// wrong
        "N", // wrong
        ";A;B\\;C\\;;D;:E;\\\\;--", Arrays.asList("", "A;B\\", "C\\;", "D", ":E", "\\\\", "")).addExpectedNodeWithOrder("FN", "A;B\\C\\;D:E\\\\");
        verifier.verify();
    } catch (AssertionFailedError e) {
        failureDetected = true;
    }
    if (!failureDetected) {
        TestCase.fail("Test case that should fail actually succeeded.");
    }
}
Example 4
Project: RoboBuggy-master  File: TextFeedbackTest.java View source code
public void testFailure() {
    String expected = expected(new String[] { ".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1,  Failures: 1,  Errors: 0", "" });
    ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {

        @Override
        public void printFailures(TestResult result) {
            getWriter().println("Failures here");
        }
    };
    runner.setPrinter(printer);
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
            throw new AssertionFailedError();
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Example 5
Project: sosies-generator-master  File: TextFeedbackTest.java View source code
public void testFailure() {
    String expected = expected(new String[] { ".F", "Time: 0", "Failures here", "", "FAILURES!!!", "Tests run: 1,  Failures: 1,  Errors: 0", "" });
    ResultPrinter printer = new TestResultPrinter(new PrintStream(output)) {

        @Override
        public void printFailures(TestResult result) {
            getWriter().println("Failures here");
        }
    };
    runner.setPrinter(printer);
    TestSuite suite = new TestSuite();
    suite.addTest(new TestCase() {

        @Override
        public void runTest() {
            throw new AssertionFailedError();
        }
    });
    runner.doRun(suite);
    assertEquals(expected, output.toString());
}
Example 6
Project: cdo-master  File: TestListener.java View source code
public <T extends IEvent> void assertEvent(final Class<?> eventType, final EventAssertion<T> assertion) throws Exception {
    new AbstractOMTest.PollingTimeOuter() {

        @SuppressWarnings("unchecked")
        @Override
        protected boolean successful() {
            synchronized (events) {
                for (int i = nextAssertion; i < events.size(); i++) {
                    IEvent event = events.get(i);
                    System.out.println(event);
                    ++nextAssertion;
                    if (eventType.isAssignableFrom(event.getClass())) {
                        try {
                            assertion.execute((T) event);
                            return true;
                        } catch (AssertionFailedError ignore) {
                        }
                    }
                }
            }
            return false;
        }
    }.assertNoTimeOut();
}
Example 7
Project: cdt-tests-runner-master  File: ASTComparer.java View source code
private static void assertCopy(IASTNode node1, IASTNode node2, int n) throws Exception {
    if (node1 == null && node2 == null)
        return;
    assertNotNull(node1);
    assertNotNull(node2);
    // must be distinct copy
    assertFalse(node1 == node2);
    Class klass1 = node1.getClass();
    Class klass2 = node2.getClass();
    // nodes must be the same concrete type
    assertTrue(klass1.equals(klass2));
    //System.out.println(spaces(n) + klass1.getSimpleName());
    BeanInfo beanInfo = Introspector.getBeanInfo(klass1);
    for (PropertyDescriptor property : beanInfo.getPropertyDescriptors()) {
        Method getter = property.getReadMethod();
        if (getter == null)
            continue;
        if (methodsToIgnore.contains(getter.getName()))
            continue;
        if (getter.getAnnotation(Deprecated.class) != null)
            continue;
        try {
            Class returnType = getter.getReturnType();
            if (IASTNode.class.isAssignableFrom(returnType)) {
                //System.out.println(spaces(n) + "Testing1: " + getter.getName());
                IASTNode result1 = (IASTNode) getter.invoke(node1);
                IASTNode result2 = (IASTNode) getter.invoke(node2);
                // members must be same
                assertCopy(result1, result2, n + 1);
            } else if (returnType.isArray() && IASTNode.class.isAssignableFrom(returnType.getComponentType())) {
                //System.out.println(spaces(n) + "Testing2: " + getter.getName());
                IASTNode[] result1 = (IASTNode[]) getter.invoke(node1);
                IASTNode[] result2 = (IASTNode[]) getter.invoke(node2);
                if (result1 == null && result2 == null)
                    continue;
                assertNotNull(result1);
                assertNotNull(result2);
                assertEquals(result1.length, result2.length);
                for (int i = 0; i < result1.length; i++) assertCopy(result1[i], result2[i], n + 1);
            } else if ((returnType.isPrimitive() || returnType.equals(String.class)) && !returnType.equals(Void.class)) {
                //System.out.println(spaces(n) + "Testing3: " + getter.getName());
                Object result1 = getter.invoke(node1);
                Object result2 = getter.invoke(node2);
                assertEquals(result1, result2);
            }
        } catch (AssertionFailedError e) {
            System.out.printf("Failure when calling %s.%s() @(%d,%d)\n", node1.getClass().getSimpleName(), getter.getName(), ((ASTNode) node1).getOffset(), ((ASTNode) node1).getLength());
            throw e;
        }
    }
}
Example 8
Project: cdt-master  File: FailingTest.java View source code
/* (non-Javadoc)
     * @see junit.framework.Test#run(junit.framework.TestResult)
     */
@Override
public void run(TestResult result) {
    result.startTest(this);
    TestResult r = new TestResult();
    test.run(r);
    if (r.failureCount() == 1) {
        TestFailure failure = r.failures().nextElement();
        String msg = failure.exceptionMessage();
        if (msg != null && msg.startsWith("Method \"" + test.getName() + "\"")) {
            result.addFailure(this, new AssertionFailedError(msg));
        }
    } else if (r.errorCount() == 0 && r.failureCount() == 0) {
        //$NON-NLS-1$
        String err = "Unexpected success";
        if (bugNum != -1)
            //$NON-NLS-1$
            err += ", bug #" + bugNum;
        result.addFailure(this, new AssertionFailedError(err));
    }
    result.endTest(this);
}
Example 9
Project: rabbitmq-java-client-master  File: ConfirmBase.java View source code
protected void waitForConfirms(final String testTitle) throws Exception {
    try {
        FutureTask<?> waiter = new FutureTask<Object>(new Runnable() {

            public void run() {
                try {
                    channel.waitForConfirmsOrDie();
                } catch (IOException e) {
                    throw (ShutdownSignalException) e.getCause();
                } catch (InterruptedException _e) {
                    fail(testTitle + ": interrupted");
                }
            }
        }, null);
        (Executors.newSingleThreadExecutor()).execute(waiter);
        waiter.get(10, TimeUnit.SECONDS);
    } catch (ExecutionException ee) {
        Throwable t = ee.getCause();
        if (t instanceof ShutdownSignalException)
            throw (ShutdownSignalException) t;
        if (t instanceof AssertionFailedError)
            throw (AssertionFailedError) t;
        throw (Exception) t;
    } catch (TimeoutException _e) {
        fail(testTitle + ": timeout");
    }
}
Example 10
Project: closure-stylesheets-master  File: RecordingSubstitutionMapTest.java View source code
public final void testReadAndWrite() throws IOException {
    for (OutputRenamingMapFormat format : OutputRenamingMapFormat.values()) {
        RecordingSubstitutionMap recording = new RecordingSubstitutionMap.Builder().withSubstitutionMap(createDelegate()).build();
        // Put some stuff into the map.
        // TIL: there are a lot of websites on the A-Z of fruits & vegetables.
        assertEquals("x-a", recording.get("apple"));
        assertEquals("x-b", recording.get("banana"));
        assertEquals("x-d", recording.get("durian"));
        assertEquals("x-f-g", recording.get("figgy-goop"));
        // Write it out.
        StringWriter out = new StringWriter();
        String formatted;
        try {
            format.writeRenamingMap(recording.getMappings(), out);
            formatted = out.toString();
        } finally {
            out.close();
        }
        // Reconstitute it.
        RecordingSubstitutionMap recordingFromString;
        StringReader in = new StringReader(formatted);
        try {
            recordingFromString = new RecordingSubstitutionMap.Builder().withSubstitutionMap(createDelegate()).withMappings(format.readRenamingMap(in)).build();
            assertEquals(-1, in.read());
        } catch (IOExceptionRuntimeException |  ex) {
            throw (AssertionFailedError) new AssertionFailedError("Problem with input formatted according to " + format + "\n```\n" + formatted + "\n```").initCause(ex);
        } finally {
            in.close();
        }
        // Vary the order to check that we get stable values from the
        // earlier uses, and unambiguous new values.
        assertEquals("x-b", recordingFromString.get("banana"));
        assertEquals("x-h", recordingFromString.get("honeydew"));
        assertEquals("x-a", recordingFromString.get("apple"));
        assertEquals("x-f-g", recordingFromString.get("figgy-goop"));
        assertEquals("x-d", recordingFromString.get("durian"));
        assertEquals("x-j", recordingFromString.get("jalapeno"));
    }
}
Example 11
Project: android_platform_libcore-master  File: AccessControllerTest.java View source code
public void testDoPrivilegedWithCombiner() {
    final Permission permission = new RuntimePermission("do stuff");
    final DomainCombiner union = new DomainCombiner() {

        public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
            throw new AssertionFailedError("Expected combiner to be unused");
        }
    };
    ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
    AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
    final AtomicInteger actionCount = new AtomicInteger();
    AccessController.doPrivileged(new PrivilegedAction<Void>() {

        public Void run() {
            assertEquals(null, AccessController.getContext().getDomainCombiner());
            AccessController.getContext().checkPermission(permission);
            // Calling doPrivileged again would have exercised the combiner
            AccessController.doPrivileged(new PrivilegedAction<Void>() {

                public Void run() {
                    actionCount.incrementAndGet();
                    assertEquals(null, AccessController.getContext().getDomainCombiner());
                    AccessController.getContext().checkPermission(permission);
                    return null;
                }
            });
            return null;
        }
    }, accessControlContext);
    assertEquals(1, actionCount.get());
}
Example 12
Project: android-libcore64-master  File: AccessControllerTest.java View source code
public void testDoPrivilegedWithCombiner() {
    final Permission permission = new RuntimePermission("do stuff");
    final DomainCombiner union = new DomainCombiner() {

        public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
            throw new AssertionFailedError("Expected combiner to be unused");
        }
    };
    ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
    AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
    final AtomicInteger actionCount = new AtomicInteger();
    AccessController.doPrivileged(new PrivilegedAction<Void>() {

        public Void run() {
            assertEquals(null, AccessController.getContext().getDomainCombiner());
            AccessController.getContext().checkPermission(permission);
            // Calling doPrivileged again would have exercised the combiner
            AccessController.doPrivileged(new PrivilegedAction<Void>() {

                public Void run() {
                    actionCount.incrementAndGet();
                    assertEquals(null, AccessController.getContext().getDomainCombiner());
                    AccessController.getContext().checkPermission(permission);
                    return null;
                }
            });
            return null;
        }
    }, accessControlContext);
    assertEquals(1, actionCount.get());
}
Example 13
Project: ARTPart-master  File: AccessControllerTest.java View source code
public void testDoPrivilegedWithCombiner() {
    final Permission permission = new RuntimePermission("do stuff");
    final DomainCombiner union = new DomainCombiner() {

        public ProtectionDomain[] combine(ProtectionDomain[] a, ProtectionDomain[] b) {
            throw new AssertionFailedError("Expected combiner to be unused");
        }
    };
    ProtectionDomain protectionDomain = new ProtectionDomain(null, new Permissions());
    AccessControlContext accessControlContext = new AccessControlContext(new AccessControlContext(new ProtectionDomain[] { protectionDomain }), union);
    final AtomicInteger actionCount = new AtomicInteger();
    AccessController.doPrivileged(new PrivilegedAction<Void>() {

        public Void run() {
            assertEquals(null, AccessController.getContext().getDomainCombiner());
            AccessController.getContext().checkPermission(permission);
            // Calling doPrivileged again would have exercised the combiner
            AccessController.doPrivileged(new PrivilegedAction<Void>() {

                public Void run() {
                    actionCount.incrementAndGet();
                    assertEquals(null, AccessController.getContext().getDomainCombiner());
                    AccessController.getContext().checkPermission(permission);
                    return null;
                }
            });
            return null;
        }
    }, accessControlContext);
    assertEquals(1, actionCount.get());
}
Example 14
Project: eclipse.jdt.ui-master  File: TestRunListenerTest3.java View source code
public void testFail() throws Exception {
    String source = "package pack;\n" + "import junit.framework.TestCase;\n" + "public class ATestCase extends TestCase {\n" + "    public void testFail() { fail(); }\n" + "}";
    IType aTestCase = createType(source, "pack", "ATestCase.java");
    String[] expectedSequence = new String[] { "sessionStarted-" + TestRunListeners.sessionAsString("ATestCase", ProgressState.RUNNING, Result.UNDEFINED, 0), "testCaseStarted-" + TestRunListeners.testCaseAsString("testFail", "pack.ATestCase", ProgressState.RUNNING, Result.UNDEFINED, null, 0), "testCaseFinished-" + TestRunListeners.testCaseAsString("testFail", "pack.ATestCase", ProgressState.COMPLETED, Result.FAILURE, new FailureTrace("junit.framework.AssertionFailedError", null, null), 0), "sessionFinished-" + TestRunListeners.sessionAsString("ATestCase", ProgressState.COMPLETED, Result.FAILURE, 0) };
    String[] actual = runSequenceTest(aTestCase);
    assertEqualLog(expectedSequence, actual);
}
Example 15
Project: modeshape-master  File: BinaryContains.java View source code
@Override
public boolean matchesSafely(BinaryValue content) {
    try {
        byte[] actualContents = IoUtil.readBytes(content.getStream());
        if (actualContents.length != expectedContent.length)
            return false;
        for (int i = 0, len = actualContents.length; i != len; ++i) {
            if (actualContents[i] != expectedContent[i])
                return false;
        }
        return true;
    } catch (RepositoryException e) {
        throw new AssertionFailedError(e.getMessage());
    } catch (IOException e) {
        throw new AssertionFailedError(e.getMessage());
    } finally {
        content.dispose();
    }
}
Example 16
Project: google-web-toolkit-svnmirror-master  File: CustomFieldSerializerTest.java View source code
/**
   * Tests that the custom field serializers are actually called when the
   * custom field serializer does not derive from
   * [email protected] CustomFieldSerializer}
   */
public void testCustomFieldSerialization() {
    CustomFieldSerializerTestServiceAsync service = getServiceAsync();
    delayTestFinishForRpc();
    service.echo(CustomFieldSerializerTestSetFactory.createUnserializableClass(), new AsyncCallback() {

        public void onFailure(Throwable caught) {
            AssertionFailedError er = new AssertionFailedError("Class UnserializableClass should be serializable because it has a custom field serializer");
            er.initCause(caught);
            throw er;
        }

        public void onSuccess(Object result) {
            assertNotNull(result);
            assertTrue(CustomFieldSerializerTestSetValidator.isValid((ManuallySerializedClass) result));
            finishTest();
        }
    });
}
Example 17
Project: hibernate-core-ogm-master  File: AbstractTransactionalAccessTestCase.java View source code
@Override
public void run() {
    try {
        long txTimestamp = System.currentTimeMillis();
        BatchModeTransactionManager.getInstance().begin();
        assertEquals("Correct initial value", VALUE1, localAccessStrategy.get(KEY, txTimestamp));
        localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1));
        pferLatch.countDown();
        commitLatch.await();
        BatchModeTransactionManager.getInstance().commit();
    } catch (Exception e) {
        log.error("node1 caught exception", e);
        node1Exception = e;
        rollback();
    } catch (AssertionFailedError e) {
        node1Failure = e;
        rollback();
    } finally {
        completionLatch.countDown();
    }
}
Example 18
Project: JBossAS51-master  File: MBeanServerFactoryTEST.java View source code
public void testFindByAgentID() {
    try {
        MBeanServer server1 = MBeanServerFactory.createMBeanServer();
        MBeanServer server2 = MBeanServerFactory.createMBeanServer();
        MBeanServer server3 = MBeanServerFactory.newMBeanServer();
        ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate");
        String agentID1 = (String) server1.getAttribute(delegateName, "MBeanServerId");
        String agentID2 = (String) server2.getAttribute(delegateName, "MBeanServerId");
        String agentID3 = (String) server3.getAttribute(delegateName, "MBeanServerId");
        assertTrue((MBeanServer) MBeanServerFactory.findMBeanServer(agentID1).get(0) == server1);
        assertTrue((MBeanServer) MBeanServerFactory.findMBeanServer(agentID2).get(0) == server2);
        assertTrue(MBeanServerFactory.findMBeanServer(agentID3).size() == 0);
    } catch (AssertionFailedError e) {
        throw e;
    } catch (Throwable t) {
        fail("Unexpected error: " + t.toString());
    }
}
Example 19
Project: eclipselink.runtime-master  File: MarshalToNodeTestCases.java View source code
public void testMarshalToNode() throws Exception {
    Document testDocument = documentBuilder.newDocument();
    Element rootElement = testDocument.createElementNS("http://www.example.org/", "abc:ROOT-ELEMENT");
    testDocument.appendChild(rootElement);
    XMLContext xmlContext = getXMLContext(new XMLRootComplexProject());
    XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
    xmlMarshaller.setFormattedOutput(false);
    xmlMarshaller.marshal(getControlObject(), rootElement);
    Document controlDocument = getControlDocument();
    try {
        this.assertXMLIdentical(controlDocument, testDocument);
    } catch (AssertionFailedError e) {
        ((Element) controlDocument.getDocumentElement().getFirstChild()).setAttributeNS(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI, javax.xml.XMLConstants.XMLNS_ATTRIBUTE + ":abc", "http://www.example.org/");
        this.assertXMLIdentical(controlDocument, testDocument);
    }
}
Example 20
Project: JBossAS_5_1_EDG-master  File: MBeanServerFactoryTEST.java View source code
public void testFindByAgentID() {
    try {
        MBeanServer server1 = MBeanServerFactory.createMBeanServer();
        MBeanServer server2 = MBeanServerFactory.createMBeanServer();
        MBeanServer server3 = MBeanServerFactory.newMBeanServer();
        ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate");
        String agentID1 = (String) server1.getAttribute(delegateName, "MBeanServerId");
        String agentID2 = (String) server2.getAttribute(delegateName, "MBeanServerId");
        String agentID3 = (String) server3.getAttribute(delegateName, "MBeanServerId");
        assertTrue((MBeanServer) MBeanServerFactory.findMBeanServer(agentID1).get(0) == server1);
        assertTrue((MBeanServer) MBeanServerFactory.findMBeanServer(agentID2).get(0) == server2);
        assertTrue(MBeanServerFactory.findMBeanServer(agentID3).size() == 0);
    } catch (AssertionFailedError e) {
        throw e;
    } catch (Throwable t) {
        fail("Unexpected error: " + t.toString());
    }
}
Example 21
Project: newFunf-master  File: ContactProbeTest.java View source code
public void testProbe() {
    Bundle params = new Bundle();
    params.putLong(Parameter.Builtin.PERIOD.name, 0L);
    params.putBoolean(ContactProbe.FULL_PARAM.getName(), true);
    startProbe(params);
    Bundle data = getData(30);
    assertNotNull(data.get(BaseProbeKeys.TIMESTAMP));
    ArrayList<Parcelable> contactData = data.getParcelableArrayList(ContactProbe.CONTACT_DATA);
    assertNotNull(contactData);
    int count = 1;
    while (data != null) {
        try {
            data = getData(5);
            count++;
        } catch (AssertionFailedError e) {
            assertTrue(contactData.size() > 0);
            Log.i("ContactProbeTest", "Contact keys: " + Utils.join(Utils.getValues(data).keySet(), ", "));
            for (Parcelable dataRow : contactData) {
                Bundle b = (Bundle) dataRow;
                Log.i("ContactProbeTest", "Data keys: " + b.getString(Data.MIMETYPE) + ":" + String.valueOf(b.get(Data.DATA1)) + " - Others: " + Utils.join(Utils.getValues(b).keySet(), ", "));
            }
            data = null;
        }
    }
    Log.i("ContactProbeTest", "Count: " + String.valueOf(count));
}
Example 22
Project: sisu-guice-master  File: ContinuingHttpServletRequestTest.java View source code
public void testReturnDelegateCookies() {
    Cookie[] cookies = new Cookie[] { new Cookie("testName1", TEST_VALUE_1), new Cookie("testName2", "testValue2") };
    HttpServletRequest delegate = createMock(HttpServletRequest.class);
    expect(delegate.getCookies()).andStubReturn(cookies);
    replay(delegate);
    ContinuingHttpServletRequest continuingRequest = new ContinuingHttpServletRequest(delegate);
    assertCookieArraysEqual(cookies, continuingRequest.getCookies());
    // Now mutate the original cookies, this shouldnt be reflected in the continued request.
    cookies[0].setValue("INVALID");
    cookies[1].setValue("INVALID");
    cookies[1].setMaxAge(123);
    try {
        assertCookieArraysEqual(cookies, continuingRequest.getCookies());
        throw new Error();
    } catch (AssertionFailedError e) {
    }
    // Verify that they remain equal to the original values.
    assertEquals(TEST_VALUE_1, continuingRequest.getCookies()[0].getValue());
    assertEquals(TEST_VALUE_2, continuingRequest.getCookies()[1].getValue());
    assertEquals(DEFAULT_MAX_AGE, continuingRequest.getCookies()[1].getMaxAge());
    // Perform a snapshot of the snapshot.
    ContinuingHttpServletRequest furtherContinuingRequest = new ContinuingHttpServletRequest(continuingRequest);
    // The cookies should be fixed.
    assertCookieArraysEqual(continuingRequest.getCookies(), furtherContinuingRequest.getCookies());
    verify(delegate);
}
Example 23
Project: strongback-java-master  File: ExecutableTimerTest.java View source code
/**
     * Time for the given duration the execution using the supplied mode and execution period.
     *
     * @param mode the execution wait mode; may not be null
     * @param millisecondExecutionPeriod the execution period in milliseconds
     * @param sampleTimeInMilliseconds the sample time in milliseconds
     */
protected void runTimer(TimerMode mode, int millisecondExecutionPeriod, int sampleTimeInMilliseconds) {
    try {
        Strongback.configure().useExecutionTimerMode(mode).useExecutionPeriod(millisecondExecutionPeriod, TimeUnit.MILLISECONDS).initialize();
        assertThat(ExecutableTimer.measureTimingAndPrint(Strongback.executor(), mode.toString() + " for " + millisecondExecutionPeriod + " ms", sampleTimeInMilliseconds / millisecondExecutionPeriod).await(10, TimeUnit.SECONDS).isComplete());
    } catch (InterruptedException e) {
        Thread.interrupted();
        throw new AssertionFailedError();
    }
}
Example 24
Project: eclipse.jdt.core-master  File: AnnotationValueProcessor.java View source code
public void process() {
    ProcessorTestStatus.setProcessorRan();
    try {
        TypeDeclaration typeDecl = _env.getTypeDeclaration("question.AnnotationTest");
        junit.framework.TestCase.assertNotNull("failed to locate type 'question.AnnotationTest'", typeDecl);
        if (typeDecl != null) {
            FieldDeclaration firstFieldDecl = null;
            for (FieldDeclaration fieldDeclaration : typeDecl.getFields()) {
                firstFieldDecl = fieldDeclaration;
                break;
            }
            AnnotationMirror rtVisibleAnnotationMirror = null;
            for (AnnotationMirror annotationMirror : firstFieldDecl.getAnnotationMirrors()) {
                if (annotationMirror.getAnnotationType().getDeclaration().getSimpleName().equals("RTVisibleAnno")) {
                    rtVisibleAnnotationMirror = annotationMirror;
                    break;
                }
            }
            final Map<String, String> namesToValues = new HashMap<String, String>();
            namesToValues.put("name", "\"Foundation\"");
            namesToValues.put("boolValue", "false");
            namesToValues.put("byteValue", "16");
            namesToValues.put("charValue", "'c'");
            namesToValues.put("doubleValue", "99.0");
            namesToValues.put("floatValue", "9.0");
            namesToValues.put("intValue", "999");
            namesToValues.put("longValue", "3333");
            namesToValues.put("shortValue", "3");
            namesToValues.put("colors", "{question.Color.RED, question.Color.BLUE}");
            namesToValues.put("anno", "@question.SimpleAnnotation(value = \"core\")");
            namesToValues.put("simpleAnnos", "[email protected](value = \"org\"), @question.SimpleAnnotation(value = \"eclipse\"), @question.SimpleAnnotation(value = \"jdt\")}");
            namesToValues.put("clazzes", "{java.lang.Object.class, java.lang.String.class}");
            namesToValues.put("clazz", "java.lang.Object.class");
            assertAnnotation(namesToValues, rtVisibleAnnotationMirror);
        }
    } catch (ComparisonFailure failure) {
        if (!ProcessorTestStatus.hasErrors()) {
            ProcessorTestStatus.failWithoutException(failure.toString());
        }
        throw failure;
    } catch (junit.framework.AssertionFailedError error) {
        if (!ProcessorTestStatus.hasErrors()) {
            ProcessorTestStatus.failWithoutException(error.toString());
        }
        throw error;
    }
}
Example 25
Project: clinic-softacad-master  File: AbstractTransactionalAccessTestCase.java View source code
@Override
public void run() {
    try {
        long txTimestamp = System.currentTimeMillis();
        BatchModeTransactionManager.getInstance().begin();
        assertEquals("Correct initial value", VALUE1, localAccessStrategy.get(KEY, txTimestamp));
        localAccessStrategy.update(KEY, VALUE2, new Integer(2), new Integer(1));
        pferLatch.countDown();
        commitLatch.await();
        BatchModeTransactionManager.getInstance().commit();
    } catch (Exception e) {
        log.error("node1 caught exception", e);
        node1Exception = e;
        rollback();
    } catch (AssertionFailedError e) {
        node1Failure = e;
        rollback();
    } finally {
        completionLatch.countDown();
    }
}