Example usage for junit.framework Assert assertTrue

List of usage examples for junit.framework Assert assertTrue

Introduction

In this page you can find the example usage for junit.framework Assert assertTrue.

Prototype

static public void assertTrue(String message, boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testEvaluateStringWithExpressionNotMatchingDocument()
        throws ParserConfigurationException, XPathExpressionException {
    PTestServerConfigurationParser p = new PTestServerConfigurationParser();
    String result = p.evaluateString(p.xpathExpressionHostname,
            DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
    Assert.assertNotNull("The result must not be null", result);
    Assert.assertTrue("The result must be empty", result.isEmpty());
}

From source file:eu.stratosphere.pact.runtime.task.CoGroupTaskExternalITCase.java

@Test
public void testExternalSortCoGroupTask() {

    int keyCnt1 = 16384;
    int valCnt1 = 4 * 2;

    int keyCnt2 = 65536 * 2;
    int valCnt2 = 1;

    super.initEnvironment(6 * 1024 * 1024);
    super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 1);
    super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 2);
    super.addOutput(this.outList);

    CoGroupTask<PactRecord, PactRecord, PactRecord> testTask = new CoGroupTask<PactRecord, PactRecord, PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.SORT_BOTH_MERGE);
    super.getTaskConfig().setMemorySize(6 * 1024 * 1024);
    super.getTaskConfig().setNumFilehandles(4);

    final int[] keyPos1 = new int[] { 0 };
    final int[] keyPos2 = new int[] { 0 };
    @SuppressWarnings("unchecked")
    final Class<? extends Key>[] keyClasses = (Class<? extends Key>[]) new Class[] { PactInteger.class };

    PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(),
            super.getTaskConfig().getPrefixForInputParameters(0), keyPos1, keyClasses);
    PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(),
            super.getTaskConfig().getPrefixForInputParameters(1), keyPos2, keyClasses);

    super.registerTask(testTask, MockCoGroupStub.class);

    try {/*from  ww w . ja v  a 2  s .  c o m*/
        testTask.invoke();
    } catch (Exception e) {
        LOG.debug(e);
        Assert.fail("Invoke method caused exception.");
    }

    int expCnt = valCnt1 * valCnt2 * Math.min(keyCnt1, keyCnt2) + Math.max(keyCnt1, keyCnt2)
            - Math.min(keyCnt1, keyCnt2);

    Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt,
            this.outList.size() == expCnt);

    this.outList.clear();

}

From source file:net.sf.dynamicreports.test.jasper.chart.XyBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*  w  w  w .j  ava2 s  .  c om*/

    JFreeChart chart = getChart("summary.chart1", 0);
    XYPlot plot = chart.getXYPlot();
    Assert.assertEquals("renderer", XYBarRenderer.class, plot.getRenderer().getClass());
    Assert.assertTrue("show labels", plot.getRenderer().getBaseItemLabelsVisible());
    //Assert.assertFalse("show tick labels", plot.getDomainAxis().isTickMarksVisible());
    //Assert.assertFalse("show tick marks", plot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:com.googlecode.ehcache.annotations.integration.ConfigurationFailureTest.java

/**
 * Test verifies behavior when the "default-cache-key-generator" attribute
 * on the main config element refers to a bean name that does not exist. 
 *//*  w w  w . j a  v a 2s . c  om*/
@Test
public void testMissingOverrideDefaultCacheKeyGenerator() {
    try {
        new ClassPathXmlApplicationContext("/noOverrideDefaultCacheKeyGeneratorTestContext.xml");
        Assert.fail("Test should have failed with due to missing bean for default-cache-key-generator");
    } catch (BeanCreationException bce) {
        Throwable cause = bce;
        while (cause.getCause() != null) {
            cause = cause.getCause();
        }

        final StringWriter stack = new StringWriter();
        cause.printStackTrace(new PrintWriter(stack));
        Assert.assertTrue(
                "Root cause must be NoSuchBeanDefinitionException but was: " + cause + "\n " + stack.toString(),
                cause instanceof NoSuchBeanDefinitionException);
    }
}

