Java Code Examples for java.util.Locale.ENGLISH

The following are Jave code examples for showing how to use ENGLISH of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: oscm   File: RegistrationBeanTest.java   View Source Code Vote up 6 votes
@Test
public void register_UserAlreadyExist_NotInternalMode() throws Exception {
    // given
    new FacesContextStub(Locale.ENGLISH);
    prepareRegister();
    doReturn(Boolean.FALSE).when(userBeanMock).isInternalAuthMode();
    registrationBean.init();
    NonUniqueBusinessKeyException ex = new NonUniqueBusinessKeyException();
    doThrow(ex).when(accountServiceMock).registerCustomer(
            any(VOOrganization.class), any(VOUserDetails.class), any(String.class),
            eq(SERVICE_KEY), eq(MARKETPLACE_ID), eq(SUPPLIER_ID));

    //when
    String result = registrationBean.register();

    // then
    assertEquals(BaseBean.ERROR_USER_ALREADY_EXIST, ex.getMessageKey());        
    assertEquals(BaseBean.OUTCOME_ERROR, result);
}
 
Example 2
Project: oscm   File: ManageLanguageCtrlTest.java   View Source Code Vote up 6 votes
/**
 * @param facesMessages
 * @return
 */
private FacesContextStub givenContextStub(
        final List<FacesMessage> facesMessages) {
    FacesContextStub contextStub = new FacesContextStub(Locale.ENGLISH) {
        @Override
        public void addMessage(String arg0, FacesMessage arg1) {
            facesMessages.add(arg1);
        }

        @Override
        public Iterator<FacesMessage> getMessages() {
            return facesMessages.iterator();
        }
    };
    return contextStub;
}
 
Example 3
Project: TaipeiTechRefined   File: MainActivity.java   View Source Code Vote up 6 votes
protected void switchLanguage(String lang) {
    Resources resources = getResources();
    Configuration configuration = resources.getConfiguration();
    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
    switch (lang) {
        case "zh":
            configuration.locale = Locale.TAIWAN;
            break;
        case "ja":
            configuration.locale = Locale.JAPAN;
            break;
        default:
            configuration.locale = Locale.ENGLISH;
            break;
    }

    resources.updateConfiguration(configuration, displayMetrics);
    /*  避免重複寫入
    MainApplication.writeSetting("uiLang", lang);
    //*/
}
 
Example 4
Project: oscm   File: ServiceDetailsTest.java   View Source Code Vote up 6 votes
@Before
public void setup() throws Exception {
    voDetails = new VOServiceDetails();
    voDetails.setImageDefined(true);
    voDetails.setAccessType(ServiceAccessType.DIRECT);
    voDetails.setDescription("marketingName");
    voDetails.setFeatureURL("technicalURL");
    voDetails.setName("name");
    voDetails.setServiceId("serviceId");
    voDetails.setStatus(ServiceStatus.ACTIVE);
    voDetails.setSellerId("supplierId");
    voDetails.setSellerName("supplierName");
    voDetails.setTechnicalId("technicalId");

    new FacesContextStub(Locale.ENGLISH);
}
 
Example 5
Project: oscm   File: ApplicationStub.java   View Source Code Vote up 5 votes
@Override
public Locale getDefaultLocale() {
    if (defaultLocale != null) {
        return defaultLocale;
    }
    return Locale.ENGLISH;
}
 
