List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(String message, boolean condition)
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendCommentAddedEmail() throws Exception { SobaMessage sobaMessage = new SobaMessage.Builder().sender(testUser).providerId("test") .visibility(SobaObject.Visibility.ACCOUNT).transformedMessage(LOREM_IPSUM).type(MessageType.USER) .build();/* ww w . ja v a 2 s. c o m*/ sobaMessage.setId(new ObjectId()); MessageComment messageComment = new MessageComment(testSenderUser, LOREM_IPSUM); when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser)); testSenderUser.setId(new ObjectId()); emailService.sendCommentAddedEmail(testAccount, sobaMessage, messageComment); ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); String emailContent = captor.getValue().getMessage().getBody().getHtml().getData(); Assert.assertFalse("Encountered unexpanded template token.", emailContent.contains("${")); }
From source file:com.sap.prd.mobile.ios.mios.FatBinaryTest.java
@Test public void testFallbackToFatLibs() throws Exception { final String testName = getTestName(); final File thinLibReleaseIPhoneOsRemoteRepo = new File(remoteRepoDir, "com/sap/ondevice/production/ios/tests/MyLibrary/" + dynamicVersion + "/MyLibrary-" + dynamicVersion + "-Release-iphoneos.a"); final File testSourceDirApp = new File(getTestRootDirectory(), "straight-forward/MyApp"); final File alternateTestSourceDirApp = new File(getTestRootDirectory(), "straight-forward-fat-libs/MyApp"); if (!thinLibReleaseIPhoneOsRemoteRepo.delete()) throw new IOException("Cannot delete release fat lib file: " + thinLibReleaseIPhoneOsRemoteRepo); Verifier verifier = new Verifier(getTestExecutionDirectory(testName, "MyApp").getAbsolutePath()); verifier.deleteArtifacts("com.sap.ondevice.production.ios.tests"); Map<String, String> additionalSystemProperties = new HashMap<String, String>(); Properties pomReplacements = new Properties(); pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepoDir.getAbsolutePath()); pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion); test(verifier, testName, testSourceDirApp, "install", THE_EMPTY_LIST, additionalSystemProperties, pomReplacements, new FileCopyProjectModifier(alternateTestSourceDirApp)); final File testRootDir = getTestExecutionDirectory(testName, "MyApp"); final File fatLibReleaseInProject = new File(testRootDir, "target/xcode-deps/libs/Release/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a"); final File thinLibReleaseInProject = new File(testRootDir, "target/libs/Release-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a"); Assert.assertTrue("Fat lib '" + fatLibReleaseInProject + " does not exist but was expected to be present.", fatLibReleaseInProject.exists()); Assert.assertFalse("Thin lib for release '" + thinLibReleaseInProject + "exist but must not be present.", thinLibReleaseInProject.exists()); Assert.assertFalse(new File(testRootDir, "target/libs/Release-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists());/*from w w w.j a v a 2s . c o m*/ Assert.assertFalse(new File(testRootDir, "target/xcode-deps/libs/Debug/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertTrue(new File(testRootDir, "target/libs/Debug-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertTrue(new File(testRootDir, "target/libs/Debug-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); }
From source file:org.apache.synapse.transport.passthru.config.SourceConfigurationTest.java
@Test public void testGetBooleanValue() throws Exception { boolean enableAdvancedForS2SView = sourceConfiguration .getBooleanValue(PassThroughConstants.SYNAPSE_PASSTHROUGH_S2SLATENCY_ADVANCE_VIEW, false); Assert.assertFalse(PassThroughConstants.SYNAPSE_PASSTHROUGH_S2SLATENCY_ADVANCE_VIEW + " is enabled", enableAdvancedForS2SView);/* w ww. j a va2 s . c o m*/ }
From source file:DocumentCountFunctionalTest.java
@Test public void testRouteRawOrientDB() { running(getFakeApplication(), new Runnable() { public void run() { //creates a fake collection String sFakeCollection = new AdminCollectionFunctionalTest().routeCreateCollection(); //creates a dummy user String sFakeUser = "UserTestCount_" + UUID.randomUUID(); // Prepare test user JsonNode node = updatePayloadFieldValue("/adminUserCreatePayload.json", "username", sFakeUser); // Create user FakeRequest request = new FakeRequest("POST", "/user"); request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE); request = request.withJsonBody(node, "POST"); Result result = routeAndCall(request); assertRoute(result, "testRouteGetDocumentsCountWithStart -create fake user", 201, null, false); //insert 2 records using admin result = routeCreateDocument(getRouteAddress(sFakeCollection)); result = routeCreateDocument(getRouteAddress(sFakeCollection)); try { DbHelper.open("1234567890", sFakeUser, "passw1"); } catch (InvalidAppCodeException e) { assertFail("AppCode not valid(??!!!??) - " + ExceptionUtils.getMessage(e)); }/*from w w w . ja va 2s . com*/ long count = 0; try { List<ODocument> listOfdoc = (List<ODocument>) DbHelper .genericSQLStatementExecute("select count(*) from " + sFakeCollection, new String[] {}); ODocument doc = listOfdoc.get(0); count = (Long) doc.field("count"); } catch (Exception e) { assertFail(ExceptionUtils.getMessage(e)); } finally { if (DbHelper.getConnection() != null && !DbHelper.getConnection().isClosed()) DbHelper.getConnection().close(); } //these two tests will fail when OrientDB will be patched, actually it will need to be swapped //this is WRONG, should not pass when OrientDB will be patched Assert.assertTrue("Finally OrientDB is patched", count == 2); //this is wrong too Assert.assertFalse("Finally OrientDB is patched", count == 0); } }); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendUserMessageEmail() throws Exception { SobaMessage sobaMessage = new SobaMessage.Builder().sender(testUser).providerId("test") .visibility(SobaObject.Visibility.ACCOUNT).transformedMessage(LOREM_IPSUM).type(MessageType.USER) .build();/*ww w . j a va 2 s.c o m*/ sobaMessage.setId(new ObjectId()); testUser.getConfig().put(User.ConfigKeys.RECEIVES_COMMENT_NOTIFICATIONS, false); testSenderUser.setId(new ObjectId()); JSONObject payload = new JSONObjectBuilder().add("subject", "Test Subject").add("body", "Test Body") .add("recipient", "testuser@nodeable.com").build(); emailService.sendUserMessageEmail(testSenderUser, sobaMessage, payload); ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); String emailContent = captor.getValue().getMessage().getBody().getHtml().getData(); Assert.assertFalse("Encountered unexpanded template token in email content: " + emailContent, emailContent.contains("${")); }
From source file:com.rmn.qa.aws.VmManagerTest.java
@Test // Test if multiple security groups can be passed when launching a node public void testLaunchNodesMultipleSecurityGroups() throws NodesCouldNotBeStartedException { MockAmazonEc2Client client = new MockAmazonEc2Client(null); RunInstancesResult runInstancesResult = new RunInstancesResult(); Reservation reservation = new Reservation(); reservation.setInstances(Arrays.asList(new Instance())); runInstancesResult.setReservation(reservation); client.setRunInstances(runInstancesResult); Properties properties = new Properties(); String region = "east", uuid = "uuid", browser = "chrome", os = null; Integer threadCount = 5, maxSessions = 5; MockManageVm manageEC2 = new MockManageVm(client, properties, region); String userData = "userData"; String securityGroup = "securityGroup1,securityGroup2,securityGroup3", subnetId = "subnetId", keyName = "keyName", linuxImage = "linuxImage"; String[] splitSecurityGroupdIds = securityGroup.split(","); List securityGroupIdsAryLst = new ArrayList(); if (securityGroup != null) { for (int i = 0; i < splitSecurityGroupdIds.length; i++) { securityGroupIdsAryLst.add(splitSecurityGroupdIds[i]); }//from w ww. j ava 2 s . c o m } properties.setProperty(region + "_security_group", securityGroup); properties.setProperty(region + "_subnet_id", subnetId); properties.setProperty(region + "_key_name", keyName); properties.setProperty(region + "_linux_node_ami", linuxImage); manageEC2.setUserData(userData); manageEC2.launchNodes(uuid, os, browser, null, threadCount, maxSessions); RunInstancesRequest request = client.getRunInstancesRequest(); request.setSecurityGroupIds(securityGroupIdsAryLst); List<String> securityGroups = request.getSecurityGroupIds(); List<String> expectedSecurityGroups = Arrays .asList("securityGroup1,securityGroup2,securityGroup3".split(",")); Assert.assertTrue("Security groups should match all given security groups", securityGroups.containsAll(expectedSecurityGroups)); List<String> invalidSecurityGroups = Arrays .asList("securityGroup1,securityGroup2,securityGroup7".split(",")); Assert.assertFalse("Security groups should match only the set security groups", securityGroups.containsAll(invalidSecurityGroups)); Assert.assertFalse("Security group should not be empty", request.getSecurityGroupIds().isEmpty()); Assert.assertEquals("More than 1 security group should be set", 3, securityGroups.size()); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testSendUserMessageAddedEmail() throws Exception { SobaMessage sobaMessage = new SobaMessage.Builder().sender(testUser).providerId("test") .visibility(SobaObject.Visibility.ACCOUNT).transformedMessage(LOREM_IPSUM).type(MessageType.USER) .build();// ww w. ja va 2 s . c o m sobaMessage.setId(new ObjectId()); when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser)); testSenderUser.setId(new ObjectId()); emailService.sendUserMessageAddedEmail(testSenderUser, sobaMessage); ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); String emailContent = captor.getValue().getMessage().getBody().getHtml().getData(); Assert.assertFalse("Encountered unexpanded template token.", emailContent.contains("${")); }
From source file:com.streamreduce.core.service.EmailServiceImplTest.java
@Test public void testConnectionBrokenEmail() throws Exception { Connection mockConnection = mock(Connection.class); when(mockConnection.getId()).thenReturn(new ObjectId()); when(mockConnection.getAccount()).thenReturn(testAccount); when(mockConnection.getAlias()).thenReturn("My Test Connection"); when(mockUserService.getAccountAdmin(testAccount)).thenReturn(testUser); testSenderUser.setId(new ObjectId()); emailService.sendConnectionBrokenEmail(mockConnection); ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class); verify(mockAmazonSimpleEmailServiceClient).sendEmail(captor.capture()); Body body = captor.getValue().getMessage().getBody(); String htmlContent = body.getHtml().getData(); String textContent = body.getText().getData(); Assert.assertFalse("Encountered unexpanded template token.", htmlContent.contains("${")); Assert.assertFalse("Encountered unexpanded template token.", textContent.contains("${")); }
From source file:org.cloudifysource.azure.CliAzureDeploymentTest.java
public void test() throws Exception { List<List<String>> commands = new ArrayList<List<String>>(); // CLI uses groovy to parse the path which requires either a double backslash or a single slash String applicationAbsolutePath = applicationFile.getAbsolutePath().replaceAll(Pattern.quote("\\"), "/"); List<String> boostrapApplicationCommand = Arrays.asList("azure:bootstrap-app", "--verbose", "-timeout", String.valueOf(TIMEOUT_IN_MINUTES), "-progress", String.valueOf(POLLING_INTERVAL_IN_MINUTES), "-azure-svc", AZURE_HOSTED_SERVICE, "-azure-pwd", RDP_PFX_FILE_PASSWORD, "-azure-location", "'" + AZURE_REGION + "'", applicationAbsolutePath); commands.add(boostrapApplicationCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear();// w w w . ja v a 2 s . c o m String deploymentUrl = deployment.getUrl(); final URL restAdminMachinesUrl = getMachinesUrl(deploymentUrl); log("Getting number of running machines"); repetativeAssert("Number of machines", new RepetativeConditionProvider() { @Override public boolean getCondition() { try { int numberOfMachines = getNumberOfMachines(restAdminMachinesUrl); logger.info("Actual numberOfMachines=" + numberOfMachines + ". Expected numberOfMachins=" + EXPECTED_NUMBER_OF_MACHINES); return EXPECTED_NUMBER_OF_MACHINES == numberOfMachines; } catch (Exception e) { logger.log(Level.WARNING, "Exception while calculating numberOfMachines", e); return false; } } }); List<String> connectCommand = Arrays.asList("azure:connect-app", "--verbose", "-timeout 5", "-azure-svc", AZURE_HOSTED_SERVICE); List<String> installApplicationCommand = Arrays.asList("install-application", "--verbose", applicationAbsolutePath); commands.add(connectCommand); commands.add(installApplicationCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear(); final URI travelApplicationUrl = getTravelApplicationUrl(deploymentUrl).toURI(); RepetativeConditionProvider applicationInstalledCondition = new RepetativeConditionProvider() { @Override public boolean getCondition() { try { URL url = travelApplicationUrl.toURL(); return isUrlAvailable(url); } catch (Exception e) { logger.log(Level.WARNING, "Exception while checking if " + travelApplicationUrl.toString() + " is available", e); return false; } } }; repetativeAssert("Failed waiting for travel application", applicationInstalledCondition); List<String> setInstancesScaleOutCommand = Arrays.asList("azure:set-instances", "--verbose", "-azure-svc", AZURE_HOSTED_SERVICE, TOMCAT_SERVICE, NUMBER_OF_INSTANCES_FOR_TOMCAT_SERVICE); commands.add(connectCommand); commands.add(setInstancesScaleOutCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear(); repetativeAssert("Failed waiting for scale out", new RepetativeConditionProvider() { @Override public boolean getCondition() { try { int numberOfMachines = getNumberOfMachines(restAdminMachinesUrl); logger.info("Actual numberOfMachines=" + numberOfMachines + ". Expected numberOfMachins=" + (EXPECTED_NUMBER_OF_MACHINES + 1)); return numberOfMachines == EXPECTED_NUMBER_OF_MACHINES + 1; } catch (Exception e) { logger.log(Level.WARNING, "Exception while calculating numberOfMachines", e); return false; } } }); List<String> uninstallApplicationCommand = Arrays.asList("uninstall-application", "--verbose", "-timeout", String.valueOf(TIMEOUT_IN_MINUTES), APPLICATION_NAME); commands.add(connectCommand); commands.add(uninstallApplicationCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear(); Assert.assertFalse("Travel application should not be running", isUrlAvailable(travelApplicationUrl.toURL())); List<String> setInstancesScaleInCommand = Arrays.asList("azure:set-instances", "--verbose", "-azure-svc", AZURE_HOSTED_SERVICE, TOMCAT_SERVICE, INITIAL_NUMBER_OF_INSTANCES_FOR_TOMCAT_SERVICE); commands.add(connectCommand); commands.add(setInstancesScaleInCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear(); repetativeAssert("Failed waiting for scale in", new RepetativeConditionProvider() { @Override public boolean getCondition() { try { int numberOfMachines = getNumberOfMachines(restAdminMachinesUrl); logger.info("Actual numberOfMachines=" + numberOfMachines + ". Expected numberOfMachins=" + EXPECTED_NUMBER_OF_MACHINES); return EXPECTED_NUMBER_OF_MACHINES == numberOfMachines; } catch (Exception e) { logger.log(Level.WARNING, "Exception while calculating numberOfMachines", e); return false; } } }); commands.add(connectCommand); commands.add(installApplicationCommand); runCliCommands(cliExecutablePath, commands, isDebugMode); commands.clear(); repetativeAssert("Failed waiting for travel application", applicationInstalledCondition); }
From source file:com.rmn.qa.aws.VmManagerTest.java
@Test // Tests terminating an invalid instance is handled correctly public void testTerminateInstanceInvalidRunningCode() { MockAmazonEc2Client client = new MockAmazonEc2Client(null); String instanceId = "foo"; TerminateInstancesResult terminateInstancesResult = new TerminateInstancesResult(); client.setTerminateInstancesResult(terminateInstancesResult); InstanceStateChange stateChange = new InstanceStateChange(); stateChange.withInstanceId(instanceId); stateChange.setCurrentState(new InstanceState().withCode(8)); terminateInstancesResult.setTerminatingInstances(Arrays.asList(stateChange)); Properties properties = new Properties(); String region = "east"; MockManageVm manageEC2 = new MockManageVm(client, properties, region); boolean success = manageEC2.terminateInstance(instanceId); TerminateInstancesRequest request = client.getTerminateInstancesRequest(); Assert.assertEquals("Instance id size should match", 1, request.getInstanceIds().size()); Assert.assertEquals("Instance ids should match", instanceId, request.getInstanceIds().get(0)); Assert.assertFalse("Termination call should have not been successful", success); }