@Test
  public void testCopyTo() {
    graph = createGraph();
    initExampleGraph(graph);
    GraphStorage gs = newRAMGraph();
    gs.setSegmentSize(8000);
    gs.create(10);
    try {
      graph.copyTo(gs);
      checkExampleGraph(gs);
    } catch (Exception ex) {
      ex.printStackTrace();
      assertTrue(ex.toString(), false);
    }

    try {
      Helper.close((Closeable) graph);
      graph = createGraph();
      gs.copyTo(graph);
      checkExampleGraph(graph);
    } catch (Exception ex) {
      ex.printStackTrace();
      assertTrue(ex.toString(), false);
    }
    Helper.close((Closeable) graph);
  }
Esempio n. 2
0
 void report2(Exception e) {
   if (e instanceof WrappedTargetException) {
     System.out.println("Cause:");
     Exception cause = (Exception) (((WrappedTargetException) e).TargetException);
     System.out.println(cause.toString());
     report2(cause);
   } else if (e instanceof WrappedTargetRuntimeException) {
     System.out.println("Cause:");
     Exception cause = (Exception) (((WrappedTargetRuntimeException) e).TargetException);
     System.out.println(cause.toString());
     report2(cause);
   }
 }
Esempio n. 3
0
 void report(Exception e) {
   System.out.println("Exception occurred:");
   System.out.println(e.toString());
   e.printStackTrace(System.err);
   report2(e);
   //        failed();
 }
Esempio n. 4
0
  @Test
  public void testException() throws Exception {
    try {
      ClassLookup.find().orThrow(new NullPointerException()).get();
      fail(NullPointerException.class.getSimpleName() + " expected");
    } catch (NullPointerException e) {
      // expected
    }

    try {
      ClassLookup.find().orThrow(new IOException()).get();
      fail(RuntimeException.class.getSimpleName() + " expected");
    } catch (RuntimeException e) {
      assertSame(IOException.class, e.getCause().getClass());
    }

    String msg = "I knew it!";
    try {
      ClassLookup.find().orThrow(msg).get();
      fail(RuntimeException.class.getSimpleName() + " expected");
    } catch (RuntimeException e) {
      assertEquals(true, e.toString().endsWith(ExceptionUtils.getMessage(e)));
    }

    try {
      ClassLookup.find().orThrow(msg).list();
      fail(RuntimeException.class.getSimpleName() + " expected");
    } catch (Exception e) {
      assertEquals(true, e.toString().endsWith(ExceptionUtils.getMessage(e)));
    }
  }
Esempio n. 5
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   for (int i = 0; i < 10; i++) {
     try {
       JSONArray jsa = (JSONArray) pubnub.publish(channel, message + i);
     } catch (Exception e) {
       fail("Exception " + e.toString());
     }
   }
   Thread.sleep(5000);
 }
Esempio n. 6
0
 @Test
 public void test_parse_formatter_output() {
   try {
     FileInputStream in = new FileInputStream(new File(TEST_GPX_INPUT));
     List<GpsTrack> tracks = new GpxParser().parse(in);
     assertEquals(tracks.size(), 1);
     GpsTrack track = tracks.get(0);
     assertEquals(1758, track.size());
   } catch (Exception e) {
     fail(e.toString());
   }
 }
Esempio n. 7
0
 @Test
 public void historyCount5Reverse() {
   try {
     JSONArray response = (JSONArray) pubnub.history(channel, 5, true);
     JSONArray messages = (JSONArray) response.get(0);
     assertEquals(messages.length(), 5);
     assertEquals(messages.get(0), message + "0");
     assertEquals(messages.get(4), message + "4");
   } catch (Exception e) {
     fail("Exception " + e.toString());
   }
 }
Esempio n. 8
0
  @Test
  public void test_thinned_track() {
    try {
      GpxParser parser = new GpxParser();
      FileInputStream gpxIn = new FileInputStream(new File(TEST_GPX_INPUT));
      List<GpsTrack> gpxTracks = parser.parse(gpxIn);
      GpsTrack gpxTrack = gpxTracks.get(0);

      GpsTrack thinned = gpxTrack.getThinnedTrack();
    } catch (Exception e) {
      fail(e.toString());
    }
  }