From source file:eu.delving.sip.TestCoordinateConversion.java

private void checkLatLong(String line, String latLongString) {
    String[] latLong = latLongString.split(",");
    double latitude = Double.parseDouble(latLong[0]);
    double longitude = Double.parseDouble(latLong[1]);
    Assert.assertTrue(String.format("Latitude is outside Norway [%s]=>[%s]", line, latLongString),
            latitude > 58.0 && latitude < 72.0);
    Assert.assertTrue(String.format("Longitude is outside Norway [%s]=>[%s]", line, latLongString),
            longitude > 4.0 && longitude < 30.0);
}

From source file:eu.stratosphere.pact.runtime.sort.AsynchonousPartialSorterITCase.java

@After
public void afterTest() {
    this.ioManager.shutdown();
    if (!this.ioManager.isProperlyShutDown()) {
        Assert.fail("I/O Manager was not properly shut down.");
    }/*from w ww. j a  va 2 s  . c o  m*/

    if (this.memoryManager != null) {
        Assert.assertTrue("Memory leak: not all segments have been returned to the memory manager.",
                this.memoryManager.verifyEmpty());
        this.memoryManager.shutdown();
        this.memoryManager = null;
    }
}

From source file:com.sap.prd.mobile.ios.mios.AlternatePublicHeaderFolderPathTest.java

@Test
public void testHeadersWithPrefix() throws Exception {
    File headersTar = new File(remoteRepositoryDirectory, "com/sap/ondevice/production/ios/tests/MyLibrary/"
            + dynamicVersion + "/MyLibrary-" + dynamicVersion + "-Release-iphoneos.headers.tar");

    Assert.assertTrue("Headers tar file '" + headersTar + "' does not exist", headersTar.exists());

    ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(byteOs);

    try {/*w w w .  j  a  va 2s  . com*/
        Forker.forkProcess(out, null, new String[] { "tar", "-tf", headersTar.getAbsolutePath() });
    } finally {
        IOUtils.closeQuietly(out);
    }
    final String toc = new String(byteOs.toByteArray());
    final String expectedContent = "include/PrintOutObject.h";
    Assert.assertTrue("Table of content of the headers tar file '" + headersTar
            + "' does not contain the expected content '" + expectedContent + "'. Table of content is: " + toc,
            toc.contains(expectedContent));
}

From source file:my.adam.smo.EncryptionTest.java

@Test
public void symmetricEncryptionGaveDifferentCryptogramForSamePlainText() {
    ApplicationContext clientContext = new ClassPathXmlApplicationContext("Context.xml");
    SymmetricEncryptionBox box = clientContext.getBean(SymmetricEncryptionBox.class);
    int plainTextLength = 17;
    Random random = new Random();

    byte[] plainText = new byte[plainTextLength];
    random.nextBytes(plainText);/*from  w w  w. j  a va 2  s .co  m*/

    byte[] cryptogram1 = box.encrypt(plainText);
    byte[] cryptogram2 = box.encrypt(plainText);

    Assert.assertFalse("cryptograms are same", Arrays.equals(cryptogram1, cryptogram2));

    byte[] decrypted1 = box.decrypt(cryptogram1);
    Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted1));

    byte[] decrypted2 = box.decrypt(cryptogram2);
    Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted2));
}

From source file:com.sap.prd.mobile.ios.mios.DependencyToZipToUnpackTest.java

