org.junit.experimental.categories.Category Java Examples

The following examples show how to use org.junit.experimental.categories.Category. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TutorialListTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testCorrectOrderSkipIndexes() {
  TutorialList list = new TutorialList();
  HelpLine line = new HelpLine(0);
  list.add(line);
  line = new HelpLine(2);
  list.add(line);
  line = new HelpLine(4);
  list.add(line);
  line = new HelpLine(6);
  list.add(line);
  line = new HelpLine(8);
  list.add(line);
  assertEquals("0:  - \n" + 
      "2:  - \n" + 
      "4:  - \n" + 
      "6:  - \n" + 
      "8:  - \n", list.toString());
}
 
Example #2
Source File: MapAlgebraIntegrationTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void isNull() throws Exception
{
//    java.util.Properties prop = MrGeoProperties.getInstance();
//    prop.setProperty(HadoopUtils.IMAGE_BASE, testUtils.getInputHdfs().toUri().toString());
  if (GEN_BASELINE_DATA_ONLY)
  {
    testUtils.generateBaselineTif(this.conf, testname.getMethodName(),
        String.format("isNull([%s])", allones), -9999);
  }
  else
  {
    testUtils.runRasterExpression(this.conf, testname.getMethodName(),
        TestUtils.nanTranslatorToMinus9999, TestUtils.nanTranslatorToMinus9999,
        String.format("isNull([%s])", allones));
  }
}
 
Example #3
Source File: BoxTrashTest.java    From box-java-sdk with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void restoreTrashedFileWithNewNameSucceeds() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxTrash trash = new BoxTrash(api);
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String fileName = "[restoreTrashedFileWithNewNameSucceeds] Trashed File.txt";
    String restoredFileName = "[restoreTrashedFileWithNewNameSucceeds] Restored File.txt";
    String fileContent = "Trashed file";
    byte[] fileBytes = fileContent.getBytes(StandardCharsets.UTF_8);

    InputStream uploadStream = new ByteArrayInputStream(fileBytes);
    BoxFile uploadedFile = rootFolder.uploadFile(uploadStream, fileName).getResource();
    uploadedFile.delete();
    BoxFile.Info restoredFileInfo = trash.restoreFile(uploadedFile.getID(), restoredFileName, null);

    assertThat(restoredFileInfo.getName(), is(equalTo(restoredFileName)));
    assertThat(trash, not(hasItem(Matchers.<BoxItem.Info>hasProperty("ID", equalTo(uploadedFile.getID())))));
    assertThat(rootFolder, hasItem(Matchers.<BoxItem.Info>hasProperty("ID", equalTo(uploadedFile.getID()))));

    uploadedFile.delete();
}
 
Example #4
Source File: AlarmsControllerTest.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
@Test(timeout = 5000)
@Category({UnitTest.class})
public void itUpdateAlarm() throws Exception {
    AlarmServiceModel alarmResult = new AlarmServiceModel();

    IAlarms alarms = mock(IAlarms.class);
    AlarmsController controller = new AlarmsController(alarms);
    when(alarms.update(
        "1",
        "open"))
        .thenReturn(alarmResult);

    setMockContext();

    // Act
    Result response = controller.patch("1");

    // Assert
    assertThat(response.body().isKnownEmpty(), is(false));
}
 
Example #5
Source File: BoxGroupTest.java    From box-java-sdk with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void getCollaborationsSucceedsAndHandlesResponseCorrectly() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    String groupName = "[getCollaborationsSucceedsAndHandlesResponseCorrectly] Test Group";

    BoxGroup group = BoxGroup.createGroup(api, groupName).getResource();
    BoxCollaborator collabGroup = new BoxGroup(api, group.getID());

    String folderName = "[getCollaborationsSucceedsAndHandlesResponseCorrectly] Test Folder";

    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    BoxFolder folder = rootFolder.createFolder(folderName).getResource();

    BoxCollaboration.Info collabInfo = folder.collaborate(collabGroup, BoxCollaboration.Role.EDITOR);

    Collection<BoxCollaboration.Info> collaborations = group.getCollaborations();

    assertThat(collaborations, hasSize(1));
    assertThat(collaborations, hasItem(
            Matchers.<BoxCollaboration.Info>hasProperty("ID", equalTo(collabInfo.getID())))
    );

    group.delete();
    folder.delete(false);
}
 
