Skip to content

Commit

Permalink
Add new regions
Browse files Browse the repository at this point in the history
  • Loading branch information
liry17 committed Aug 14, 2018
1 parent 82a115f commit 7c6abd9
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Simple Amazon Glacier Uploader Changelog

### TBD - Version 0.76.0

- Add new regions

### 2016/02/07 - Version 0.75.0

- Upgrade to Java version 8 (i.e. Java 8 is required).
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/brianmcmichael/sagu/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/**
* Amazon Endpoint(Region) helper enum. It preserves stable indexes of its values.
* See https://docs.aws.amazon.com/general/latest/gr/rande.html#glacier_region for current list.
*/
public enum Endpoint {

Expand All @@ -21,7 +22,18 @@ public enum Endpoint {
EU_WEST_IRELAND("eu-west-1", "EU (Ireland)"),
AP_NORTHEAST_TOKYO("ap-northeast-1", "Asia Pacific (Tokyo)"),
AP_SOUTHEAST_SYDNEY("ap-southeast-2", "Asia Pacific (Sydney)"),
EU_CENTRAL_FRANKFURT("eu-central-1", "EU (Frankfurt)");
EU_CENTRAL_FRANKFURT("eu-central-1", "EU (Frankfurt)"),
EU_WEST_LONDON("eu-west-2", "EU (London)"),
EU_WEST_PARIS("eu-west-3", "EU (Paris)"),
AP_NORTHEAST_SEOUL("ap-northeast-2", "Asia Pacific (Seoul)"),
AP_NORTHEAST_OSAKA_LOCAL("ap-northeast-3", "Asia Pacific (Osaka-Local)"),
AP_SOUTH_MUMBAI("ap-south-1", "Asia Pacific (Mumbai)"),
AP_SOUTHEAST_SINGAPORE("ap-southeast-1", "Asia Pacific (Singapore)"),
CN_NORTH_BEIJING("cn-north-1", "China (Beijing)"),
CN_NORTHWEST_NINGXIA("cn-northwest-1", "China (Ningxia)"),
CA_CENTRAL("ca-central-1", "Canada (Central)"),
US_EAST_OHIO("us-east-2", "US East (Ohio)"),
US_GOV_WEST("us-gov-west-1", "AWS GovCloud (US)");

private final String id;
private final String title;
Expand Down
91 changes: 75 additions & 16 deletions src/test/java/com/brianmcmichael/sagu/EndpointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,87 +12,146 @@

import javax.swing.*;

import static com.brianmcmichael.sagu.Endpoint.AP_NORTHEAST_TOKYO;
import static com.brianmcmichael.sagu.Endpoint.AP_SOUTHEAST_SYDNEY;
import static com.brianmcmichael.sagu.Endpoint.EU_CENTRAL_FRANKFURT;
import static com.brianmcmichael.sagu.Endpoint.EU_WEST_IRELAND;
import static com.brianmcmichael.sagu.Endpoint.US_EAST_NVIRGINIA;
import static com.brianmcmichael.sagu.Endpoint.US_WEST_NCALIFORNIA;
import static com.brianmcmichael.sagu.Endpoint.US_WEST_OREGON;
import static com.brianmcmichael.sagu.Endpoint.getTitleByIndex;
import static com.brianmcmichael.sagu.Endpoint.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class EndpointTest {

@Test
public void shouldReturnCorrectInstanceByIndex() throws Exception {
public void shouldReturnCorrectInstanceByIndex() {
assertThat(Endpoint.getByIndex(0), is(US_EAST_NVIRGINIA));
assertThat(Endpoint.getByIndex(1), is(US_WEST_OREGON));
assertThat(Endpoint.getByIndex(2), is(US_WEST_NCALIFORNIA));
assertThat(Endpoint.getByIndex(3), is(EU_WEST_IRELAND));
assertThat(Endpoint.getByIndex(4), is(AP_NORTHEAST_TOKYO));
assertThat(Endpoint.getByIndex(5), is(AP_SOUTHEAST_SYDNEY));
assertThat(Endpoint.getByIndex(6), is(EU_CENTRAL_FRANKFURT));
assertThat(Endpoint.getByIndex(7), is(EU_WEST_LONDON));
assertThat(Endpoint.getByIndex(8), is(EU_WEST_PARIS));
assertThat(Endpoint.getByIndex(9), is(AP_NORTHEAST_SEOUL));
assertThat(Endpoint.getByIndex(10), is(AP_NORTHEAST_OSAKA_LOCAL));
assertThat(Endpoint.getByIndex(11), is(AP_SOUTH_MUMBAI));
assertThat(Endpoint.getByIndex(12), is(AP_SOUTHEAST_SINGAPORE));
assertThat(Endpoint.getByIndex(13), is(CN_NORTH_BEIJING));
assertThat(Endpoint.getByIndex(14), is(CN_NORTHWEST_NINGXIA));
assertThat(Endpoint.getByIndex(15), is(CA_CENTRAL));
assertThat(Endpoint.getByIndex(16), is(US_EAST_OHIO));
assertThat(Endpoint.getByIndex(17), is(US_GOV_WEST));
}

@Test
public void getRegionTitleShouldReturnCorrectValues() throws Exception {
public void getRegionTitleShouldReturnCorrectValues() {
assertThat(getTitleByIndex(0), is("US East (Northern Virginia)"));
assertThat(getTitleByIndex(1), is("US West (Oregon)"));
assertThat(getTitleByIndex(2), is("US West (Northern California)"));
assertThat(getTitleByIndex(3), is("EU (Ireland)"));
assertThat(getTitleByIndex(4), is("Asia Pacific (Tokyo)"));
assertThat(getTitleByIndex(5), is("Asia Pacific (Sydney)"));
assertThat(getTitleByIndex(6), is("EU (Frankfurt)"));
assertThat(getTitleByIndex(7), is("EU (London)"));
assertThat(getTitleByIndex(8), is("EU (Paris)"));
assertThat(getTitleByIndex(9), is("Asia Pacific (Seoul)"));
assertThat(getTitleByIndex(10), is("Asia Pacific (Osaka-Local)"));
assertThat(getTitleByIndex(11), is("Asia Pacific (Mumbai)"));
assertThat(getTitleByIndex(12), is("Asia Pacific (Singapore)"));
assertThat(getTitleByIndex(13), is("China (Beijing)"));
assertThat(getTitleByIndex(14), is("China (Ningxia)"));
assertThat(getTitleByIndex(15), is("Canada (Central)"));
assertThat(getTitleByIndex(16), is("US East (Ohio)"));
assertThat(getTitleByIndex(17), is("AWS GovCloud (US)"));
}

@Test
public void shouldPopulateComboBoxWithValuesInCorrectOrder() throws Exception {
final JComboBox<String> comboBox = new JComboBox<String>();
public void shouldPopulateComboBoxWithValuesInCorrectOrder() {
final JComboBox<String> comboBox = new JComboBox<>();
assertThat(comboBox.getItemCount(), is(0));

Endpoint.populateComboBox(comboBox);
assertThat(comboBox.getItemCount(), is(7));
assertThat(comboBox.getItemCount(), is(18));
assertThat(comboBox.getItemAt(0), is("US East (Northern Virginia)"));
assertThat(comboBox.getItemAt(1), is("US West (Oregon)"));
assertThat(comboBox.getItemAt(2), is("US West (Northern California)"));
assertThat(comboBox.getItemAt(3), is("EU (Ireland)"));
assertThat(comboBox.getItemAt(4), is("Asia Pacific (Tokyo)"));
assertThat(comboBox.getItemAt(5), is("Asia Pacific (Sydney)"));
assertThat(comboBox.getItemAt(6), is("EU (Frankfurt)"));
assertThat(comboBox.getItemAt(7), is("EU (London)"));
assertThat(comboBox.getItemAt(8), is("EU (Paris)"));
assertThat(comboBox.getItemAt(9), is("Asia Pacific (Seoul)"));
assertThat(comboBox.getItemAt(10), is("Asia Pacific (Osaka-Local)"));
assertThat(comboBox.getItemAt(11), is("Asia Pacific (Mumbai)"));
assertThat(comboBox.getItemAt(12), is("Asia Pacific (Singapore)"));
assertThat(comboBox.getItemAt(13), is("China (Beijing)"));
assertThat(comboBox.getItemAt(14), is("China (Ningxia)"));
assertThat(comboBox.getItemAt(15), is("Canada (Central)"));
assertThat(comboBox.getItemAt(16), is("US East (Ohio)"));
assertThat(comboBox.getItemAt(17), is("AWS GovCloud (US)"));
}

@Test
public void getGlacierEndpointShouldReturnCorrectAddress() throws Exception {
public void getGlacierEndpointShouldReturnCorrectAddress() {
assertThat(US_EAST_NVIRGINIA.getGlacierEndpoint(), is("https://glacier.us-east-1.amazonaws.com/"));
assertThat(US_WEST_OREGON.getGlacierEndpoint(), is("https://glacier.us-west-2.amazonaws.com/"));
assertThat(US_WEST_NCALIFORNIA.getGlacierEndpoint(), is("https://glacier.us-west-1.amazonaws.com/"));
assertThat(EU_WEST_IRELAND.getGlacierEndpoint(), is("https://glacier.eu-west-1.amazonaws.com/"));
assertThat(AP_NORTHEAST_TOKYO.getGlacierEndpoint(), is("https://glacier.ap-northeast-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SYDNEY.getGlacierEndpoint(), is("https://glacier.ap-southeast-2.amazonaws.com/"));
assertThat(EU_CENTRAL_FRANKFURT.getGlacierEndpoint(), is("https://glacier.eu-central-1.amazonaws.com/"));
assertThat(EU_WEST_LONDON.getGlacierEndpoint(), is("https://glacier.eu-west-2.amazonaws.com/"));
assertThat(EU_WEST_PARIS.getGlacierEndpoint(), is("https://glacier.eu-west-3.amazonaws.com/"));
assertThat(AP_NORTHEAST_SEOUL.getGlacierEndpoint(), is("https://glacier.ap-northeast-2.amazonaws.com/"));
assertThat(AP_NORTHEAST_OSAKA_LOCAL.getGlacierEndpoint(), is("https://glacier.ap-northeast-3.amazonaws.com/"));
assertThat(AP_SOUTH_MUMBAI.getGlacierEndpoint(), is("https://glacier.ap-south-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SINGAPORE.getGlacierEndpoint(), is("https://glacier.ap-southeast-1.amazonaws.com/"));
assertThat(CN_NORTH_BEIJING.getGlacierEndpoint(), is("https://glacier.cn-north-1.amazonaws.com/"));
assertThat(CN_NORTHWEST_NINGXIA.getGlacierEndpoint(), is("https://glacier.cn-northwest-1.amazonaws.com/"));
assertThat(CA_CENTRAL.getGlacierEndpoint(), is("https://glacier.ca-central-1.amazonaws.com/"));
assertThat(US_EAST_OHIO.getGlacierEndpoint(), is("https://glacier.us-east-2.amazonaws.com/"));
assertThat(US_GOV_WEST.getGlacierEndpoint(), is("https://glacier.us-gov-west-1.amazonaws.com/"));
}

@Test
public void getSQSEndpointShouldReturnCorrectAddress() throws Exception {
public void getSQSEndpointShouldReturnCorrectAddress() {
assertThat(US_EAST_NVIRGINIA.getSQSEndpoint(), is("https://sqs.us-east-1.amazonaws.com/"));
assertThat(US_WEST_OREGON.getSQSEndpoint(), is("https://sqs.us-west-2.amazonaws.com/"));
assertThat(US_WEST_NCALIFORNIA.getSQSEndpoint(), is("https://sqs.us-west-1.amazonaws.com/"));
assertThat(EU_WEST_IRELAND.getSQSEndpoint(), is("https://sqs.eu-west-1.amazonaws.com/"));
assertThat(AP_NORTHEAST_TOKYO.getSQSEndpoint(), is("https://sqs.ap-northeast-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SYDNEY.getSQSEndpoint(), is("https://sqs.ap-southeast-2.amazonaws.com/"));
assertThat(EU_CENTRAL_FRANKFURT.getSQSEndpoint(), is("https://sqs.eu-central-1.amazonaws.com/"));
assertThat(EU_WEST_LONDON.getSQSEndpoint(), is("https://sqs.eu-west-2.amazonaws.com/"));
assertThat(EU_WEST_PARIS.getSQSEndpoint(), is("https://sqs.eu-west-3.amazonaws.com/"));
assertThat(AP_NORTHEAST_SEOUL.getSQSEndpoint(), is("https://sqs.ap-northeast-2.amazonaws.com/"));
assertThat(AP_NORTHEAST_OSAKA_LOCAL.getSQSEndpoint(), is("https://sqs.ap-northeast-3.amazonaws.com/"));
assertThat(AP_SOUTH_MUMBAI.getSQSEndpoint(), is("https://sqs.ap-south-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SINGAPORE.getSQSEndpoint(), is("https://sqs.ap-southeast-1.amazonaws.com/"));
assertThat(CN_NORTH_BEIJING.getSQSEndpoint(), is("https://sqs.cn-north-1.amazonaws.com/"));
assertThat(CN_NORTHWEST_NINGXIA.getSQSEndpoint(), is("https://sqs.cn-northwest-1.amazonaws.com/"));
assertThat(CA_CENTRAL.getSQSEndpoint(), is("https://sqs.ca-central-1.amazonaws.com/"));
assertThat(US_EAST_OHIO.getSQSEndpoint(), is("https://sqs.us-east-2.amazonaws.com/"));
assertThat(US_GOV_WEST.getSQSEndpoint(), is("https://sqs.us-gov-west-1.amazonaws.com/"));
}

@Test
public void getSNSEndpointShouldReturnCorrectAddress() throws Exception {
public void getSNSEndpointShouldReturnCorrectAddress() {
assertThat(US_EAST_NVIRGINIA.getSNSEndpoint(), is("https://sns.us-east-1.amazonaws.com/"));
assertThat(US_WEST_OREGON.getSNSEndpoint(), is("https://sns.us-west-2.amazonaws.com/"));
assertThat(US_WEST_NCALIFORNIA.getSNSEndpoint(), is("https://sns.us-west-1.amazonaws.com/"));
assertThat(EU_WEST_IRELAND.getSNSEndpoint(), is("https://sns.eu-west-1.amazonaws.com/"));
assertThat(AP_NORTHEAST_TOKYO.getSNSEndpoint(), is("https://sns.ap-northeast-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SYDNEY.getSNSEndpoint(), is("https://sns.ap-southeast-2.amazonaws.com/"));
assertThat(EU_CENTRAL_FRANKFURT.getSNSEndpoint(), is("https://sns.eu-central-1.amazonaws.com/"));
assertThat(EU_WEST_LONDON.getSNSEndpoint(), is("https://sns.eu-west-2.amazonaws.com/"));
assertThat(EU_WEST_PARIS.getSNSEndpoint(), is("https://sns.eu-west-3.amazonaws.com/"));
assertThat(AP_NORTHEAST_SEOUL.getSNSEndpoint(), is("https://sns.ap-northeast-2.amazonaws.com/"));
assertThat(AP_NORTHEAST_OSAKA_LOCAL.getSNSEndpoint(), is("https://sns.ap-northeast-3.amazonaws.com/"));
assertThat(AP_SOUTH_MUMBAI.getSNSEndpoint(), is("https://sns.ap-south-1.amazonaws.com/"));
assertThat(AP_SOUTHEAST_SINGAPORE.getSNSEndpoint(), is("https://sns.ap-southeast-1.amazonaws.com/"));
assertThat(CN_NORTH_BEIJING.getSNSEndpoint(), is("https://sns.cn-north-1.amazonaws.com/"));
assertThat(CN_NORTHWEST_NINGXIA.getSNSEndpoint(), is("https://sns.cn-northwest-1.amazonaws.com/"));
assertThat(CA_CENTRAL.getSNSEndpoint(), is("https://sns.ca-central-1.amazonaws.com/"));
assertThat(US_EAST_OHIO.getSNSEndpoint(), is("https://sns.us-east-2.amazonaws.com/"));
assertThat(US_GOV_WEST.getSNSEndpoint(), is("https://sns.us-gov-west-1.amazonaws.com/"));
}
}

0 comments on commit 7c6abd9

Please sign in to comment.