List of usage examples for junit.framework Assert assertNull
static public void assertNull(Object object)
From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.feature.UpgradeVersionTests.java
/** * Method addReviewGroupToPreferences/*from w w w . j a v a 2s.c o m*/ * * @param aGroupName * - String * @param aReviewGroupUri * - URI * @param aUpgradeDialogIndexButton * int */ private void addReviewGroupToPreferences(String aGroupName, URI aReviewGroupUri, boolean aGroupResolved) { R4EUIReviewGroup reviewGroupFound = null; fTestMain.getPreferencesProxy().addGroupToPreferences(aReviewGroupUri.toFileString()); for (R4EUIReviewGroup group : R4EUIModelController.getRootElement().getGroups()) { if (group.getName().equals(aGroupName)) { reviewGroupFound = group; break; } } Assert.assertNotNull(reviewGroupFound); if (aGroupResolved) { Assert.assertNotNull(reviewGroupFound.getReviewGroup()); } else { Assert.assertNull(reviewGroupFound.getReviewGroup()); } }
From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.feature.UpgradeVersionTests.java
/** * Method addRuleSetToPreferences//w w w . j av a 2 s . c o m * * @param aRuleSetName * - String * @param aRuleSetUri * - URI * @param aUpgradeDialogIndexButton * int */ private void addRuleSetToPreferences(String aRuleSetName, URI aRuleSetUri, boolean aRuleSetResolved) { R4EUIRuleSet ruleSetFound = null; fTestMain.getPreferencesProxy().addRuleSetToPreferences(aRuleSetUri.toFileString()); for (R4EUIRuleSet ruleSet : R4EUIModelController.getRootElement().getRuleSets()) { if (ruleSet.getName().equals(aRuleSetName)) { ruleSetFound = ruleSet; break; } } Assert.assertNotNull(ruleSetFound); if (aRuleSetResolved) { Assert.assertNotNull(ruleSetFound.getRuleSet()); } else { Assert.assertNull(ruleSetFound.getRuleSet()); } }
From source file:org.eclipselabs.garbagecat.TestMain.java
public void testShortHelpOption() { try {// w ww .j a v a2 s .c o m Class<?> c = Class.forName("org.eclipselabs.garbagecat.Main"); Class<?>[] argTypes = new Class[] { String[].class }; Method parseOptions = c.getDeclaredMethod("parseOptions", argTypes); // Make private method accessible parseOptions.setAccessible(true); // Method arguments String[] args = new String[1]; args[0] = "-h"; // Pass null object since parseOptions is static parseOptions.invoke(null, (Object) args); Object o = parseOptions.invoke(null, (Object) args); CommandLine cmd = (CommandLine) o; // CommandLine will be null if only the help option is passed in. Assert.assertNull(cmd); Assert.assertTrue("'-h' is a valid option", true); } catch (ClassNotFoundException e) { Assert.fail(e.getMessage()); } catch (SecurityException e) { Assert.fail("SecurityException: " + e.getMessage()); } catch (NoSuchMethodException e) { Assert.fail("NoSuchMethodException: " + e.getMessage()); } catch (IllegalArgumentException expected) { Assert.assertNotNull(expected.getMessage()); } catch (IllegalAccessException e) { Assert.fail("IllegalAccessException: " + e.getMessage()); } catch (InvocationTargetException e) { Assert.fail("InvocationTargetException: " + e.getMessage()); } }
From source file:org.eclipselabs.garbagecat.TestMain.java
public void testLongHelpOption() { try {// w w w .jav a 2s .c o m Class<?> c = Class.forName("org.eclipselabs.garbagecat.Main"); Class<?>[] argTypes = new Class[] { String[].class }; Method parseOptions = c.getDeclaredMethod("parseOptions", argTypes); // Make private method accessible parseOptions.setAccessible(true); // Method arguments String[] args = new String[1]; args[0] = "--help"; // Pass null object since parseOptions is static parseOptions.invoke(null, (Object) args); Object o = parseOptions.invoke(null, (Object) args); CommandLine cmd = (CommandLine) o; // CommandLine will be null if only the help option is passed in. Assert.assertNull(cmd); Assert.assertTrue("'--help' is a valid option", true); } catch (ClassNotFoundException e) { Assert.fail(e.getMessage()); } catch (SecurityException e) { Assert.fail("SecurityException: " + e.getMessage()); } catch (NoSuchMethodException e) { Assert.fail("NoSuchMethodException: " + e.getMessage()); } catch (IllegalArgumentException expected) { Assert.assertNotNull(expected.getMessage()); } catch (IllegalAccessException e) { Assert.fail("IllegalAccessException: " + e.getMessage()); } catch (InvocationTargetException e) { Assert.fail("InvocationTargetException: " + e.getMessage()); } }
From source file:org.encuestame.test.business.service.TestTweetPollService.java
/** * @throws EnMeNoResultsFoundException/*from w w w. j a v a2 s .c om*/ * */ @Test public void testRemoveTweetpolls() throws EnMeNoResultsFoundException { final Question myFirstQuestion = createQuestion("What is your favorite kind of movie?", this.userAccount.getAccount()); final Question mySecondQuestion = createQuestion("What is your favorite kind of song?", this.userAccount.getAccount()); final TweetPollFolder tpFolder = createTweetPollFolder("My Tp1111 folder", this.userAccount); final HashTag tag1 = createHashTag("romantic"); final HashTag tag2 = createHashTag("suspense"); final String tagName = tag1.getHashTag(); final Long questionId = myFirstQuestion.getQid(); // FIRST TP final TweetPoll tweetPoll1 = createPublishedTweetPoll(this.userAccount, myFirstQuestion, new Date()); tweetPoll1.setTweetPollFolder(tpFolder); tweetPoll1.getHashTags().add(tag1); tweetPoll1.getHashTags().add(tag2); getTweetPoll().saveOrUpdate(tweetPoll1); // Create QuestionsAnswers final TweetPoll myTweetpoll = tweetPoll1; final QuestionAnswer questAns1 = createQuestionAnswer("yes", myFirstQuestion, "1234555"); final QuestionAnswer questAns2 = createQuestionAnswer("no", myFirstQuestion, "12346666"); final QuestionAnswer questAns3 = createQuestionAnswer("no", myFirstQuestion, "123466667"); // Tweetpoll switch final TweetPollSwitch tps1 = createTweetPollSwitch(questAns1, tweetPoll1); final TweetPollSwitch tps2 = createTweetPollSwitch(questAns2, tweetPoll1); // TweetPoll Result createTweetPollResult(tps1, "192.168.0.1"); createTweetPollResult(tps1, "192.168.0.2"); createTweetPollResult(tps2, "192.168.0.3"); // Social Accounts & Providers final SocialAccount socialAccount = createDefaultSettedSocialAccount(this.userAccount); final List<SocialProvider> providers = new ArrayList<SocialProvider>(); providers.add(SocialProvider.FACEBOOK); providers.add(SocialProvider.LINKEDIN); // Create TweetPollSavedPublished - Social Links final TweetPollSavedPublishedStatus tpSaved4 = createTweetPollSavedPublishStatus(tweetPoll1, socialAccount, SocialProvider.FACEBOOK); final TweetPollSavedPublishedStatus tpSaved5 = createTweetPollSavedPublishStatus(tweetPoll1, socialAccount, SocialProvider.TWITTER); /* ***** BEFORE ***** */ // Retrieve all TwweetpollSwitch associated final List<TweetPollSwitch> tpSwitchs = getTweetPoll().getListAnswersByTweetPollAndDateRange(tweetPoll1); for (TweetPollSwitch tweetPollSwitch : tpSwitchs) { final List<TweetPollResult> tpollsResult = getTweetPoll() .getTweetPollResultsByTweetPollSwitch(tweetPollSwitch); } final List<TweetPollSavedPublishedStatus> TpollSaved = getTweetPoll().getLinksByTweetPoll(tweetPoll1, null, null, TypeSearchResult.TWEETPOLL); /* Retrieve Tweetpolls folders by Folder ID */ Assert.assertEquals(tweetPoll1.getHashTags().size(), 2); /* Retrieve Question Answers * */ Assert.assertEquals(tweetPoll1.getHashTags().size(), 2); // Check total Answers final List<QuestionAnswer> totalAnswers = getQuestionDaoImp() .getAnswersByQuestionId(tweetPoll1.getQuestion().getQid()); Assert.assertEquals(totalAnswers.size(), 3); // Check if exist TweetPoll Assert.assertNotNull(getTweetPoll().getTweetPollById(myTweetpoll.getTweetPollId())); Assert.assertNotNull(getQuestionDaoImp().retrieveQuestionById(myTweetpoll.getQuestion().getQid())); /* * **************************** REMOVE * ************************************ */ this.getTweetPollService().removeTweetPoll(tweetPoll1); List<TweetPollSwitch> tpSwitchsAfter = getTweetPoll().getListAnswersByTweetPollAndDateRange(myTweetpoll); Assert.assertEquals(tpSwitchsAfter.size(), 0); // Check Tweetpollresult for (TweetPollSwitch tweetPollSwitch : tpSwitchsAfter) { final List<TweetPollResult> tpollsResult = getTweetPoll() .getTweetPollResultsByTweetPollSwitch(tweetPollSwitch); } // Check TweetpollSaved final List<TweetPollSavedPublishedStatus> TpollSavedAfter = getTweetPoll().getLinksByTweetPoll(myTweetpoll, null, null, TypeSearchResult.TWEETPOLL); Assert.assertEquals(TpollSavedAfter.size(), 0); // Check Hashtag final List<TweetPoll> tpollsbyHashtag = getTweetPoll().getTweetpollByHashTagName(tagName, 0, 10, TypeSearchResult.HASHTAG, SearchPeriods.ALLTIME); Assert.assertEquals(tpollsbyHashtag.size(), 0); // Check QuestionAnswer final List<QuestionAnswer> totalAnswersAfter = getQuestionDaoImp() .getAnswersByQuestionId(tweetPoll1.getQuestion().getQid()); Assert.assertEquals(totalAnswersAfter.size(), 0); // Check TweetPoll final TweetPoll tpollAfter = getTweetPoll().getTweetPollById(myTweetpoll.getTweetPollId()); Assert.assertNull(tpollAfter); // Check Question final Question questionAfter = getQuestionDaoImp().retrieveQuestionById(myTweetpoll.getQuestion().getQid()); Assert.assertNull(questionAfter); }
From source file:org.geomajas.gwt2.plugin.wms.client.service.WmsServiceTest.java
@Test public void testWmsUrlTransformer1() { Assert.assertNull(wmsService.getWmsUrlTransformer()); wmsService.setWmsUrlTransformer(toHelloWorld); Assert.assertEquals(toHelloWorld, wmsService.getWmsUrlTransformer()); }
From source file:org.geomajas.gwt2.plugin.wms.client.service.WmsServiceTest.java
@Test public void testWmsUrlTransformer4GetMap() { Assert.assertNull(wmsService.getWmsUrlTransformer()); String getLegendUrl = wmsService.getLegendGraphicUrl(wmsConfig); Assert.assertEquals(VALUE_URL, getLegendUrl.substring(0, getLegendUrl.indexOf('?'))); Assert.assertTrue(hasParameter(getLegendUrl, "service", "WMS")); wmsService.setWmsUrlTransformer(toHelloWorld); Bbox bounds = new Bbox(0, 1, 100, 100); String getMapUrl = wmsService.getMapUrl(wmsConfig, bounds, VALUE_SIZE, VALUE_SIZE); Assert.assertEquals(HELLOWORLD, getMapUrl); }
From source file:org.jasypt.properties.EncryptablePropertiesTest.java
public void testEncryptableProperties() throws Exception { final BasicTextEncryptor encryptor = new BasicTextEncryptor(); encryptor.setPassword("jasypt"); final Properties props = new EncryptableProperties(encryptor); props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("props.properties")); final String value = "Spain"; final String locationPlain1 = props.getProperty("location.plain"); final String locationPlain2 = props.getProperty("location.plain", "defaultPlain"); final String locationPlain3 = (String) props.get("location.plain"); final String locationEnc1 = props.getProperty("location.enc"); final String locationEnc2 = props.getProperty("location.enc", "defaultEnc"); final String locationEnc3 = (String) props.get("location.enc"); final String nonExisting1 = props.getProperty("non.existing"); final String nonExisting2 = props.getProperty("non.existing", "defaultNon"); final String nonExisting3 = (String) props.get("non.existing"); Assert.assertEquals(value, locationPlain1); Assert.assertEquals(value, locationPlain2); Assert.assertEquals(value, locationPlain3); Assert.assertEquals(value, locationEnc1); Assert.assertEquals(value, locationEnc2); Assert.assertEquals(value, locationEnc3); Assert.assertNull(nonExisting1); Assert.assertEquals("defaultNon", nonExisting2); Assert.assertNull(nonExisting3);//from w ww . jav a2 s. c om }
From source file:org.jboss.arquillian.extension.jrebel.DeploymentInterceptorTest.java
@Test public void testExplodedEnterpriseArchive() throws IOException { final Archive<?> archive = Packager.createEnterpriseArchive(); final DeploymentInterceptor deploymentInterceptor = createDeploymentInterceptorMock(); final File tempDirectory = deploymentInterceptor.getTempDirectory(); FileUtils.deleteDirectory(tempDirectory); ShrinkWrapUtil.createTempDirectory(tempDirectory); final String jrebelExtRoot = tempDirectory.getPath(); final String deploymentRoot = jrebelExtRoot + "/" + DeploymentInterceptorTest.class.getCanonicalName() + "/mock/test.ear"; final File jrebelExtRootDir = new File(jrebelExtRoot); Assert.assertTrue(jrebelExtRootDir.exists()); final File deploymentRootDir = new File(deploymentRoot); Assert.assertFalse(deploymentRootDir.exists()); deploymentInterceptor.onDeploy(createDeployEventContextMock(archive), new TestClass(DeploymentInterceptorTest.class)); Assert.assertTrue(deploymentRootDir.exists()); final EnterpriseArchive explodedArchive = ShrinkWrap.create(WebArchive.class).as(ExplodedImporter.class) .importDirectory(deploymentRootDir).as(EnterpriseArchive.class); Assert.assertEquals(25, explodedArchive.getContent().size()); Assert.assertNotNull(explodedArchive.get("/test.war/WEB-INF/beans.xml")); Assert.assertNotNull(explodedArchive.get("/test.war/WEB-INF/classes/rebel.xml")); Assert.assertNotNull(explodedArchive.get("/test.war/WEB-INF/classes/org")); Assert.assertNotNull(explodedArchive.get("/test.war/otherDir/sampleWebResource.html")); Assert.assertNull(explodedArchive.get("/test.war/WEB-INF/classes/org/arquillian")); }
From source file:org.jboss.arquillian.extension.jrebel.DeploymentInterceptorTest.java
@Test public void testExplodedWebArchive() throws IOException { final Archive<?> archive = Packager.createWebArchive(); final DeploymentInterceptor deploymentInterceptor = createDeploymentInterceptorMock(); final File tempDirectory = deploymentInterceptor.getTempDirectory(); FileUtils.deleteDirectory(tempDirectory); ShrinkWrapUtil.createTempDirectory(tempDirectory); final String jrebelExtRoot = tempDirectory.getPath(); final String deploymentRoot = jrebelExtRoot + "/" + DeploymentInterceptorTest.class.getCanonicalName() + "/mock/test.war"; final File jrebelExtRootDir = new File(jrebelExtRoot); Assert.assertTrue(jrebelExtRootDir.exists()); final File deploymentRootDir = new File(deploymentRoot); Assert.assertFalse(deploymentRootDir.exists()); deploymentInterceptor.onDeploy(createDeployEventContextMock(archive), new TestClass(DeploymentInterceptorTest.class)); Assert.assertTrue(deploymentRootDir.exists()); final WebArchive explodedArchive = ShrinkWrap.create(WebArchive.class).as(ExplodedImporter.class) .importDirectory(deploymentRootDir).as(WebArchive.class); Assert.assertEquals(24, explodedArchive.getContent().size()); Assert.assertNotNull(explodedArchive.get("/WEB-INF/beans.xml")); Assert.assertNotNull(explodedArchive.get("/WEB-INF/classes/rebel.xml")); Assert.assertNotNull(explodedArchive.get("/WEB-INF/classes/org")); Assert.assertNotNull(explodedArchive.get("/otherDir/sampleWebResource.html")); Assert.assertNull(explodedArchive.get("/WEB-INF/classes/org/arquillian")); }