Example #6
Source File: FleetTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testFleetWithTradeShip2() {
  Ship ship = createTradeShip();
  Fleet fleet = new Fleet(ship, 2, 3);
  assertEquals(2, fleet.getCoordinate().getX());
  assertEquals(3, fleet.getCoordinate().getY());
  fleet.setName("Trader #1");
  assertEquals("Trader #1",fleet.getName());
  Coordinate tradeCoordinate = new Coordinate(15,16);
  Mockito.when(ship.calculateTradeCredits((Coordinate) Mockito.any(),
      (Coordinate) Mockito.any())).thenReturn(4);
  assertEquals(4, fleet.calculateTrade(tradeCoordinate));
  fleet.addShip(ship);
  assertEquals(8, fleet.calculateTrade(tradeCoordinate));
}
 
Example #7
Source File: DiplomaticTradeTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testGetBestFleet2() {
  StarMap map = generateMapWithPlayer(SpaceRace.SPORKS);
  PlayerInfo info = Mockito.mock(PlayerInfo.class);
  ArrayList<Fleet> fleets = new ArrayList<>();
  Fleet fleet1 = Mockito.mock(Fleet.class);
  Mockito.when(fleet1.getMilitaryValue()).thenReturn(10);
  Mockito.when(fleet1.calculateFleetObsoleteValue(info)).thenReturn(1);
  fleets.add(fleet1);
  Fleet fleet2 = Mockito.mock(Fleet.class);
  Mockito.when(fleet2.getMilitaryValue()).thenReturn(8);
  Mockito.when(fleet2.calculateFleetObsoleteValue(info)).thenReturn(1);
  fleets.add(fleet2);
  Fleet fleet3 = Mockito.mock(Fleet.class);
  Mockito.when(fleet3.getMilitaryValue()).thenReturn(15);
  Mockito.when(fleet3.calculateFleetObsoleteValue(info)).thenReturn(1);
  fleets.add(fleet3);
  DiplomaticTrade trade = new DiplomaticTrade(map, 0, 1);
  assertEquals(fleet2, trade.getTradeableFleet(info, fleets));
}
 
Example #8
Source File: BeamEnumerableConverterTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
@Category(NeedsRunner.class)
public void testToEnumerable_collectNullValue() {
  Schema schema = Schema.builder().addNullableField("id", fieldType).build();
  RelDataType type = CalciteUtils.toCalciteRowType(schema, TYPE_FACTORY);
  ImmutableList<ImmutableList<RexLiteral>> tuples =
      ImmutableList.of(
          ImmutableList.of(
              rexBuilder.makeNullLiteral(CalciteUtils.toRelDataType(TYPE_FACTORY, fieldType))));
  BeamRelNode node = new BeamValuesRel(cluster, type, tuples, null);

  Enumerable<Object> enumerable = BeamEnumerableConverter.toEnumerable(options, node);
  Enumerator<Object> enumerator = enumerable.enumerator();

  assertTrue(enumerator.moveNext());
  Object row = enumerator.current();
  assertEquals(null, row);
  assertFalse(enumerator.moveNext());
  enumerator.close();
}
 