Example 6
Project: NICON   File: ExporOnlyViagemPdf.java   View Source Code Vote up 5 votes
private void dataTableTitile(Document documento, String data) throws IOException, BadElementException, DocumentException {
    
   try {
       pTableEmpresaPricipal = new PdfPTable(new float[]{15f, 85f});
       pTableEmpresaInforImpres1 = new PdfPTable(1);
       pTableEmpresaInforImpres5 = new PdfPTable(1);
       
       PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG));
       pCellNomeEmpresa.setBorder(0);
       PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN));
       pCellNomeEndereco.setBorder(0);
       PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN));
       pCellCaixaPostal.setBorder(0);
       PdfPCell pCellTeleFax = new PdfPCell(new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
       pCellTeleFax.setBorder(0);
       PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN));
       pCellSociedade.setBorder(0);
       Image imageEmpresa = Image.getInstance("logo.png");
       imageEmpresa.scaleToFit(120f, 85f);
       pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
       pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
       pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
       pTableEmpresaInforImpres1.addCell(pCellTeleFax);
       pTableEmpresaInforImpres1.addCell(pCellSociedade);
       PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
       cellTabela3.setBorder(0);
       pTableEmpresaInforImpres5.addCell(cellTabela3);
       PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
       cellTabela5.setBorder(0);
       PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
       cellTabela6.setBorder(0);
       pTableEmpresaPricipal.setWidthPercentage(95);
       pTableEmpresaPricipal.addCell(cellTabela6);
       pTableEmpresaPricipal.addCell(cellTabela5);
       PdfPTable pTableTitulo = new PdfPTable(1);
       pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
       pTableTitulo.setWidthPercentage(100);
       
       SimpleDateFormat sdfEsp = new SimpleDateFormat("MMMM, yyyy", Locale.ENGLISH);
       SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy");
       PdfPCell cellTitulo = new PdfPCell(new Phrase("TOTAL PREMIUM COLLECTED ON TRAVEL INSURANCE AND TAXES FOR "+sdfEsp.format(sdf.parse(data)).toUpperCase(), fontCorpoNG));
       cellTitulo.setBorder(0);
       cellTitulo.setPaddingBottom(10f);
       pTableTitulo.addCell(cellTitulo);
       
       pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER);
       
       documento.add(pTableEmpresaPricipal);
       documento.add(pTableNull);
       documento.add(pTableTitulo);
   } catch (ParseException ex) {
       Logger.getLogger(ExporOnlyViagemPdf.class.getName()).log(Level.SEVERE, null, ex);
   }
}
 
Example 7
Project: MaterialTextClock   File: MaterialTextClock.java   View Source Code Vote up 5 votes
private void init() {
    mFormat = "hh:mm a";
    aSize = 0.5f;
    aColor = "#000000";
    numformats = "en";
    if(numformats.equals("ar")){
        local = new Locale("ar");
    }else{
        local = Locale.ENGLISH;
    }
    syf = new SimpleDateFormat("hh:mm a", local);
    createTime(mTimeZone);
}
 
Example 8
Project: oscm   File: TenantValidatorTest.java   View Source Code Vote up 5 votes
@Before
public void setup() {

    context = new FacesContextStub(Locale.ENGLISH);
    component = mock(UIComponent.class);

    tenantValidator = spy(new TenantValidator());
    tenantService = mock(TenantService.class);
    serviceLocator = mock(ServiceLocator.class);

    tenantValidator.serviceLocator = serviceLocator;
    when(serviceLocator.findService(TenantService.class))
            .thenReturn(tenantService);
}
 
Example 9
Project: dubbox-hystrix   File: LocaleUtils.java   View Source Code Vote up 5 votes
public static Locale getLocale(String language) {
	if ("en".equalsIgnoreCase(language)) {
    	return Locale.ENGLISH;
    } else if ("zh".equalsIgnoreCase(language)) {
    	return Locale.SIMPLIFIED_CHINESE;
    } else if ("zh_TW".equalsIgnoreCase(language)) {
    	return Locale.TRADITIONAL_CHINESE;
    }
    return Locale.getDefault();
}
 
Example 10
Project: oscm   File: LocaleUtilsTest.java   View Source Code Vote up 5 votes
private void initFacesContext() {
    new FacesContextStub(Locale.ENGLISH) {
        @Override
        public Application getApplication() {
            Application applicationStub = new ApplicationStub();
            List<Locale> locales = new ArrayList<Locale>();
            locales.add(Locale.ENGLISH);
            locales.add(Locale.GERMAN);
            locales.add(Locale.JAPANESE);
            locales.add(new Locale("in"));
            applicationStub.setSupportedLocales(locales);
            return applicationStub;
        }
    };
}
 
