List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:ejportal.webapp.action.UserActionTest.java
/** * Test search./*ww w . j a v a2s .c om*/ * * @throws Exception * the exception */ public void testSearch() throws Exception { Assert.assertNull(this.action.getUsers()); Assert.assertEquals("success", this.action.list()); Assert.assertNotNull(this.action.getUsers()); Assert.assertFalse(this.action.hasActionErrors()); }
From source file:com.sap.prd.mobile.ios.mios.FatBinaryTest.java
@Test public void testUseThinLibs() throws Exception { final File testSourceDirApp = new File(getTestRootDirectory(), "straight-forward/MyApp"); final File alternateTestSourceDirApp = new File(getTestRootDirectory(), "straight-forward-fat-libs/MyApp"); final String testName = getTestName(); 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(testName, testSourceDirApp, "install", THE_EMPTY_LIST, additionalSystemProperties, pomReplacements, new FileCopyProjectModifier(alternateTestSourceDirApp)); final File testRootDir = getTestExecutionDirectory(testName, "MyApp"); Assert.assertFalse(new File(testRootDir, "target/xcode-deps/libs/Release/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists());/* ww w . j a v a 2 s . c o m*/ Assert.assertTrue(new File(testRootDir, "target/libs/Release-iphoneos/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); Assert.assertTrue(new File(testRootDir, "target/libs/Release-iphonesimulator/com.sap.ondevice.production.ios.tests/MyLibrary/libMyLibrary.a") .exists()); }
From source file:com.vmware.identity.idm.server.LocalOsIdentityProviderTest.java
@Test public void TestUsers() throws Exception { for (UserInfo userInfo : _users.values()) { // --------------------- // findUser // --------------------- PersonUser user = localOsProvider.findUser(new PrincipalId(userInfo.getName(), domainName)); Assert.assertNotNull(String.format("User '%s' should exist.", userInfo.getName()), user); validateUser(user, userInfo);//w w w . j a v a 2 s .com // --------------------- // IsActive // --------------------- boolean isActive = SystemUtils.IS_OS_LINUX ? true : !userInfo.isDisabled(); Assert.assertEquals(isActive, localOsProvider.IsActive(new PrincipalId(userInfo.getName(), domainName))); // --------------------- // getAttributes // --------------------- Collection<AttributeValuePair> attributes = localOsProvider .getAttributes(new PrincipalId(userInfo.getName(), domainName), getAttributes()); Assert.assertNotNull( String.format("Should be able to retrieve attributes for User '%s'.", userInfo.getName()), attributes); for (AttributeValuePair attr : attributes) { Assert.assertNotNull(attr); Assert.assertNotNull(attr.getAttrDefinition()); // new sids attributes comes without the friendly name. // Assert.assertNotNull( attr.getAttrDefinition().getFriendlyName() ); if (GROUPS_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Set<GroupInfo> groups = _usersToGroups.get(userInfo.getName()); if (groups != null && groups.isEmpty() == false) { Assert.assertNotNull(attr.getValues()); Assert.assertTrue(groups.size() <= attr.getValues().size()); HashSet<String> attrGroups = new HashSet<String>(); for (String attributeValue : attr.getValues()) { Assert.assertNotNull(attributeValue); Assert.assertTrue(attributeValue.startsWith(domainName) || (providerHasAlias() && attributeValue.startsWith(domainAlias))); Assert.assertTrue(attributeValue.contains("\\")); String groupName = attributeValue; Assert.assertFalse(groupName.isEmpty()); attrGroups.add(groupName); } for (GroupInfo info : groups) { Assert.assertTrue( String.format("group '%s' is expected to be present", domainName + "\\" + info.getName()), attrGroups.contains(domainName + "\\" + info.getName())); if (providerHasAlias()) { Assert.assertTrue( String.format("group '%s' is expected to be present", domainAlias + "\\" + info.getName()), attrGroups.contains(domainAlias + "\\" + info.getName())); } } } } else if (LAST_NAME_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getLastName(), attr.getValues().get(0)); } else if (FIRST_NAME_FRIENDLY_NAME.equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getFirstName(), attr.getValues().get(0)); } else if (SUBJECT_TYPE_FRIENDLY_NAME .equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString("false", attr.getValues().get(0)); } else if (USER_PRINCIPAL_NAME_FRIENDLY_NAME .equalsIgnoreCase(attr.getAttrDefinition().getFriendlyName())) { Assert.assertNotNull(attr.getValues()); Assert.assertEquals(1, attr.getValues().size()); assertEqualsString(userInfo.getName() + "@" + domainName, attr.getValues().get(0)); } } // --------------------- // findDirectParentGroups, findNestedParentGroups // --------------------- Set<GroupInfo> groups = _usersToGroups.get(userInfo.getName()); PrincipalGroupLookupInfo directParentGroups = localOsProvider .findDirectParentGroups(new PrincipalId(userInfo.getName(), domainName)); validateGroupsSubset(groups, ((directParentGroups == null) ? null : directParentGroups.getGroups()), domainName, domainAlias); PrincipalGroupLookupInfo userGroups = localOsProvider .findNestedParentGroups(new PrincipalId(userInfo.getName(), domainName)); validateGroupsSubset(groups, ((userGroups == null) ? null : userGroups.getGroups()), domainName, domainAlias); } }
From source file:com.vmware.identity.sts.auth.impl.BETAuthenticatorTest.java
@Test public void testAuthNotCompleted() { final RequestSecurityTokenType rst = newValidRst(); final byte[] initRawLeg = Base64.decodeBase64(rst.getBinaryExchange().getValue()); com.vmware.identity.sts.idm.Authenticator idmAuth = EasyMock .createMock(com.vmware.identity.sts.idm.Authenticator.class); final byte[] serverLeg = new byte[] { -3, 9 }; final GSSResult gssResult = new GSSResult(rst.getContext(), serverLeg); EasyMock.expect(idmAuth.authenticate(EasyMock.eq(rst.getContext()), EasyMock.aryEq(initRawLeg))) .andReturn(gssResult);//from www .ja v a2 s . c om EasyMock.replay(idmAuth); final Authenticator authenticator = new BETAuthenticator(idmAuth); final Result result = authenticator.authenticate(newReq(rst)); Assert.assertNotNull(result); Assert.assertFalse(result.completed()); Assert.assertTrue(Arrays.equals(serverLeg, result.getServerLeg())); EasyMock.verify(idmAuth); }
From source file:com.espertech.esper.multithread.StmtMgmtCallable.java
public Object call() throws Exception { try {/*from www . ja v a2s.c o m*/ for (int loop = 0; loop < numRepeats; loop++) { for (Object[] statement : statements) { boolean isEPL = (Boolean) statement[0]; String statementText = (String) statement[1]; // Create EPL or pattern statement EPStatement stmt; ThreadLogUtil.trace("stmt create,", statementText); if (isEPL) { stmt = engine.getEPAdministrator().createEPL(statementText); } else { stmt = engine.getEPAdministrator().createPattern(statementText); } ThreadLogUtil.trace("stmt done,", stmt); // Add listener SupportMTUpdateListener listener = new SupportMTUpdateListener(); LogUpdateListener logListener; if (isEPL) { logListener = new LogUpdateListener(null); } else { logListener = new LogUpdateListener("a"); } ThreadLogUtil.trace("adding listeners ", listener, logListener); stmt.addListener(listener); stmt.addListener(logListener); Object theEvent = makeEvent(); ThreadLogUtil.trace("sending event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Should have received one or more events, one of them must be mine EventBean[] newEvents = listener.getNewDataListFlattened(); Assert.assertTrue("No event received", newEvents.length >= 1); ThreadLogUtil.trace("assert received, size is", newEvents.length); boolean found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertTrue(found); listener.reset(); // Stopping statement, the event should not be received, another event may however ThreadLogUtil.trace("stop statement"); stmt.stop(); theEvent = makeEvent(); ThreadLogUtil.trace("send non-matching event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Make sure the event was not received newEvents = listener.getNewDataListFlattened(); found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertFalse(found); } } } catch (AssertionFailedError ex) { log.fatal("Assertion error in thread " + Thread.currentThread().getId(), ex); return false; } catch (Exception ex) { log.fatal("Error in thread " + Thread.currentThread().getId(), ex); return false; } return true; }
From source file:com.netflix.curator.TestSessionFailRetryLoop.java
@Test public void testRetryStatic() throws Exception { Timing timing = new Timing(); final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), timing.session(), timing.connection(), null, new RetryOneTime(1)); SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY); retryLoop.start();//from ww w . java 2 s . c om try { client.start(); final AtomicBoolean secondWasDone = new AtomicBoolean(false); final AtomicBoolean firstTime = new AtomicBoolean(true); SessionFailRetryLoop.callWithRetry(client, SessionFailRetryLoop.Mode.RETRY, new Callable<Object>() { @Override public Object call() throws Exception { RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { if (firstTime.compareAndSet(true, false)) { Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); KillSession.kill(client.getZooKeeper(), server.getConnectString()); client.getZooKeeper(); client.blockUntilConnectedOrTimedOut(); } Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); return null; } }); RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { Assert.assertFalse(firstTime.get()); Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); secondWasDone.set(true); return null; } }); return null; } }); Assert.assertTrue(secondWasDone.get()); } finally { retryLoop.close(); IOUtils.closeQuietly(client); } }
From source file:org.openscore.lang.runtime.steps.ExecutableStepsTest.java
@Test public void testBoundInputEvent() { List<Input> inputs = Arrays.asList(new Input("input1", "input1"), new Input("input2", "3", true, true, false, null)); RunEnvironment runEnv = new RunEnvironment(); ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices(); Map<String, Serializable> resultMap = new HashMap<>(); resultMap.put("input1", 5); resultMap.put("input2", 3); when(inputsBinding.bindInputs(eq(inputs), anyMap(), anyMap())).thenReturn(resultMap); executableSteps.startExecutable(inputs, runEnv, new HashMap<String, Serializable>(), runtimeServices, "dockerizeStep", 2L); Collection<ScoreEvent> events = runtimeServices.getEvents(); Assert.assertFalse(events.isEmpty()); ScoreEvent boundInputEvent = null;/* www. j a va 2s . c om*/ for (ScoreEvent event : events) { if (event.getEventType().equals(EVENT_INPUT_END)) { boundInputEvent = event; } } Assert.assertNotNull(boundInputEvent); Map<String, Serializable> eventData = (Map<String, Serializable>) boundInputEvent.getData(); Assert.assertTrue(eventData.containsKey(LanguageEventData.BOUND_INPUTS)); Map<String, Serializable> inputsBounded = (Map<String, Serializable>) eventData .get(LanguageEventData.BOUND_INPUTS); Assert.assertEquals(5, inputsBounded.get("input1")); Assert.assertEquals(LanguageEventData.ENCRYPTED_VALUE, inputsBounded.get("input2")); Assert.assertTrue(eventData.containsKey(LanguageEventData.levelName.EXECUTABLE_NAME.name())); Assert.assertEquals("dockerizeStep", eventData.get(LanguageEventData.levelName.EXECUTABLE_NAME.name())); }
From source file:org.openmrs.module.printer.PrinterServiceComponentTest.java
@Test public void testShouldReturnFalseIfAnotherPrinterDoesNotHaveIpAddressAssigned() { Printer differentPrinter = new Printer(); differentPrinter.setName("Another printer"); differentPrinter.setIpAddress("192.1.1.8"); differentPrinter.setType(PrinterType.LABEL); Assert.assertFalse(printerService.isIpAddressAllocatedToAnotherPrinter(differentPrinter)); }
From source file:de.akquinet.gomobile.androlog.test.PostReporterTest.java
public void testReportOnAssert() { Log.init(getContext());/* w ww .j av a 2 s . c o m*/ String message = "This is a INFO test"; String tag = "my.log.info"; Log.d(tag, message); Log.i(tag, message); Log.w(tag, message); for (int i = 0; i < 200; i++) { Log.w("" + i); } List<String> list = Log.getReportedEntries(); Assert.assertNotNull(list); Assert.assertFalse(list.isEmpty()); Assert.assertEquals(25, list.size()); Log.wtf(this, "What a terrible failure !", null); }
From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.VisitAttributeControllerTest.java
@Test public void shouldVoidAVisitAttribute() throws Exception { VisitAttribute visitAttribute = service .getVisitAttributeByUuid(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID); Assert.assertFalse(visitAttribute.isVoided()); controller.delete(Rest19ExtTestConstants.VISIT_UUID, Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID, "unit test", request, response); visitAttribute = service.getVisitAttributeByUuid(Rest19ExtTestConstants.VISIT_ATTRIBUTE_UUID); Assert.assertTrue(visitAttribute.isVoided()); Assert.assertEquals("unit test", visitAttribute.getVoidReason()); }