Example #9
Source File: MessagesControllerTest.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
@Test(timeout = 5000)
@Category({UnitTest.class})
public void itGetsAllMessages() throws
    InvalidInputException,
    InvalidConfigurationException,
    TimeSeriesParseException {

    // Arrange
    IMessages messages = mock(IMessages.class);
    MessagesController controller = new MessagesController(mock(IMessages.class));
    ArrayList<MessageServiceModel> msgs = new ArrayList<MessageServiceModel>() {{
        add(new MessageServiceModel());
        add(new MessageServiceModel());
    }};
    MessageListServiceModel res = new MessageListServiceModel(msgs, null);
    when(messages.getList(
        DateTime.now(), DateTime.now(), "asc", 0, 100, new String[0]))
        .thenReturn(res);

    // Act
    Result response = controller.list(null, null, null, null, null, null);

    // Assert
    assertThat(response.body().isKnownEmpty(), is(false));
}
 
Example #10
Source File: FleetVisibilityTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testPrivateer() {
  Espionage espionage = Mockito.mock(Espionage.class);
  PlayerInfo info = Mockito.mock(PlayerInfo.class);
  Mockito.when(info.getEspionage()).thenReturn(espionage);
  Coordinate coord = Mockito.mock(Coordinate.class);
  Mockito.when(coord.getX()).thenReturn(10);
  Mockito.when(coord.getY()).thenReturn(12);
  Mockito.when(info.getSectorVisibility(coord)).thenReturn(PlayerInfo.VISIBLE);
  Fleet fleet = Mockito.mock(Fleet.class);
  Mockito.when(fleet.getCoordinate()).thenReturn(coord);
  Mockito.when(fleet.isPrivateerFleet()).thenReturn(true);
  int fleetOwnerIndex = 1;
  FleetVisibility visiblity = new FleetVisibility(info, fleet, fleetOwnerIndex);
  assertEquals(true, visiblity.isFleetVisible());
  assertEquals(false, visiblity.isEspionageDetected());
  assertEquals(false, visiblity.isRecognized());
}
 
Example #11
Source File: TileMapServiceResourceIntegrationTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetTileMapMercator() throws Exception
{
  String version = "1.0.0";

  when(request.getRequestURL())
      .thenReturn(new StringBuffer("http://localhost:9998/tms/1.0.0/" +
          rgbsmall_nopyramids_abs + "/global-mercator"));
  when(service.getMetadata(rgbsmall_nopyramids_abs))
      .thenReturn(getMetadata(rgbsmall_nopyramids_abs));

  Response response = target("tms" + "/" + version + "/" +
      URLEncoder.encode(rgbsmall_nopyramids_abs, "UTF-8") + "/global-mercator")
      .request().get();

  Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());

  verify(request, times(1)).getRequestURL();
  verify(service, times(1)).getMetadata(rgbsmall_nopyramids_abs);
  verify(service, times(0));
  service.listImages();
  verifyNoMoreInteractions(request, service);
}
 
Example #12
Source File: WindowTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
@Category({ValidatesRunner.class, UsesCustomWindowMerging.class})
public void testMergingCustomWindowsKeyedCollection() {
  Instant startInstant = new Instant(0L);
  PCollection<KV<Integer, String>> inputCollection =
      pipeline.apply(
          Create.timestamped(
              TimestampedValue.of(
                  KV.of(0, "big"), startInstant.plus(Duration.standardSeconds(10))),
              TimestampedValue.of(
                  KV.of(1, "small1"), startInstant.plus(Duration.standardSeconds(20))),
              // This element is not contained within the bigWindow and not merged
              TimestampedValue.of(
                  KV.of(2, "small2"), startInstant.plus(Duration.standardSeconds(39)))));
  PCollection<KV<Integer, String>> windowedCollection =
      inputCollection.apply(Window.into(new CustomWindowFn<>()));
  PCollection<Long> count =
      windowedCollection.apply(
          Combine.globally(Count.<KV<Integer, String>>combineFn()).withoutDefaults());
  // "small1" and "big" elements merged into bigWindow "small2" not merged
  // because it is not contained in bigWindow
  PAssert.that("Wrong number of elements in output collection", count).containsInAnyOrder(2L, 1L);
  pipeline.run();
}
 