Example 11
Project: Runnest   File: RunningMapFragment.java   View Source Code Vote up 5 votes
private void startButtonPressed() {

        if(checkPermission() && locationSettingsHandler.checkLocationSettings()) {

            // Set user as unavailable
            new FirebaseHelper().
                    setUserAvailable(((AppRunnest) getActivity().getApplication()).getUser().getEmail(), false, false);

            // initialize new Run
            SimpleDateFormat dateFormat = new SimpleDateFormat("d MMM yyyy HH:mm:ss", Locale.ENGLISH);
            String runName = dateFormat.format(new Date());
            run = new Run(runName);
            super.startRun();
            // Prevent sleeping
            //noinspection ConstantConditions
            getView().setKeepScreenOn(true);

            startUpdatesButton.setVisibility(View.INVISIBLE);
            stopUpdatesButton.setVisibility(View.VISIBLE);

            chronometer.setVisibility(View.VISIBLE);
            chronometer.setBase(SystemClock.elapsedRealtime());
            chronometer.start();

            ((SideBarActivity)getActivity()).setRunning(true);

            setButtonsEnabledState();
        }
    }
 
Example 12
Project: SimpleUILauncher   File: AlphabeticIndexCompat.java   View Source Code Vote up 5 votes
public AlphabeticIndexVN(Context context) {
    LocaleList locales = context.getResources().getConfiguration().getLocales();
    int localeCount = locales.size();

    Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0);
    AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale);
    for (int i = 1; i < localeCount; i++) {
        indexBuilder.addLabels(locales.get(i));
    }
    indexBuilder.addLabels(Locale.ENGLISH);

    mAlphabeticIndex = indexBuilder.buildImmutableIndex();
}
 
Example 13
Project: oscm   File: IdValidatorTest.java   View Source Code Vote up 5 votes
@Before
public void setup() {

    validator = new IdValidator() {
        @Override
        protected int getMaxLength() {
            return TEST_LENGTH;
        }
    };

    context = new FacesContextStub(Locale.ENGLISH);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(Constants.UI_COMPONENT_ATTRIBUTE_LABEL, "componentStub");
    component = new UIComponentStub(map);
}
 
Example 14
Project: oscm   File: PriceModelBeanTest.java   View Source Code Vote up 5 votes
@Test
public void testGetServiceNameToDisplay_EmptyName() {
    new FacesContextStub(Locale.ENGLISH);

    VOServiceDetails details = new VOServiceDetails();
    details.setName("");
    bean.setSelectedService(details);

    String result = bean.getSelectedServiceNameToDisplay();
    assertEquals(JSFUtils.getText("marketplace.name.undefined", null),
            result);
}
 
Example 15
Project: oscm   File: UserIdValidatorTest.java   View Source Code Vote up 5 votes
@Before
public void setup() {
    validator = new UserIdValidator();
    context = new FacesContextStub(Locale.ENGLISH);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(Constants.UI_COMPONENT_ATTRIBUTE_LABEL, "componentStub");
    component = new UIComponentStub(map);
}
 
Example 16
Project: oscm   File: SubscriptionViewBeanTest.java   View Source Code Vote up 4 votes
@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);

    new FacesContextStub(Locale.ENGLISH) {
        @Override
        public void addMessage(String arg0, FacesMessage arg1) {
            facesMessages.add(arg1);
        }
    };
    sd = new VOSubscriptionDetails();
    sd.setPriceModel(new VOPriceModel());
    
    VOServiceDetails voServiceDetails = new VOServiceDetails();
    VOPriceModel voPriceModel = new VOPriceModel();
    voPriceModel.setExternal(false);
    voServiceDetails.setPriceModel(voPriceModel);
    
    sd.setSubscribedService(voServiceDetails);

    bean = spy(new SubscriptionViewBean());
    sessionBean = new SessionBean();
    ss = mock(SubscriptionService.class);

    when(ss.getSubscriptionForCustomer(eq(CUST_ID), eq(SUB_ID))).thenReturn(sd);
    subscriptionsService = mock(SubscriptionsService.class);
    poSubscriptionAndCustomers = givenPOSubscriptionAndCustomersList();
    poSubscriptionAndCustomers.add(getPOSubscriptionAndCustomer(SUB_ID));
    response = new Response(poSubscriptionAndCustomers);
    when(subscriptionsService.getSubscriptionsAndCustomersForManagers()).thenReturn(response);

    udaBean = mock(UdaBean.class);
    when(udaBean.getSubscriptionUdas(anyLong())).thenReturn(new ArrayList<UdaRow>());
    when(udaBean.getForType(eq(UdaBean.CUSTOMER_SUBSCRIPTION))).thenReturn(new ArrayList<VOUdaDefinition>());

    doReturn(ss).when(bean).getSubscriptionService();

    model = spy(new BPLazyDataModel());
    bean.setModel(model);
    model.setSubscriptionsService(subscriptionsService);
    model.arrange(spy(new FacesContextStub(Locale.ENGLISH)), mock(ArrangeableState.class));


    // doNothing().when(bean.ui).handleException(
    // any(SaaSApplicationException.class));

    VODiscount voDiscount = new VODiscount();
    voDiscount.setValue(BigDecimal.valueOf(1));
    voDiscount.setStartTime(Long.valueOf(1));
    discount = new Discount(voDiscount);
    discountBean = mock(DiscountBean.class);
    when(discountBean.getDiscountForCustomer(CUST_ID)).thenReturn(discount);

    bean.setSessionBean(sessionBean);
    bean.setUdaBean(udaBean);
    bean.setDiscountBean(discountBean);

}
 