Esempio n. 9
0
      @Override
      public IStructuredModel getModelForRead() {
        IModelManager mm = StructuredModelManager.getModelManager();
        if (mm != null) {
          try {
            return mm.getModelForRead(mFile);
          } catch (Exception e) {
            fail(e.toString());
          }
        }

        return null;
      }
 @Test
 public void fileDownloadTestOnMac() throws InterruptedException {
   File f = new File(c.getDownloadFullPath());
   f.mkdir();
   int before = (int) FileUtils.sizeOfDirectory(f);
   try {
     c.fileDownload(url, null);
   } catch (Exception e) {
     LOG.info(e.toString() + '\n' + e.getStackTrace()[0].toString());
   }
   int after = (int) FileUtils.sizeOfDirectory(f);
   assertTrue(after > before);
 }
 @Test
 public void testNoCreateCalled() throws IOException {
   GraphHopperStorage gs = new GraphBuilder(encodingManager).build();
   try {
     ((BaseGraph) gs.getGraph(Graph.class)).ensureNodeIndex(123);
     assertFalse("AssertionError should be raised", true);
   } catch (AssertionError err) {
     assertTrue(true);
   } catch (Exception ex) {
     assertFalse("AssertionError should be raised, but was " + ex.toString(), true);
   } finally {
     gs.close();
   }
 }
Esempio n. 12
0
 @Test
 public void testPointBuild2() {
   b = g.getMyBoard();
   try {
     /* black on 14 & 12 heading for 0; white on 4 (has long way to go)*/
     b.makePointBuild2Board();
     assertNotNull(b);
   } catch (Exception e) {
     /* isn't there a way to test without catching excetions? */
     fail(e.toString());
   }
   g.setCurrentPlayer(aiColor);
   g.myAI.setHowManyTurnsSoFar(4); // so AI uses pointBuilderStrategy
   b.myDice.roll(4, 3);
 }
  @Test
  public void testValidUser() throws Exception {

    // TestModel a valid basic user
    {
      try {
        TestModel test = new TestModel();

        test.setTest("foo");

        testService.addTest(test);

      } catch (Exception e) {
        fail(e.toString());
      }
    }
  }
Esempio n. 14
0
 /** 13s */
 @Test
 public void testLiveHtmls() throws IOException {
   FindFile ff = new WildcardFindFile().include("**/*.html");
   ff.searchPath(testLiveRoot);
   File file;
   boolean processed = false;
   while ((file = ff.nextFile()) != null) {
     processed = true;
     String name = file.getName();
     System.out.println('+' + name);
     String content = FileUtil.readString(file);
     try {
       _parseEmpty(content);
     } catch (Exception ex) {
       ex.printStackTrace();
       fail(ex.toString());
     }
   }
   assertTrue(processed);
 }
Esempio n. 15
0
  @Test
  public void test_strava_compare() {
    try {
      GpxParser parser = new GpxParser();
      FileInputStream gpxIn = new FileInputStream(new File(TEST_GPX_INPUT));
      List<GpsTrack> gpxTracks = parser.parse(gpxIn);
      GpsTrack gpxTrack = gpxTracks.get(0);

      FileInputStream stravaIn = new FileInputStream(new File(TEST_STRAVA_INPUT));
      List<GpsTrack> stravaTracks = parser.parse(stravaIn);
      GpsTrack stravaTrack = stravaTracks.get(0);

      assertEquals(
          stravaTrack.size() + " != " + gpxTrack.size(), stravaTrack.size(), gpxTrack.size());

      for (int i = 0; i < stravaTrack.size(); i++) {
        GpsLocation g = gpxTrack.get(i);
        GpsLocation s = stravaTrack.get(i);
        assertTrue(g + " != " + s, g.equals(s));
      }
    } catch (Exception e) {
      fail(e.toString());
    }
  }