Example #13
Source File: SPARQLQueryBuilderTest.java    From inception with Apache License 2.0 6 votes vote down vote up
@Category(SlowTests.class)
@Ignore("#1522 - GND tests not running")
@Test
public void testWithLabelContainingAnyOf_Fuseki_FTS() throws Exception
{
    assertIsReachable(zbwGnd);
    
    kb.setType(REMOTE);
    kb.setFullTextSearchIri(FTS_FUSEKI);
    kb.setLabelIri(RDFS.LABEL);
    kb.setSubPropertyIri(RDFS.SUBPROPERTYOF);
    
    List<KBHandle> results = asHandles(zbwGnd, SPARQLQueryBuilder
            .forItems(kb)
            .withLabelContainingAnyOf("Schapiro-Frisch", "Stiker-Métral"));
    
    assertThat(results).extracting(KBHandle::getIdentifier).doesNotHaveDuplicates();
    assertThat(results).isNotEmpty();
    assertThat(results).extracting(KBHandle::getUiLabel)
            .allMatch(label -> label.contains("Schapiro-Frisch") || 
                    label.contains("Stiker-Métral"));
}
 
Example #14
Source File: StarMapUtilitiesTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 6 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testVotingSupportRulerOfGalaxySelf() {
  PlayerInfo info = Mockito.mock(PlayerInfo.class);
  Mockito.when(info.getAttitude()).thenReturn(Attitude.AGGRESSIVE);
  Mockito.when(info.getRace()).thenReturn(SpaceRace.HUMAN);
  Diplomacy diplomacy = Mockito.mock(Diplomacy.class);
  Mockito.when(info.getDiplomacy()).thenReturn(diplomacy);
  Mockito.when(diplomacy.getLiking(0)).thenReturn(Diplomacy.FRIENDS);
  Mockito.when(diplomacy.getLiking(5)).thenReturn(Diplomacy.HATE);
  Vote vote = new Vote(VotingType.RULER_OF_GALAXY, 6, 20);
  vote.setOrganizerIndex(1);
  vote.setSecondCandidateIndex(5);
  StarMap map = Mockito.mock(StarMap.class);
  PlayerList playerList = Mockito.mock(PlayerList.class);
  Mockito.when(map.getPlayerList()).thenReturn(playerList);
  Mockito.when(playerList.getIndex(info)).thenReturn(1);
  Mockito.when(playerList.getCurrentMaxRealms()).thenReturn(6);
  assertEquals(90, StarMapUtilities.getVotingSupport(info, vote, map));

  vote.setOrganizerIndex(0);
  vote.setSecondCandidateIndex(1);
  assertEquals(-70, StarMapUtilities.getVotingSupport(info, vote, map));
}
 
Example #15
Source File: MapAlgebraIntegrationTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void expressionIncompletePathInput1() throws Exception
{
  // test expressions with file names mixed in with fullpaths
  if (GEN_BASELINE_DATA_ONLY)
  {
    testUtils.generateBaselineTif(this.conf, testname.getMethodName(),
        String.format("a = [%s]; b = 3; a / [%s] + b", allones, allonesPath), -9999);
  }
  else
  {
    testUtils.runRasterExpression(this.conf, testname.getMethodName(),
        TestUtils.nanTranslatorToMinus9999, TestUtils.nanTranslatorToMinus9999,
        String.format("a = [%s]; b = 3; a / [%s] + b", allones, allonesPath));
  }
}
 
Example #16
Source File: BoxFileTest.java    From box-java-sdk with Apache License 2.0 6 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testAddClassification() throws IOException {
    String result = "";
    final String fileID = "12345";
    final String classificationType = "Public";
    final String metadataURL = "/files/" + fileID + "/metadata/enterprise/securityClassification-6VMVochwUWo";
    JsonObject metadataObject = new JsonObject()
            .add("Box__Security__Classification__Key", classificationType);

    result = TestConfig.getFixture("BoxFile/CreateClassificationOnFile201");

    WIRE_MOCK_CLASS_RULE.stubFor(WireMock.post(WireMock.urlPathEqualTo(metadataURL))
            .withRequestBody(WireMock.equalToJson(metadataObject.toString()))
            .willReturn(WireMock.aResponse()
                    .withHeader("Content-Type", "application/json")
                    .withBody(result)));

    BoxFile file = new BoxFile(this.api, fileID);
    String classification = file.addClassification(classificationType);

    Assert.assertEquals(classificationType, classification);
}
 
