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(boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:org.openmrs.web.controller.GlobalPropertyPortletControllerTest.java

/**
 * @see GlobalPropertyPortletController#populateModel(HttpServletRequest,Map)
 *///from   ww  w .  ja va  2 s .  c o m
@SuppressWarnings("unchecked")
@Test
@Verifies(value = "should exclude multiple prefixes", method = "populateModel(HttpServletRequest,Map<String,Object>)")
public void populateModel_shouldExcludeMultiplePrefixes() throws Exception {
    //given
    GlobalPropertyPortletController portletController = new GlobalPropertyPortletController();
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "");
    Map<String, Object> model = new HashMap<String, Object>();

    //when
    String excludePrefix = "file.started;file.mandatory";
    model.put("excludePrefix", excludePrefix);
    GlobalProperty[] globalProperties = { new GlobalProperty("file.started", ""),
            new GlobalProperty("file.mandatory", ""), new GlobalProperty("file.other", "") };
    Context.getAdministrationService().saveGlobalProperties(Arrays.asList(globalProperties));

    //then
    portletController.populateModel(request, model);
    List<GlobalProperty> properties = (List<GlobalProperty>) model.get("properties");
    Assert.assertFalse(properties.contains(globalProperties[0]));
    Assert.assertFalse(properties.contains(globalProperties[1]));
    Assert.assertTrue(properties.contains(globalProperties[2]));
}

From source file:it.geosolutions.geobatch.testsuite.FileBasedFlowManagerTestCase.java

@Test
public void testFSFlowManagerService() throws IOException, InterruptedException {
    // ///* www. j  a va 2 s.  com*/
    //
    // get the FileBasedEventGeneratorService bean service from the context
    //
    // //
    Object o = context.getBean("fsFlowManagerService", FileBasedFlowManagerService.class);
    Assert.assertNotNull(o);
    Assert.assertTrue(o instanceof FileBasedFlowManagerService);

    final FileBasedFlowManagerService service = (FileBasedFlowManagerService) o;

    // //
    //
    // Create a fictitious EventGeneratorConfiguration configuration
    //
    // //
    //        final FileBasedEventGeneratorConfiguration eventGeneratorConfiguration = new FileBasedEventGeneratorConfiguration();
    //        eventGeneratorConfiguration.setId("id");
    //        eventGeneratorConfiguration.setName("name");
    //        eventGeneratorConfiguration.setDescription("description");
    //        eventGeneratorConfiguration.setOsType(OsType.OS_UNDEFINED);
    //        eventGeneratorConfiguration.setWorkingDirectory(TestData.file(this, ".").getAbsolutePath());
    //
    //        // //
    //        //
    //        // Create a fictitious EventGeneratorConfiguration configuration
    //        //
    //        // //
    //        final FileBasedEventConsumerConfiguration eventConsumerConfiguration = new FileBasedEventConsumerConfiguration();
    //        eventConsumerConfiguration.setId("fsEventConsumerConfiguration");
    //        eventConsumerConfiguration.setName("fsEventConsumerConfiguration");
    //        eventConsumerConfiguration.setDescription("fsEventConsumerConfiguration");
    //        eventConsumerConfiguration.setWorkingDirectory(TestData.file(this, ".").getAbsolutePath());
    //
    //        final FileEventRule rule = new FileEventRule();
    //        rule.setAcceptableNotifications(Arrays.asList(FileSystemEventType.FILE_ADDED));
    //        rule.setActualOccurrencies(1);
    //        rule.setId("tesRule");
    //        rule.setOptional(false);
    //        rule.setRegex(".*\\.txt");
    //        eventConsumerConfiguration.setRules(Arrays.asList(rule));
    // eventConsumerConfiguration.setActions(Arrays.asList(new
    // BaseAction<FileSystemEvent>() {
    //
    //
    // public FileSystemEvent process(
    // FileSystemEvent event) {
    // FileBasedFlowManagerTestCase.this.LOGGER.info(event.toString());
    // return event;
    // }});

    // flow configuration
    //        final FileBasedFlowConfiguration flowConfiguration = new FileBasedFlowConfiguration();
    //        flowConfiguration.setId("id");
    //        flowConfiguration.setName("name");
    //        flowConfiguration.setDescription("description");
    //        flowConfiguration.setWorkingDirectory(TestData.file(this, ".").getAbsolutePath());
    //        flowConfiguration.setEventConsumerConfiguration(eventConsumerConfiguration);
    //        flowConfiguration.setEventGeneratorConfiguration(eventGeneratorConfiguration);

    // //
    //
    // Check if we can create the needed EventGenerator and if so create it
    //
    // //
    //        final boolean result = service.canCreateFlowManager(flowConfiguration);
    //        Assert.assertTrue(result);
    //
    //        // create the event generator
    //        final FileBasedFlowManager eg = service.createFlowManager(flowConfiguration);
    //        Thread flowM = new Thread(eg);
    //        flowM.start();

    Thread.sleep(10000);

    //
    //
    final File file = TestData.temp(this, "test");
    // if(file.exists()) {
    synchronized (this) {
        this.wait(5000);
    }
    // Assert.assertTrue("unable to create test",this.caughtEvent);
    // }
    // else
    // Assert.assertTrue("unable to create test",false);

}