@Test
public void testPrepare() throws Exception {

    final String testName = getTestName();

    final File testSourceDirApp = new File(getTestRootDirectory(), "straight-forward/MyApp");
    final File alternateTestSourceDirApp = new File(getTestRootDirectory(),
            "straight-forward-transitive-bundles");

    final File remoteRepositoryDirectory = getRemoteRepositoryDirectory(getClass().getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    final File zipRepository = new File(new File(".").getCanonicalFile(), "src/test/zipRepository");

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, "1.0." + String.valueOf(System.currentTimeMillis()));
    pomReplacements.setProperty(PROP_NAME_ZIP_REPO_DIR, zipRepository.getAbsolutePath());

    final ProjectModifier projectModifier = new ChainProjectModifier(
            new FileCopyProjectModifier(alternateTestSourceDirApp, "pom.xml"), new ProjectModifier() {

                @Override//ww w  .  j  ava2  s.co m
                public void execute() throws Exception {
                    final File pom = new File(testExecutionDirectory, "pom.xml");
                    FileInputStream fis = null;
                    FileOutputStream fos = null;

                    try {
                        fis = new FileInputStream(pom);
                        final Model model = new MavenXpp3Reader().read(fis);
                        fis.close();
                        fos = new FileOutputStream(pom);
                        Plugin plugin = model.getBuild().getPlugins().get(0);
                        ((Xpp3Dom) plugin.getConfiguration()).getChild("additionalPackagingTypes")
                                .getChild("html5").setValue("UNPACK");
                        new MavenXpp3Writer().write(fos, model);
                    } finally {
                        IOUtils.closeQuietly(fis);
                        IOUtils.closeQuietly(fos);
                    }
                }
            });

    test(testName, testSourceDirApp, "com.sap.prd.mobile.ios.mios:xcode-maven-plugin:"
            + getMavenXcodePluginVersion() + ":prepare-xcode-build", THE_EMPTY_LIST, null, pomReplacements,
            projectModifier);

    File tmp = new File(getTestExecutionDirectory(testName, "MyApp"),
            "target/xcode-deps/html5/" + TestConstants.GROUP_ID + "/MyZip/dummy.txt");

    Assert.assertTrue("File '" + tmp + "' not found", tmp.exists());
}

From source file:com.sap.prd.mobile.ios.mios.DependencyToZipToBundleTest.java

@Test
public void testPrepare() throws Exception {

    final String testName = getTestName();

    final File testSourceDirApp = new File(getTestRootDirectory(), "straight-forward/MyApp");
    final File alternateTestSourceDirApp = new File(getTestRootDirectory(),
            "straight-forward-transitive-bundles");

    final File remoteRepositoryDirectory = getRemoteRepositoryDirectory(getClass().getName());

    prepareRemoteRepository(remoteRepositoryDirectory);

    final File zipRepository = new File(new File(".").getCanonicalFile(), "src/test/zipRepository");

    Properties pomReplacements = new Properties();
    pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath());
    pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, "1.0." + String.valueOf(System.currentTimeMillis()));
    pomReplacements.setProperty(PROP_NAME_ZIP_REPO_DIR, zipRepository.getAbsolutePath());

    final ProjectModifier projectModifier = new ChainProjectModifier(
            new FileCopyProjectModifier(alternateTestSourceDirApp, "pom.xml"), new ProjectModifier() {

                @Override// w w w . j a  v a2  s .  c om
                public void execute() throws Exception {
                    final File pom = new File(testExecutionDirectory, "pom.xml");
                    FileInputStream fis = null;
                    FileOutputStream fos = null;

                    try {
                        fis = new FileInputStream(pom);
                        final Model model = new MavenXpp3Reader().read(fis);
                        fis.close();
                        fos = new FileOutputStream(pom);
                        Plugin plugin = model.getBuild().getPlugins().get(0);
                        ((Xpp3Dom) plugin.getConfiguration()).getChild("additionalPackagingTypes")
                                .getChild("html5").setValue("BUNDLE");
                        new MavenXpp3Writer().write(fos, model);
                    } finally {
                        IOUtils.closeQuietly(fis);
                        IOUtils.closeQuietly(fos);
                    }
                }
            });

    test(testName, testSourceDirApp, "com.sap.prd.mobile.ios.mios:xcode-maven-plugin:"
            + getMavenXcodePluginVersion() + ":prepare-xcode-build", THE_EMPTY_LIST, null, pomReplacements,
            projectModifier);

    File tmp = new File(getTestExecutionDirectory(testName, "MyApp"),
            "target/xcode-deps/html5/" + Constants.GROUP_ID + "/MyZip/MyZip.bundle/dummy.txt");

    Assert.assertTrue("File '" + tmp + "' not found", tmp.exists());
}