Example #17
Source File: MissingPyramidsTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void testGetMapTifNonExistingZoomLevelAboveWithoutPyramidsExtraMetadata() throws Exception
{
  String contentType = "image/tiff";
  Response response = target("wms")
      .queryParam("SERVICE", "WMS")
      .queryParam("REQUEST", "getmap")
      .queryParam("LAYERS", "IslandsElevation-v2-no-pyramid-extra-metadata")
      .queryParam("FORMAT", contentType)
      //pyramid only has a single zoom level = 10; pass in zoom level = 8
      .queryParam("BBOX", ISLANDS_ELEVATION_V2_IN_BOUNDS_SINGLE_SOURCE_TILE)
      .queryParam("WIDTH", MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT)
      .queryParam("HEIGHT", MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT)
      .request().get();

  processImageResponse(response, contentType, "tif");
}
 
Example #18
Source File: BoxFileTest.java    From box-java-sdk with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void renameFileSucceeds() {
    BoxAPIConnection api = new BoxAPIConnection(TestConfig.getAccessToken());
    BoxFolder rootFolder = BoxFolder.getRootFolder(api);
    String originalFileName = "[renameFileSucceeds] Original Name.txt";
    String newFileName = "[renameFileSucceeds] New Name.txt";
    String fileContent = "Test file";
    byte[] fileBytes = fileContent.getBytes(StandardCharsets.UTF_8);

    InputStream uploadStream = new ByteArrayInputStream(fileBytes);
    BoxFile.Info uploadedFileInfo = rootFolder.uploadFile(uploadStream, originalFileName);
    BoxFile uploadedFile = uploadedFileInfo.getResource();

    uploadedFile.rename(newFileName);
    BoxFile.Info newInfo = uploadedFile.getInfo();

    assertThat(newInfo.getName(), is(equalTo(newFileName)));

    uploadedFile.delete();
}
 
Example #19
Source File: GetMapTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void testGetMapLowerCaseParams() throws Exception
{
  String contentType = "image/png";
  Response response = target("wms")
      .queryParam("SERVICE", "WMS")
      .queryParam("request", "getmap")
      .queryParam("layers", "IslandsElevation-v2")
      .queryParam("format", contentType)
      .queryParam("bbox", ISLANDS_ELEVATION_V2_IN_BOUNDS_SINGLE_SOURCE_TILE)
      .queryParam("width", MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT)
      .queryParam("height", MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT)
      .request().get();

  processImageResponse(response, contentType, "png");
  response.close();
}
 
Example #20
Source File: GetMosaicTest.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
@Test
@Category(IntegrationTest.class)
public void testGetMosaicTifMultipleSourceTiles() throws Exception
{
  String contentType = "image/tiff";

  Response response = target("wms")
      .queryParam("SERVICE", "WMS")
      .queryParam("REQUEST", "getmosaic")
      .queryParam("LAYERS", "IslandsElevation-v2")
      .queryParam("FORMAT", contentType)
      .queryParam("BBOX", ISLANDS_ELEVATION_V2_IN_BOUNDS_MULTIPLE_SOURCE_TILES)
      .request().get();

  processImageResponse(response, contentType, "tif");
}
 
Example #21
Source File: ToStringTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test
@Category(NeedsRunner.class)
public void testToStringKVWithDelimiter() {
  ArrayList<KV<String, Integer>> kvs = new ArrayList<>();
  kvs.add(KV.of("one", 1));
  kvs.add(KV.of("two", 2));

  ArrayList<String> expected = new ArrayList<>();
  expected.add("one\t1");
  expected.add("two\t2");

  PCollection<KV<String, Integer>> input = p.apply(Create.of(kvs));
  PCollection<String> output = input.apply(ToString.kvs("\t"));
  PAssert.that(output).containsInAnyOrder(expected);
  p.run();
}
 