From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java

@Test
public void ChainedCursorFunctionTest() {
    this.logger.info("ChainedFunctionTest");
    try {// w ww  . j a va2 s. c  o m
        BQResultSetFunctionTest.Result.beforeFirst();
        Assert.assertTrue(BQResultSetFunctionTest.Result.next());
        Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1));

    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }
    try {
        Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(10));
        Assert.assertEquals("word", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertFalse(BQResultSetFunctionTest.Result.next());
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertEquals("", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }

    }

    try {
        Assert.assertTrue(BQResultSetFunctionTest.Result.first());
        Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertTrue(BQResultSetFunctionTest.Result.isFirst());
        Assert.assertFalse(BQResultSetFunctionTest.Result.previous());
        BQResultSetFunctionTest.Result.afterLast();
        Assert.assertTrue(BQResultSetFunctionTest.Result.isAfterLast());
        Assert.assertTrue(BQResultSetFunctionTest.Result.absolute(-1));
        Assert.assertEquals("word", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertTrue(BQResultSetFunctionTest.Result.relative(-5));
        Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertFalse(BQResultSetFunctionTest.Result.relative(6));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }
    }
    this.logger.info("chainedfunctiontest end");
}

From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java

@Test
public void ChainedCursorFunctionTest() {
    this.logger.info("ChainedFunctionTest");
    try {/*from w ww  . ja  va 2s.  co  m*/
        BQScrollableResultSetFunctionTest.Result.beforeFirst();
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next());
        Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1));

    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }
    try {
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(10));
        Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.next());
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }

    }

    try {
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.first());
        Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.isFirst());
        Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.previous());
        BQScrollableResultSetFunctionTest.Result.afterLast();
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.isAfterLast());
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.absolute(-1));
        Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.relative(-5));
        Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.relative(6));
    } catch (SQLException e) {
        this.logger.error("SQLexception" + e.toString());
        Assert.fail("SQLException" + e.toString());
    }

    try {
        Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1));
    } catch (SQLException e) {
        boolean ct = e.toString().contains("Cursor is not in a valid Position");
        if (ct == true) {
            Assert.assertTrue(ct);
        } else {
            this.logger.error("SQLexception" + e.toString());
            Assert.fail("SQLException" + e.toString());
        }
    }
    this.logger.info("chainedfunctiontest end");
}

From source file:com.currencyfair.minfraud.MinFraudImplTest.java

@Test
public void testRiskScoreResponseIsExtractedFromValidHttpResponse() throws Exception {
    StringEntity responseEntity = new StringEntity(VALID_RESPONSE, ContentType.TEXT_PLAIN);
    HttpMethodFactory methodFactory = expectCreateHttpPost();
    CloseableHttpResponse httpResponse = EasyMock.createMock(CloseableHttpResponse.class);
    expectHttpResponse(httpResponse, 200, responseEntity);
    expectClose(httpResponse, null);//from  w  w  w .j a va 2 s .  c om
    HttpClient client = expectHttpInvocation(httpResponse);
    EasyMock.replay(httpResponse);
    minFraudImpl.setHttpClient(client);
    minFraudImpl.setMethodFactory(methodFactory);
    minFraudImpl.setEndpoint(ENDPOINT);
    RiskScoreResponse response = minFraudImpl.calculateRisk(newRiskScoreRequest());
    Assert.assertNotNull(response);
    Assert.assertEquals(new BigDecimal("23.2"), response.getRiskScore());
    Assert.assertTrue(response.getGeoIpDetails().isCountryMatch());
    Assert.assertFalse(response.getGeoIpDetails().isHighRiskCountry());
    Assert.assertEquals("IE", response.getGeoIpDetails().getIpCountryCode());
    Assert.assertEquals(Integer.valueOf(48), response.getGeoIpDetails().getDistance());
    EasyMock.verify(httpResponse);
}