Example 17
Project: NanoIconPack   File: PkgUtil.java   View Source Code Vote up 4 votes
@TargetApi(17)
public static String getAppLabelEn(Context context, String pkgName, String def) {
    if (context == null || TextUtils.isEmpty(pkgName)) {
        return def;
    }

    String result = def;
    try {
        PackageManager packageManager = context.getPackageManager();
        ApplicationInfo applicationInfo = packageManager.getPackageInfo(pkgName, 0).applicationInfo;

        Configuration configuration = new Configuration();
        // It's better, I think, to use Locale.ENGLISH
        // instead of Locale.ROOT (although I want to do).
        if (C.SDK >= 17) {
            configuration.setLocale(Locale.ENGLISH);
        } else {
            configuration.locale = Locale.ENGLISH;
        }
        // The result is a value in disorder maybe if using:
        //     packageManager.getResourcesForApplication(PACKAGE_NAME)
        Resources resources = packageManager.getResourcesForApplication(applicationInfo);
        resources.updateConfiguration(configuration,
                context.getResources().getDisplayMetrics());
        int labelResId = applicationInfo.labelRes;
        if (labelResId != 0) {
            // If the localized label is not added, the default is returned.
            // NOTICE!!!If the default were empty, Resources$NotFoundException would be called.
            result = resources.getString(labelResId);
        }

        /*
         * NOTICE!!!
         * We have to restore the locale.
         * On the one hand,
         * it will influence the label of Activity, etc..
         * On the other hand,
         * the got "resources" equals the one "this.getResources()" if the current .apk file
         * happens to be this APK Checker(com.by_syk.apkchecker).
         * We need to restore the locale, or the language of APK Checker will change to English.
         */
        if (C.SDK >= 17) {
            configuration.setLocale(Locale.getDefault());
        } else {
            configuration.locale = Locale.getDefault();
        }
        resources.updateConfiguration(configuration, context.getResources().getDisplayMetrics());
    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}
 
Example 18
Project: oscm   File: PriceConverterTest.java   View Source Code Vote up 4 votes
@Test(expected = ParseException.class)
public void testParse_InvalidFormat() throws Exception {
    PriceConverter converter = new PriceConverter(Locale.ENGLISH);
    Assert.assertEquals(Locale.ENGLISH, converter.getActiveLocale());
    converter.parse("-'1.2.3'");
}
 
Example 19
Project: civify-app   File: ShowQrFragment.java   View Source Code Vote up 4 votes
public ShowQrFragment() {
    // Required empty public constructor
    mSimpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
}
 
Example 20
Project: oscm   File: ManageAccessCtrlTest.java   View Source Code Vote up 3 votes
@Before
public void setup() {

    new FacesContextStub(Locale.ENGLISH);

    marketplaceService = mock(MarketplaceService.class);

    ctrl = spy(new ManageAccessCtrl());
    model = new ManageAccessModel();

    ctrl.setModel(model);
    ctrl.setMarketplaceService(marketplaceService);
}