Example #22
Source File: CoGroupTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@Test
@Category(NeedsRunner.class)
public void testNoMainInput() {
  PCollection<Row> pc1 =
      pipeline
          .apply(
              "Create1",
              Create.of(Row.withSchema(CG_SCHEMA_1).addValues("user1", 1, "us").build()))
          .setRowSchema(CG_SCHEMA_1);
  PCollection<Row> pc2 =
      pipeline
          .apply(
              "Create2",
              Create.of(Row.withSchema(CG_SCHEMA_2).addValues("user1", 9, "us").build()))
          .setRowSchema(CG_SCHEMA_2);
  PCollection<Row> pc3 =
      pipeline
          .apply(
              "Create3",
              Create.of(Row.withSchema(CG_SCHEMA_3).addValues("user1", 17, "us").build()))
          .setRowSchema(CG_SCHEMA_3);

  thrown.expect(IllegalArgumentException.class);
  PCollection<Row> joined =
      PCollectionTuple.of("pc1", pc1, "pc2", pc2, "pc3", pc3)
          .apply(
              "CoGroup1",
              CoGroup.join("pc1", By.fieldNames("user", "country").withSideInput())
                  .join("pc2", By.fieldNames("user2", "country2").withSideInput())
                  .join("pc3", By.fieldNames("user3", "country3").withSideInput()));
  pipeline.run();
}
 
Example #23
Source File: HdfsMrsImageDataProviderTest.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetMetadataReader() throws Exception
{
  MrsPyramidMetadataReaderContext context = new MrsPyramidMetadataReaderContext();

  MrsPyramidMetadataReader reader = provider.getMetadataReader(context);

  Assert.assertEquals("Wrong class", HdfsMrsPyramidMetadataReader.class, reader.getClass());

  Assert.assertEquals("Should be same object", reader, provider.getMetadataReader(context));
}
 
Example #24
Source File: TaskGuiFT.java    From spring-boot-quickstart with Apache License 2.0 5 votes vote down vote up
/**
 * 浏览任务列表.
 */
@Test
@Category(Smoke.class)
public void viewTaskList() {
	s.open("/task/");
	WebElement table = s.findElement(By.id("contentTable"));
	assertThat(s.getTable(table, 0, 0)).isEqualTo("Release SpringSide 4.0");
}
 
Example #25
Source File: MrsPyramidServiceTest.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetRasterPngSingleSourceTileWithColorScale() throws Exception
{
  // test png, single source tile with color scale defined in Pyramid
  testIslandsElevationFor("png",
      MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT, MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT,
      ISLANDS_ELEVATION_V2_IN_BOUNDS_SINGLE_TILE,
      islandsElevationColorScale_unqualified, getDefaultColorScale());
}
 
Example #26
Source File: AccumuloGeoTableTest.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetTile() throws Exception
{

  ZooKeeperInstance zkinst = new ZooKeeperInstance(inst, zoo);
  PasswordToken pwTok = new PasswordToken(pw.getBytes());
  Connector conn = zkinst.getConnector(u, pwTok);
  Assert.assertNotNull(conn);

  PasswordToken token = new PasswordToken(pw.getBytes());

  Authorizations auths = new Authorizations(authsStr.split(","));
  long start = 0;
  long end = Long.MAX_VALUE;
  Key sKey = AccumuloUtils.toKey(start);
  Key eKey = AccumuloUtils.toKey(end);
  Range r = new Range(sKey, eKey);
  Scanner s = conn.createScanner("paris4", auths);
  s.fetchColumnFamily(new Text(Integer.toString(10)));
  s.setRange(r);

  Iterator<Entry<Key, Value>> it = s.iterator();
  while (it.hasNext())
  {
    Entry<Key, Value> ent = it.next();
    if (ent == null)
    {
      return;
    }
    System.out.println("current key   = " + AccumuloUtils.toLong(ent.getKey().getRow()));
    System.out.println("current value = " + ent.getValue().getSize());
  }

}
 
