Esempio n. 1
0
 // =========================================================================
 // Internal methods
 // =========================================================================
 private static void sanityCheckDefaultText(final LoremIpsum loremIpsum_) {
   // Sanity check using hard-coded knowledge of default resource...
   Assert.assertEquals("Lorem", loremIpsum_.getWord(0));
   Assert.assertEquals("Ipsum", loremIpsum_.getWord(1));
   Assert.assertEquals("laborum.", loremIpsum_.getWord(loremIpsum_.getNumWords() - 1));
   Assert.assertEquals(6, loremIpsum_.getNumParagraphs());
 }
Esempio n. 2
0
 @Test
 public void testLoremCtorString_Null() throws IOException {
   loremIpsum = new LoremIpsum(null);
   Assert.assertNull(loremIpsum.getText());
   Assert.assertEquals(0, loremIpsum.getNumParagraphs());
   Assert.assertEquals(0, loremIpsum.getNumSentences());
   Assert.assertEquals(0, loremIpsum.getNumWords());
 }
Esempio n. 3
0
 /**
  * Test method for {@link com.dell.mensa.util.LoremIpsum#LoremIpsum(java.lang.String)}.
  *
  * @throws IOException if thrown by code under test
  */
 @Test
 public void testLoremCtorString() throws IOException {
   final String text = "hi";
   loremIpsum = new LoremIpsum(text);
   Assert.assertEquals(text, loremIpsum.getText());
   Assert.assertEquals(1, loremIpsum.getNumParagraphs());
   Assert.assertEquals(1, loremIpsum.getNumSentences());
   Assert.assertEquals(1, loremIpsum.getNumWords());
 }
Esempio n. 4
0
 @Test(expected = IllegalArgumentException.class)
 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
     value = "NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS",
     justification = "Testing null argument")
 public void testSetText_Null() throws IOException {
   loremIpsum.setText(null);
 }
Esempio n. 5
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getWord(int)}. */
 @Test
 public void testGetWord() {
   for (int i = 0; i < EXPECTED_WORDS.length; ++i) {
     Assert.assertEquals(
         String.format("unexpected word[%d]; ", i), EXPECTED_WORDS[i], loremIpsum.getWord(i));
   }
 }
Esempio n. 6
0
 @SuppressWarnings("static-method")
 @Test(expected = IllegalArgumentException.class)
 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
     value = "NP_NULL_PARAM_DEREF_NONVIRTUAL",
     justification = "Testing null argument")
 public void testNormalize_IllegalArgument() throws IOException {
   LoremIpsum.normalize(null);
 }
Esempio n. 7
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getSentence(int)}. */
 @Test
 public void testGetSentence() {
   for (int i = 0; i < EXPECTED_SENTENCES.length; ++i) {
     Assert.assertEquals(
         String.format("unexpected sentence[%d]; ", i),
         EXPECTED_SENTENCES[i],
         loremIpsum.getSentence(i));
   }
 }
Esempio n. 8
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getParagraph(int)}. */
 @Test
 public void testGetParagraph() {
   for (int i = 0; i < EXPECTED_PARAGRAPHS.length; ++i) {
     Assert.assertEquals(
         String.format("unexpected paragraph[%d]; ", i),
         EXPECTED_PARAGRAPHS[i],
         loremIpsum.getParagraph(i));
   }
 }
Esempio n. 9
0
 /**
  * Test method for {@link com.dell.mensa.util.LoremIpsum#normalize(java.lang.String)}.
  *
  * @throws IOException if thrown by code under test
  */
 @SuppressWarnings("static-method")
 @Test
 public void testNormalize() throws IOException {
   Assert.assertEquals(NORMALIZED_TEXT, LoremIpsum.normalize(RAW_TEXT));
   Assert.assertEquals(NORMALIZED_TEXT, LoremIpsum.normalize(NORMALIZED_TEXT));
 }
Esempio n. 10
0
 @Test(expected = FileNotFoundException.class)
 public void testLoadTextResourceString_BadResource() throws IOException {
   loremIpsum.loadTextResource("bad-resource");
 }
Esempio n. 11
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getText()}. */
 @Test
 public void testGetText() {
   Assert.assertEquals(NORMALIZED_TEXT, loremIpsum.getText());
 }
Esempio n. 12
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getNumParagraphs()}. */
 @Test
 public void testGetNumParagraphs() {
   Assert.assertEquals(EXPECTED_PARAGRAPHS.length, loremIpsum.getNumParagraphs());
 }
Esempio n. 13
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetWord_Overflow() {
   loremIpsum.getWord(loremIpsum.getNumWords());
 }
Esempio n. 14
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetWord_Underflow() {
   loremIpsum.getWord(-1);
 }
Esempio n. 15
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetSentence_Overflow() {
   loremIpsum.getSentence(loremIpsum.getNumSentences());
 }
Esempio n. 16
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testGetParagraph_Overflow() {
   loremIpsum.getParagraph(loremIpsum.getNumParagraphs());
 }
Esempio n. 17
0
 /**
  * Test method for {@link com.dell.mensa.util.LoremIpsum#loadTextResource()}.
  *
  * @throws IOException if thrown by code under test
  */
 @Test
 public void testLoadTextResource() throws IOException {
   loremIpsum.loadTextResource();
   sanityCheckDefaultText(loremIpsum);
 }
Esempio n. 18
0
 /**
  * Test method for {@link com.dell.mensa.util.LoremIpsum#loadTextResource(java.lang.String)}.
  *
  * @throws IOException if thrown by code under test
  */
 @Test
 public void testLoadTextResourceString() throws IOException {
   loremIpsum.loadTextResource(LoremIpsum.LOREM_IPSUM_RESOURCE);
   sanityCheckDefaultText(loremIpsum);
 }
Esempio n. 19
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getNumSentences()}. */
 @Test
 public void testGetNumSentences() {
   Assert.assertEquals(EXPECTED_SENTENCES.length, loremIpsum.getNumSentences());
 }
Esempio n. 20
0
 /** Test method for {@link com.dell.mensa.util.LoremIpsum#getNumWords()}. */
 @Test
 public void testGetNumWords() {
   Assert.assertEquals(EXPECTED_WORDS.length, loremIpsum.getNumWords());
 }