From source file:almira.weblogic.JndiInjectorTest.java

@Test
public void tokenizesPropertyPairs() {
    Properties parsedProperties = injector.getProperties(ARGUMENTS);
    for (Entry<Object, Object> entry : parsedProperties.entrySet()) {
        Object key = entry.getKey();
        Assert.assertTrue(PROPERTIES.containsKey(key));
        Assert.assertEquals(PROPERTIES.get(key), entry.getValue());
    }/*from  w  w w. java2  s .  com*/
}

From source file:cn.javass.spring.chapter4.ResourcePatternTest.java

@Test
public void testClasspathAsteriskPrefixLimit() throws IOException {
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

    //ClassLoader.getResources("")
    //??jar//from   www  . j a  va  2 s .  co m
    //?????
    Resource[] resources = resolver.getResources("classpath*:asm-*.txt");
    Assert.assertTrue(resources.length == 0);

    //ClassLoader.getResources("asm-license.txt")
    //asm-license.txtcom.springsource.net.sf.cglib-2.2.0.jar
    resources = resolver.getResources("classpath*:asm-license.txt");
    Assert.assertTrue(resources.length > 0);

    //??Resource
    resources = resolver.getResources("classpath*:LICENS*");
    Assert.assertTrue(resources.length == 1);
}

From source file:at.tugraz.ist.akm.test.webservice.server.SimpleWebServerTest.java

License:asdf

synchronized private void startServer(final boolean useMockServer) throws Exception {
    if (mWebserver != null) {
        if (mWebserver.isRunning()) {
            stopServer();//from w  w w.j av  a  2  s  .  c o  m
        }
        mWebserver = null;
    }

    mWebserver = useMockServer ? new MockSimpleWebServer(mContext, mServerConfig)
            : new SimpleWebServer(mContext, mServerConfig, null);

    mHttpClient = new DefaultHttpClient();

    Assert.assertTrue(mWebserver.startServer());
    waitForServiceBeingStarted(50, 200);
    assertTrue(mWebserver.isRunning());
}

From source file:io.cloudslang.lang.compiler.PreCompileTransformersTest.java

@Test
public void testOpInvalidInput() throws Exception {
    URI resource = getClass().getResource("/corrupted/transformers/operation_input_private_no_default.sl")
            .toURI();/*from w ww .j  a  v a  2s  .c  o  m*/
    ExecutableModellingResult result = compiler.preCompileSource(SlangSource.fromFile(resource));

    Assert.assertNotNull(result);

    Executable executable = result.getExecutable();
    Assert.assertNotNull(executable);
    List<Input> inputs = executable.getInputs();
    Assert.assertEquals(6, inputs.size());

    List<RuntimeException> errors = result.getErrors();
    Assert.assertNotNull(errors);
    Assert.assertTrue(errors.size() > 0);
    exception.expect(RuntimeException.class);
    exception.expectMessage("For operation 'operation_input_private_no_default' syntax is illegal.");
    exception.expectMessage(
            "Input: 'input_private_no_default' is private and required but no default value was specified");
    throw errors.get(0);
}

From source file:com.sludev.commons.vfs2.provider.s3.SS3TestUtils.java

public static void deleteFile(String accntName, String accntHost, String accntKey, String containerName,
        Path remotePath) throws FileSystemException {
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(SS3Constants.S3SCHEME, new SS3FileProvider());
    currMan.init();/*from   w w w.j av a2  s. co m*/

    StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey);
    FileSystemOptions opts = new FileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);

    String currUriStr = String.format("%s://%s/%s/%s", SS3Constants.S3SCHEME, accntHost, containerName,
            remotePath);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);

    Boolean delRes = currFile.delete();
    Assert.assertTrue(delRes);
}