Example #27
Source File: PAssertTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@Test
@Category({ValidatesRunner.class, UsesFailureMessage.class})
public void testAssertionSiteIsCapturedWithoutMessage() throws Exception {
  PCollection<Long> vals = pipeline.apply(GenerateSequence.from(0).to(5));
  assertThatCollectionIsEmptyWithoutMessage(vals);

  Throwable thrown = runExpectingAssertionFailure(pipeline);

  assertThat(
      thrown.getMessage(), containsString("Expected: iterable with items [] in any order"));
  String stacktrace = Throwables.getStackTraceAsString(thrown);
  assertThat(stacktrace, containsString("testAssertionSiteIsCapturedWithoutMessage"));
  assertThat(stacktrace, containsString("assertThatCollectionIsEmptyWithoutMessage"));
}
 
Example #28
Source File: CloudQueueTests.java    From azure-storage-android with Apache License 2.0 5 votes vote down vote up
@Test
@Category({ DevFabricTests.class, DevStoreTests.class })
public void testAddMessage() throws  StorageException {
    String msgContent = UUID.randomUUID().toString();
    final CloudQueueMessage message = new CloudQueueMessage(msgContent);
    this.queue.addMessage(message);
    VerifyAddMessageResult(message, msgContent);
    CloudQueueMessage msgFromRetrieve1 = this.queue.retrieveMessage();
    assertEquals(message.getMessageContentAsString(), msgContent);
    assertEquals(msgFromRetrieve1.getMessageContentAsString(), msgContent);
}
 
Example #29
Source File: DataProviderFactoryTest.java    From mrgeo with Apache License 2.0 5 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetVectorDataProviderForWriteWhenMissing() throws IOException
{
  // Using an existing resource
  String missingResource = "DoesNotExist";
  VectorDataProvider dp = DataProviderFactory.getVectorDataProvider(missingResource,
      AccessMode.WRITE, providerProperties);
  Assert.assertNotNull(dp);
}
 
Example #30
Source File: PlanetHandlingTest.java    From Open-Realms-of-Stars with GNU General Public License v2.0 5 votes vote down vote up
@Test
@Category(org.openRealmOfStars.UnitTest.class)
public void testTradeShipScoring() {
  Ship ship = Mockito.mock(Ship.class);
  Mockito.when(ship.getTotalMilitaryPower()).thenReturn(16);
  Mockito.when(ship.isTradeShip()).thenReturn(true);
  Mockito.when(ship.getMetalCost()).thenReturn(14);
  Mockito.when(ship.getProdCost()).thenReturn(22);
  Planet planet = Mockito.mock(Planet.class);
  PlayerInfo info = Mockito.mock(PlayerInfo.class);
  MissionList missionList = Mockito.mock(MissionList.class);
  Mission mission = Mockito.mock(Mission.class);
  Mockito.when(missionList.getMission(MissionType.TRADE_FLEET,
      MissionPhase.PLANNING)).thenReturn(mission);
  Mockito.when(info.getMissions()).thenReturn(missionList);
  StarMap map = Mockito.mock(StarMap.class);
  
  int score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.MERCHANTICAL);
  assertEquals(40, score);
  score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.DIPLOMATIC);
  assertEquals(35, score);
  score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.PEACEFUL);
  assertEquals(30, score);
  score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.SCIENTIFIC);
  assertEquals(25, score);
  score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.AGGRESSIVE);
  assertEquals(10, score);
  Mockito.when(missionList.getMission(MissionType.TRADE_FLEET,
      MissionPhase.PLANNING)).thenReturn(null);
  score = PlanetHandling.scoreTradeShip(20, ship, planet, info, map,
      Attitude.MERCHANTICAL);
  assertEquals(-1, score);
}