src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
IOUtil { public static String getPath(String file){ return FilenameUtils.getPath(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class clazz, String filePath); static Prop...
@Test public void testGetPath() { System.out.println("getPath"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "src/test/java/org/javabeanstack/util/"; String result = IOUtil.getPath(file); assertEquals(expResult, result); }
IOUtil { public static String getFullPath(String file){ return FilenameUtils.getFullPath(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class clazz, String filePath); sta...
@Test public void testGetFullPath() { System.out.println("getFullPath"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "c:/src/test/java/org/javabeanstack/util/"; String result = IOUtil.getFullPath(file); assertEquals(expResult, result); }
IOUtil { public static String getFullPathNoEndSeparator(String file){ return FilenameUtils.getFullPathNoEndSeparator(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class ...
@Test public void testGetFullPathNoEndSeparator() { System.out.println("getFullPathNoEndSeparator"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "c:/src/test/java/org/javabeanstack/util"; String result = IOUtil.getFullPathNoEndSeparator(file); assertEquals(expResult, result); ...
IOUtil { public static String getFileBaseName(String file){ return FilenameUtils.getBaseName(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class clazz, String filePath);...
@Test public void testGetFileBaseName() { System.out.println("getFileBaseName"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "prueba"; String result = IOUtil.getFileBaseName(file); assertEquals(expResult, result); }
IOUtil { public static String getFileName(String file){ return FilenameUtils.getName(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class clazz, String filePath); static ...
@Test public void testGetFileName() { System.out.println("getFileName"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "prueba.xml"; String result = IOUtil.getFileName(file); assertEquals(expResult, result); }
IOUtil { public static String getFileExtension(String file){ return FilenameUtils.getExtension(file); } private IOUtil(); static boolean isFileExist(String filePath); static boolean isFolderExist(String folder); static String addbs(String pathFolder); static InputStream getResourceAsStream(Class clazz, String filePath...
@Test public void testGetFileExtension() { System.out.println("getFileExtension"); String file = "c:/src/test/java/org/javabeanstack/util/prueba.xml"; String expResult = "xml"; String result = IOUtil.getFileExtension(file); assertEquals(expResult, result); }
AbstractDataService implements IDataService { @Override public <T extends IDataRow> T findById(Class<T> entityClass, String sessionId, Object id) throws Exception { return dao.findById(entityClass, sessionId, id); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String ses...
@Test public void test10FindById() throws Exception { System.out.println("10-DataService - findById"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppUser user = dataService.findById(AppUser.class, sessionid, 1L); assertNotNull(user); user = dataService.findById(AppUser.class, ses...
AbstractDataService implements IDataService { @Override public <T extends IDataRow> T findByUk(String sessionId, T ejb) throws Exception { return dao.findByUk(sessionId, ejb); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object>...
@Test public void test11FindByUk() throws Exception { System.out.println("11-DataService - findByUk"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppResource appResource = new AppResource(); appResource.setCode("no se encuentra"); appResource = dataService.findByUk(sessionid, app...
AbstractDataService implements IDataService { @Override public <T extends IDataRow> List<T> find(Class<T> entityClass, String sessionId) throws Exception { return dao.find(entityClass, sessionId); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Overrid...
@Test public void test12Find() throws Exception { System.out.println("12-DataService - find"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppUser> users = dataService.find(AppUser.class, sessionid); assertTrue(users.size() > 0); String order = "code desc"; String filter = ""...
AbstractDataService implements IDataService { @Override public <T extends IDataRow> T findByQuery(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return dao.findByQuery(sessionId, queryString, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUser...
@Test public void test13FindByQuery() throws Exception { System.out.println("13-DataService - findByQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppUser user = dataService.findByQuery(sessionid, "select o from AppUser o where iduser = 1L", null); assertNotNull(user); user ...
AbstractDataService implements IDataService { @Override public <T extends IDataRow> List<T> findListByQuery(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return dao.findListByQuery(sessionId, queryString, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @...
@Test public void test14FindListByQuery() throws Exception { System.out.println("14-DataService - findListByQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppUser> users = dataService.findListByQuery(sessionid, "select o from AppUser o where iduser = 1L", null); assertN...
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public <T extends IDataRow> T findById(Class<T> entityClass, String sessionId, Object id) throws Exception { LOGGER.debug(Strings.replicate("-", 50)); LOGGER.debug("find"); LOGGER.debug(entityClass.toString()); IDBLi...
@Test public void test02FindById() throws Exception { System.out.println("2-AbstractDAO - findById"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppUser user = dao.findById(AppUser.class, sessionid, 1L); assertNotNull(user); user = dao.findById(AppUser.class, sessionid, 0L); asse...
AbstractDataService implements IDataService { @Override public <T extends IDataRow> List<T> findListByNamedQuery(String sessionId, String namedQuery, Map<String, Object> parameters) throws Exception { return dao.findListByNamedQuery(sessionId, namedQuery, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessi...
@Test public void test15FindByNamedQuery() throws Exception { System.out.println("15-DataService - findByNamedQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppTablesRelation> prueba = dataService.findListByNamedQuery(sessionid, "AppTablesRelation.findAll", null); asser...
AbstractDataService implements IDataService { @Override public List<Object> findByNativeQuery(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return dao.findByNativeQuery(sessionId, queryString, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUs...
@Test public void test16FindByNativeQuery() throws Exception { System.out.println("16-DataService - findByNativeQuery"); if (error != null) { System.out.println(error); return; } String sqlSentence = "select * from {schema}.moneda where idmoneda > :id"; Map<String, Object> params = new HashMap(); params.put("id",0); Li...
AbstractDataService implements IDataService { @Override public Long getCount(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return dao.getCount(sessionId, queryString, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(S...
@Test public void test18GetCount() throws Exception { System.out.println("18-DataService - getCount"); String sessionid = null; if (error != null) { System.out.println(error); return; } Long rec = dataService.getCount(sessionid, "select o FROM AppCompany o", null); assertTrue(rec > 0L); }
AbstractDataService implements IDataService { @Override public Long getCount2(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return dao.getCount2(sessionId, queryString, parameters); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession...
@Test public void test19GetCount2() throws Exception { System.out.println("19-DataService - getCount2"); String sessionid = null; if (error != null) { System.out.println(error); return; } Long rec = dataService.getCount2(sessionid, "select * FROM {schema}.empresa", null); assertTrue(rec > 0L); }
AbstractDataService implements IDataService { @Override public <T extends IDataRow> List<T> getDataRows(String sessionId, Class<T> type, String order, String filter, Map<String, Object> params, int firstRow, int maxRows) throws Exception { String query = getSelectCmd(sessionId, type, order, filter); if (maxRows == -1) ...
@Test public void test20GetDataRows() throws Exception{ System.out.println("20-DataService - getDataRows"); if (error != null) { System.out.println(error); return; } List<Moneda> monedas = dataService.getDataRows(sessionId, Moneda.class,"" , "", null,0,1000); assertFalse(monedas.isEmpty()); }
AbstractDataService implements IDataService { @Override public Map<String, Object> getEntityManagerProp(String persistUnit) { return dao.getEntityManagerProp(persistUnit); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object> get...
@Test public void test29GetEntityManagerProp() throws Exception { System.out.println("29-DataService - getEntityManagerProp"); if (error != null) { System.out.println(error); return; } Map<String, Object> props = dataService.getEntityManagerProp(dataLink.getPersistUnit()); assertNotNull(props); }
AbstractDataService implements IDataService { @Override public Map<String, Object> getPersistUnitProp(String persistUnit) { return dao.getPersistUnitProp(persistUnit); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object> getEnti...
@Test public void test30GetPersistUnitProp() throws Exception{ System.out.println("30-DataService - getPersistUnitProp"); if (error != null) { System.out.println(error); return; } Map<String, Object> props = dataService.getPersistUnitProp(dataLink.getPersistUnit()); assertNotNull(props); }
AbstractDataService implements IDataService { @Override public IUserSession getUserSession(String sessionId) { return dao.getUserSession(sessionId); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object> getEntityManagerProp(Strin...
@Test public void test31GetUserSession() throws Exception{ System.out.println("31-DataService - getUserSession"); if (error != null) { System.out.println(error); return; } assertNotNull(dataService.getUserSession(sessionId)); } @Test public void test32GetDBLinkInfo() throws Exception{ System.out.println("32-DataService...
AbstractDataService implements IDataService { @Override public String getDataEngine(String persistentUnit) { return dao.getDataEngine(persistentUnit); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object> getEntityManagerProp(Str...
@Test public void test33GetDataEngine() throws Exception { System.out.println("33-DataService - getDataEngine"); if (error != null) { System.out.println(error); return; } System.out.println(dataService.getDataEngine("PU1")); String expResult = dataService.getDataEngine("PU1"); assertNotNull(expResult); }
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public <T extends IDataRow> T findByUk(String sessionId, T ejb) throws Exception { LOGGER.debug(Strings.replicate("-", 50)); LOGGER.debug("findByUk"); LOGGER.debug(ejb.getClass().getSimpleName()); if (ejb.getQueryUK(...
@Test public void test03FindByUk() throws Exception { System.out.println("3-AbstractDAO - findByUk"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppResource appResource = new AppResource(); appResource.setCode("no se encuentra"); appResource = dao.findByUk(sessionid, appResource)...
AbstractDataService implements IDataService { @Override public String getSchema(String persistentUnit) { return dao.getSchema(persistentUnit); } @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override IUserSession getUserSession(String sessionId); @Override Map<String, Object> getEntityManagerProp(String pers...
@Test public void test34GetSchema() throws Exception { System.out.println("34-DataService - getSchema"); if (error != null) { System.out.println(error); return; } System.out.println(dataService.getSchema("PU1")); String expResult = dataService.getSchema("PU1"); assertNotNull(expResult); }
AbstractDataLink implements IDataLink, Serializable { @Override public String getPersistUnit() { return persistUnit; } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T dao); @Override abstract T getDataService(); @Override String getPersistUnit(); @Override IDataResult persist(T ejb); @Overrid...
@Test public void test01GetPersistUnit() { System.out.println("1-DataLink - getPersistUnit"); if (error != null) { System.out.println(error); return; } String result = dataLinkCat.getPersistUnit(); String expResult = "PU1"; assertNotNull(expResult, result); }
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> T findById(Class<T> entityClass, Object id) throws Exception, SessionError { checkUserSession(); if (id == null){ return null; } return getDao().findById(entityClass, getSessionId(), id); } @Override abstract IGenericDAO getDao...
@Test public void test02Find() throws Exception { System.out.println("2-DataLink - find"); if (error != null) { System.out.println(error); return; } AppUser user = dataLinkCat.findById(AppUser.class, 1L); assertNotNull(user); }
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> T findByUk(T ejb) throws Exception, SessionError { checkUserSession(); if (ejb == null){ return null; } return getDao().findByUk(getSessionId(), ejb); } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T ...
@Test public void test03FindByUk() throws Exception { System.out.println("3-DataLink - findByUk"); if (error != null) { System.out.println(error); return; } AppResource appResource = new AppResource(); appResource.setCode("no se encuentra"); appResource = dataLinkCat.findByUk(appResource); assertNull(appResource); appR...
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> T findByQuery(String queryString, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); parameters = addParams(queryString, parameters); return getDao().findByQuery(getSessionId(), queryString, par...
@Test public void test04FindByQuery() throws Exception { System.out.println("4-DataLink - findByQuery"); if (error != null) { System.out.println(error); return; } AppUser user = dataLinkCat.findByQuery("select o from AppUser o where iduser = 1L", null); assertNotNull(user); user = dataLinkCat.findByQuery("select o from...
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> List<T> findListByQuery(String queryString, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); parameters = addParams(queryString, parameters); return getDao().findListByQuery(getSessionId(), qu...
@Test public void test05FindListByQuery() throws Exception { System.out.println("5-DataLink - findListByQuery"); if (error != null) { System.out.println(error); return; } List<AppUser> users = dataLinkCat.findListByQuery("select o from AppUser o where iduser = 1L", null); assertNotNull(users); users = dataLinkCat.findL...
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> List<T> findListByNamedQuery(String namedQuery, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); return getDao().findListByNamedQuery(getSessionId(), namedQuery, parameters); } @Override abst...
@Test public void test06FindByNamedQuery() throws Exception { System.out.println("6-DataLink - findByNamedQuery"); if (error != null) { System.out.println(error); return; } List<AppTablesRelation> prueba = dataLinkCat.findListByNamedQuery("AppTablesRelation.findAll", null); assertTrue(!prueba.isEmpty()); }
AbstractDataLink implements IDataLink, Serializable { @Override public List<Object> findByNativeQuery(String queryString, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); parameters = addParams(queryString, parameters); return getDao().findByNativeQuery(getSessionId(), queryString, p...
@Test public void test07FindByNativeQuery() throws Exception { System.out.println("7-DataLink - findByNativeQuery"); if (error != null) { System.out.println(error); return; } String sqlSentence = "select * from {schema}.moneda where idmoneda > :id"; Map<String, Object> params = new HashMap(); params.put("id", 0); List<...
AbstractDataLink implements IDataLink, Serializable { @Override public <T extends IDataRow> IDataResult persist(T ejb) throws SessionError{ ejb.setAction(IDataRow.INSERT); return update(ejb); } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T dao); @Override abstract T getDataService(); @Overr...
@Test public void test09Persist2() throws Exception { System.out.println("9-DataLink - persist2"); if (error != null) { System.out.println(error); return; } Moneda moneda = new Moneda(); moneda.setCodigo("PYG"); moneda.setNombre("Guarani"); moneda.setCambio(BigDecimal.ONE); moneda.setObservacion("34424"); IDataResult d...
AbstractDAO implements IGenericDAO { @Override public <T extends IDataRow> List<T> find(Class<T> entityClass, String sessionId) throws Exception { return find(entityClass, sessionId, null, null, null, 0, 0); } AbstractDAO(); @Override IDBLinkInfo getDBLinkInfo(String sessionId); @Override @TransactionAttribute(Transact...
@Test public void test04Find() throws Exception { System.out.println("4-AbstractDAO - find"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppUser> users = dao.find(AppUser.class, sessionid); assertTrue(users.size() > 0); String order = "code desc"; String filter = ""; users =...
AbstractDataLink implements IDataLink, Serializable { @Override public Long getCount(String queryString, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); parameters = addParams(queryString, parameters); return getDao().getCount(getSessionId(), queryString, parameters); } @Override a...
@Test public void test21GetCount() throws Exception { System.out.println("21-DataLink - getCount"); if (error != null) { System.out.println(error); return; } Long rec = dataLinkCat.getCount("select o FROM AppCompany o", null); assertTrue(rec > 0L); }
AbstractDataLink implements IDataLink, Serializable { @Override public Long getCount2(String queryString, Map<String, Object> parameters) throws Exception, SessionError { checkUserSession(); parameters = addParams(queryString, parameters); return getDao().getCount2(getSessionId(), queryString, parameters); } @Override...
@Test public void test22GetCount2() throws Exception { System.out.println("22-DataLink - getCount2"); if (error != null) { System.out.println(error); return; } Long rec = dataLinkCat.getCount2("select * FROM {schema}.empresa", null); assertTrue(rec > 0L); }
AbstractDataLink implements IDataLink, Serializable { @Override public Map<String, Object> getEntityManagerProp() { return getDao().getEntityManagerProp(persistUnit); } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T dao); @Override abstract T getDataService(); @Override String getPersistUnit...
@Test public void test23GetEntityManagerProp() { System.out.println("23-DataLink - getEntityManagerProp"); if (error != null) { System.out.println(error); return; } Map<String, Object> props = dataLinkCat.getEntityManagerProp(); assertNotNull(props); }
AbstractDataLink implements IDataLink, Serializable { @Override public Map<String, Object> getPersistUnitProp() { return getDao().getPersistUnitProp(persistUnit); } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T dao); @Override abstract T getDataService(); @Override String getPersistUnit(); ...
@Test public void test24GetPersistUnitProp() { System.out.println("24-DataLink - getPersistUnitProp"); if (error != null) { System.out.println(error); return; } Map<String, Object> props = dataLinkCat.getPersistUnitProp(); assertNotNull(props); }
AbstractDataLink implements IDataLink, Serializable { @Override public IUserSession getUserSession() { return userSession; } @Override abstract IGenericDAO getDao(); @Override abstract void setDao(T dao); @Override abstract T getDataService(); @Override String getPersistUnit(); @Override IDataResult persist(T ejb); @O...
@Test public void test25GetUserSession() { System.out.println("25-DataLink - getUserSession"); if (error != null) { System.out.println(error); return; } assertNotNull(dataLink.getUserSession()); }
DataRow implements IDataRow, Cloneable { @XmlTransient @Override public Object getValue(String fieldname) { if (fieldsOldValues == null) { this.setOldValues(); } return DataInfo.getFieldValue(this, fieldname); } DataRow(); @Override Object clone(); @Override void setOldValues(); @Override Object getOldValue(String fiel...
@Test public void testGetValue() { System.out.println("DataRow - getValue"); String expResult = "codigo nombre"; DataRowPrb row = new DataRowPrb(); String result = (String)row.getValue("codigo"); assertEquals("codigo", result); result = (String)row.getValue("publicCodigoNombre"); assertEquals(expResult, result); result...
DataRow implements IDataRow, Cloneable { @XmlTransient @Override public Class getFieldType(String fieldname) { Class result = DataInfo.getFieldType(this.getClass(), fieldname); if (result == null) { result = DataInfo.getMethodReturnType(this.getClass(), fieldname, true); } return result; } DataRow(); @Override Object c...
@Test public void testGetFieldType() { System.out.println("DataRow - getFieldType"); Class expResult = String.class; DataRowPrb row = new DataRowPrb(); Class result = row.getFieldType("codigo"); assertEquals(expResult, result); result = row.getFieldType("publicCodigoNombre"); assertEquals(expResult, result); result = r...
DataRow implements IDataRow, Cloneable { @Override public void setValue(String fieldname, Object value) throws FieldException { if (fieldsOldValues == null) { this.setOldValues(); } Boolean exito = DataInfo.setFieldValue(this, fieldname, value); if (!exito) { LOGGER.error("fieldname: " + fieldname); throw new FieldExce...
@Test public void testSetValue() throws Exception { System.out.println("DataRow - setValue"); String fieldname = "codigo"; Object value = "codigocambiado"; DataRow row = new DataRowPrb(); row.setValue(fieldname, value); assertEquals("codigocambiado", row.getValue(fieldname)); fieldname = "child.codigo"; value = "codigo...
DataRow implements IDataRow, Cloneable { @Override public int hashCode() { int hash = 0; hash += (getId() != null ? getId().hashCode() : 0); hash *= getClass().getName().hashCode(); return hash; } DataRow(); @Override Object clone(); @Override void setOldValues(); @Override Object getOldValue(String fieldName); @Overri...
@Test public void testHashcode() { System.out.println("DataRow - HashCode"); DataRowPrb row = new DataRowPrb(); row.setId(2L); int hashCode = row.hashCode(); System.out.println(row.hashCode()); for (int i = 0;i<10;i++){ int hashCode2 = row.hashCode(); assertEquals(hashCode, hashCode2); } row.setId(999999999999999L); Sy...
DataInfo { public static <T extends IDataRow> boolean isPrimaryKey(Class<T> classType, String fieldname) { try { Field field = DataInfo.getDeclaredField(classType, fieldname); Id id = field.getAnnotation(Id.class); return id != null; } catch (Exception ex) { return false; } } private DataInfo(); static boolean isPrima...
@Test public void test01IsPrimaryKey() { System.out.println("1-DataInfo - isPrimaryKey"); boolean expResult = true; boolean result = DataInfo.isPrimaryKey(AppUser.class, "iduser"); assertEquals(expResult, result); result = DataInfo.isPrimaryKey(AppUser.class, "code"); assertEquals(false, result); result = DataInfo.isPr...
AbstractDAO implements IGenericDAO { @Override public <T extends IDataRow> T findByQuery(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { LOGGER.debug(Strings.replicate("-", 50)); LOGGER.debug("findByQuery"); LOGGER.debug(queryString); IDBLinkInfo dbLinkInfo = sessions.getDBLinkI...
@Test public void test05FindByQuery() throws Exception { System.out.println("5-AbstractDAO - findByQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } AppUser user = dao.findByQuery(sessionid, "select o from AppUser o where iduser = 1L", null); assertNotNull(user); user = dao.fin...
DataInfo { public static <T extends IDataRow> boolean isUniqueKey(Class<T> classType, String fieldname) { try { String[] fields = DataInfo.getUniqueFields(classType); if (fields == null) { return false; } for (String field : fields) { if (field.equalsIgnoreCase(fieldname.toLowerCase())) { return true; } } return false;...
@Test public void test02IsUniqueKey() { System.out.println("2-DataInfo - isUniqueKey"); boolean expResult = true; boolean result = DataInfo.isUniqueKey(AppResource.class, "code"); assertEquals(expResult, result); result = DataInfo.isUniqueKey(AppResource.class, "referencetime"); assertEquals(false, result); result = Da...
DataInfo { public static <T extends IDataRow> boolean isForeignKey(Class<T> classType, String fieldname) { try { Field field = DataInfo.getDeclaredField(classType, fieldname); JoinColumn idforeignkey = field.getAnnotation(JoinColumn.class); return idforeignkey != null; } catch (Exception ex) { return false; } } private...
@Test public void test03IsForeignKey() { System.out.println("3-DataInfo - isForeignKey"); boolean expResult = true; boolean result = DataInfo.isForeignKey(AppUserMember.class, "usermember"); assertEquals(expResult, result); result = DataInfo.isForeignKey(AppUserMember.class, "usergroup"); assertEquals(expResult, result...
DataInfo { public static <T extends IDataRow> boolean isFieldExist(Class<T> classType, String fieldname) { try { Field field = DataInfo.getDeclaredField(classType, fieldname); if (field != null) { return true; } } catch (Exception ex) { ErrorManager.showError(ex, LOGGER); } return false; } private DataInfo(); static b...
@Test public void test04IsFieldExist() { System.out.println("4-DataInfo - isFieldExist"); boolean expResult = true; boolean result = DataInfo.isFieldExist(AppUser.class, "iduser"); assertEquals(expResult, result); result = DataInfo.isFieldExist(AppUser.class, "noexiste"); assertEquals(false, result); }
DataInfo { public static <T extends IDataRow> boolean isLazyFetch(Class<T> classType, String fieldname) { try { Field field = DataInfo.getDeclaredField(classType, fieldname); OneToMany annotation = field.getAnnotation(OneToMany.class); return annotation.fetch() == FetchType.LAZY; } catch (Exception ex) { return false; ...
@Test public void test05IsLazyFetch() { System.out.println("5-DataInfo - isLazyFetch"); boolean expResult = true; boolean result = DataInfo.isLazyFetch(AppUserFormView.class, "appUserFormViewColumnList"); assertEquals(expResult, result); result = DataInfo.isLazyFetch(AppUserFormView.class, "usergroup"); assertEquals(fa...
DataInfo { public static <T extends IDataRow> List<Field> getLazyMembers(Class<T> classType) { try { Field[] fields = classType.getDeclaredFields(); List<Field> lazyFields = new ArrayList(); for (Field field : fields) { OneToMany annotation = field.getAnnotation(OneToMany.class); if (annotation != null) { if (annotatio...
@Test public void test06GetLazyMembers() { System.out.println("6-DataInfo - getLazyMembers"); List<Field> result = DataInfo.getLazyMembers(AppUserFormView.class); assertTrue(!result.isEmpty()); result = DataInfo.getLazyMembers(AppTablesRelation.class); assertTrue(result.isEmpty()); }
DataInfo { public static <T extends IDataRow> String getTableName(Class<T> classType) { try { Table entity = classType.getAnnotation(Table.class); return entity.name(); } catch (Exception ex) { ErrorManager.showError(ex, LOGGER); } return ""; } private DataInfo(); static boolean isPrimaryKey(Class<T> classType, String...
@Test public void test07GetTableName() { System.out.println("7-DataInfo - getTableName"); String expResult = "appuser"; String result = DataInfo.getTableName(AppUser.class); assertEquals(expResult, result); }
DataInfo { public static String createQueryUkCommand(IDataRow ejb) { try { String command = "select o from " + ejb.getClass().getSimpleName() + " o "; if (!ejb.getIdFunctionFind().equals("")) { command = command + " where " + "o." + DataInfo.getIdFieldName(ejb.getClass()) + " = :" + ejb.getIdFunctionFind(); return comm...
@Test public void test08CreateQueryUkCommand() { System.out.println("8-DataInfo - createQueryUkCommand"); IDataRow ejb = new AppResource(); String expResult = "select o from AppResource o where o.code = :code"; String result = DataInfo.createQueryUkCommand(ejb); assertEquals(expResult, result); }
DataInfo { public static <T extends IDataRow> String getIdFieldName(Class<T> classType) { try { Field[] fields = classType.getDeclaredFields(); for (Field field : fields) { Id id = field.getAnnotation(Id.class); if (id != null) { return field.getName(); } } return null; } catch (SecurityException ex) { ErrorManager.sho...
@Test public void test09GetIdFieldName() { System.out.println("9-DataInfo - getIdFieldName"); String expResult = "iduser"; String result = DataInfo.getIdFieldName(AppUser.class); assertEquals(expResult, result); }
DataInfo { public static <T extends IDataRow> String[] getUniqueFields(Class<T> classType) { try { String[] uniqueConst = classType.getAnnotation(Table.class).uniqueConstraints()[0].columnNames(); if (uniqueConst != null) { return uniqueConst; } } catch (Exception ex) { ErrorManager.showError(ex, LOGGER); } return null...
@Test public void test10GetUniqueFields() { System.out.println("10-DataInfo - getUniqueFields"); String[] expResult = {"code"}; String[] result = DataInfo.getUniqueFields(AppResource.class); assertArrayEquals(expResult, result); }
DataInfo { public static Object getIdvalue(IDataRow ejb) { try { String field = DataInfo.getIdFieldName(ejb.getClass()); if (field != null) { return ejb.getValue(field); } return null; } catch (Exception ex) { ErrorManager.showError(ex, LOGGER); } return null; } private DataInfo(); static boolean isPrimaryKey(Class<T>...
@Test public void test11GetIdvalue() { System.out.println("11-DataInfo - getIdvalue"); AppResource ejb = new AppResource(); ejb.setIdappresource(1L); Object expResult = 1L; Object result = DataInfo.getIdvalue(ejb); assertEquals(expResult, result); }
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public <T extends IDataRow> List<T> findListByQuery(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { return findListByQuery(sessionId, queryString, parameters, 0, 0); } Abstrac...
@Test public void test06FindListByQuery() throws Exception { System.out.println("6-AbstractDAO - findListByQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppUser> users = dao.findListByQuery(sessionid, "select o from AppUser o where iduser = 1L", null); assertNotNull(us...
DataInfo { public static <T extends IDataRow> Object getDefaultValue(T ejb, String fieldname) { Object valor = null; Class<?> classObj = ejb.getClass(); try { Field field = DataInfo.getDeclaredField(classObj, fieldname + "_default"); field.setAccessible(true); valor = field.get(ejb); } catch (SecurityException | Illega...
@Test public void test13GetDefaultValue() { System.out.println("13-DataInfo - getDefaultValue"); DataRow ejb = new DataInfoPrb(); String fieldname = "codigo"; Object expResult = "codigodefault"; Object result = DataInfo.getDefaultValue(ejb, fieldname); assertEquals(expResult, result); }
DataInfo { public static <T extends IDataRow> void setDefaultValue(T ejb, String fieldname) { Object valor; Class<?> classObj = ejb.getClass(); try { Field field = DataInfo.getDeclaredField(classObj, fieldname); field.setAccessible(true); valor = DataInfo.getDefaultValue(ejb, fieldname); if (valor != null) { field.set(...
@Test public void test15SetDefaultValue() { System.out.println("15-DataInfo - setDefaultValue"); DataRow ejb = new DataInfoPrb(); String fieldname = "codigo"; DataInfo.setDefaultValue(ejb, fieldname); Object expResult = "codigodefault"; Object result = ejb.getValue(fieldname); assertEquals(expResult, result); }
DataInfo { public static Class getFieldType(Class classType, String fieldname) { Class cls = null; try { if (fieldname.contains(".")) { String className = fieldname.substring(0, Strings.findString(".", fieldname)); Class classMember = classType.getDeclaredField(className).getType(); fieldname = fieldname.substring(Stri...
@Test public void test16GetFieldType() { System.out.println("16-DataInfo - getFieldType"); Class expResult = Long.class; Class result = DataInfo.getFieldType(AppResource.class, "idappresource"); assertEquals(expResult, result); result = DataInfo.getFieldType(AppResource.class, "noexiste"); assertNull(result); }
DataInfo { public static Object getFieldValue(Object ejb, String fieldname) { Object value = null; try { if (fieldname.contains(".")) { String memberName = fieldname.substring(0, Strings.findString(".", fieldname)); fieldname = fieldname.substring(Strings.findString(".", fieldname) + 1); Field field = getDeclaredField(...
@Test public void test18GetFieldValue() { System.out.println("18-DataInfo - getFieldValue"); AppTablesRelation ejb = new AppTablesRelation(); ejb.setEntityPK("xx1"); ejb.setEntityFK("xx2"); ejb.setFechacreacion(new Date()); ejb.setFechamodificacion(new Date()); ejb.setFieldsFK("id"); ejb.setFieldsPK("id"); ejb.setInclu...
JsonUtil { public static <T extends IDataQueryModel> JsonArray create(List<T> data) { if (data == null){ return null; } Map<String, Object> config = new HashMap(); config.put("javax.json.stream.JsonGenerator.prettyPrinting", true); JsonBuilderFactory factory = Json.createBuilderFactory(config); JsonArrayBuilder builder...
@Test public void testCreate() throws Exception{ System.out.println("1-JsonUtil - create"); if (error != null) { System.out.println(error); return; } DataNativeQuery query = (DataNativeQuery)dataLink.newDataNativeQuery(); List<IDataQueryModel> data = query.select("codigo, nombre, cambio, fechacreacion, fechareplicacion...
DigestAuth { public boolean check(ClientAuth requestAuth) { if (requestAuth.getType().equals(BASIC) && isValidTypeAuth(BASIC)) { return checkBasic(requestAuth); } if (requestAuth.getType().equals(DIGEST) && isValidTypeAuth(DIGEST)) { if (checkMD5(requestAuth)) { serverAuthMap.remove(requestAuth.getNonce()); return true...
@Test public void testCheck() throws Exception { System.out.println("check"); boolean expResult = true; DigestAuth auth = new DigestAuth(); String header = "Basic YWRtaW46cGFzc3dvcmQ="; auth.createResponseAuth(DigestAuth.BASIC,"admin",""); auth.getResponseAuth("admin").setUsername("admin"); auth.getResponseAuth("admin"...
DigestAuth { public boolean checkMD5(ClientAuth clientAuth) { if (!isValidTypeAuth(DIGEST)){ return false; } if (!isValidAlgoritm("MD5")){ return false; } ServerAuth serverAuth = getResponseAuth(clientAuth.getNonce()); if (!compareServerAndClientAuth(clientAuth, serverAuth)) { return false; } String result = ""; String...
@Test public void testCheckMD5() throws Exception{ String header = "Digest username=\"admin\", realm=\"ldap\", nonce=\"f09cecf114d72dcb1ba99e02ac448687\", " + "uri=\"/digest-auth\", response=\"aac60f90b7712c712735645b9cbbc767\", opaque=\"\""; DigestAuth auth = new DigestAuth(); auth.createResponseAuth(DigestAuth.DIGEST...
DigestAuth { public String getResponseHeader(ServerAuth responseAuth) { String value = ""; value = type; if (type.equalsIgnoreCase("Basic")) { value += " realm=\"Restricted\""; return value; } String opaque = responseAuth.getOpaque(); String nonce = responseAuth.getNonce(); String nc = ((Integer) responseAuth.getNonceC...
@Test public void testGetResponseHeader() throws Exception{ DigestAuth auth = new DigestAuth(DigestAuth.BASIC, "", ""); String expResult = "Basic realm=\"Restricted\""; ServerAuth serverAuth = auth.createResponseAuth(); String result = auth.getResponseHeader(serverAuth); assertEquals(expResult, result); auth = new Dige...
DigestAuth { public void purgeResponseAuth() { Date now = DateUtils.addSeconds(Dates.now(), secondsIdle * -1); for (Iterator<Map.Entry<String, ServerAuth>> it = serverAuthMap.entrySet().iterator(); it.hasNext();) { Map.Entry<String, ServerAuth> entry = it.next(); if (entry.getValue().getLastReference().before(now)) { i...
@Test public void purgeResponseAuth() throws Exception{ System.out.println("purgeResponseAuth"); DigestAuth auth = new DigestAuth(); auth.setSecondsIdle(1); for (int i = 0;i <= 500;i++){ auth.createResponseAuth(DigestAuth.BASIC,""+i,""); } Thread.sleep(2000); auth.purgeResponseAuth(); for (int i = 0;i <= 500;i++){ Serv...
OAuthConsumer extends OAuthConsumerBase { @Override public Class<IAppAuthConsumer> getAuthConsumerClass() { try { return (Class<IAppAuthConsumer>) Class.forName("org.javabeanstack.model.appcatalog.AppAuthConsumer"); } catch (ClassNotFoundException ex) { System.out.println(ex.getMessage()); } return null; } @Override C...
@Test public void test00InstanceClass() throws InstantiationException, IllegalAccessException{ OAuthConsumerBase instance = new OAuthConsumerImpl(); IAppAuthConsumer consumer = instance.getAuthConsumerClass().newInstance(); assertNotNull(consumer); }
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public <T extends IDataRow> List<T> findListByNamedQuery(String sessionId, String namedQuery, Map<String, Object> parameters) throws Exception { return findListByNamedQuery(sessionId, namedQuery, parameters, 0, 0); }...
@Test public void test07FindByNamedQuery() throws Exception { System.out.println("7-AbstractDAO - findByNamedQuery"); String sessionid = null; if (error != null) { System.out.println(error); return; } List<AppTablesRelation> prueba = dao.findListByNamedQuery(sessionid, "AppTablesRelation.findAll", null); assertTrue(!pr...
AbstractDataObject implements IDataObject, Serializable { @Override public Long getIdcompany() { Long idempresa = 0L; if (getDAO().getUserSession() != null) { idempresa = getDAO().getUserSession().getIdCompany(); } return idempresa; } @Override boolean isReadwrite(); @Override abstract IDataLink getDAO(); @Override ab...
@Test public void test21GetIdcompany() { System.out.println("21-DataObject - getIdcompany"); if (error != null) { System.out.println(error); return; } IDataObject<Region> region = new DataObject(Region.class, null, dataLink, null); assertEquals(dataLink.getUserSession().getIdCompany(),region.getIdcompany()); }
AbstractDataObject implements IDataObject, Serializable { @Override public boolean open() { order = ""; filter = ""; filterExtra = ""; firstRow = 0; maxrows = -1; return this.open("", "", true, -1); } @Override boolean isReadwrite(); @Override abstract IDataLink getDAO(); @Override abstract IDataLink getDAOCatalog(); ...
@Test public void test24BeforeOpen() { System.out.println("24-DataObject - beforeOpen"); if (error != null) { System.out.println(error); return; } DataEventsTest dataEvents = new DataEventsTest(); IDataObject<Region> region = new DataObject(Region.class, dataEvents, dataLink, null); region.open(); assertTrue(dataEvents...
AbstractDataObject implements IDataObject, Serializable { @Override public boolean isFieldExist(String fieldname) { return DataInfo.isFieldExist(this.getType(), fieldname); } @Override boolean isReadwrite(); @Override abstract IDataLink getDAO(); @Override abstract IDataLink getDAOCatalog(); @Override IDataEvents getD...
@Test public void test56IsFieldExist() { System.out.println("56-DataObject - isFieldExist"); if (error != null) { System.out.println(error); return; } IDataObject<Region> region = new DataObject(Region.class, null, dataLink, null); assertTrue(region.isFieldExist("codigo")); assertFalse(region.isFieldExist("noexiste"));...
AbstractDataObject implements IDataObject, Serializable { @Override public boolean isForeingKey(String fieldname) { return DataInfo.isForeignKey(this.getType(), fieldname); } @Override boolean isReadwrite(); @Override abstract IDataLink getDAO(); @Override abstract IDataLink getDAOCatalog(); @Override IDataEvents getD...
@Test public void test57IsForeingKey() { System.out.println("57-DataObject - isForeingKey"); if (error != null) { System.out.println(error); return; } IDataObject<Pais> pais = new DataObject(Pais.class, null, dataLink, null); assertTrue(pais.isForeingKey("region")); assertFalse(pais.isForeingKey("codigo")); assertFalse...
CipherUtil { public static String encryptBlowfishToHex(String clearText, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { return encryptToHex(CipherUtil.BLOWFISH, clearText, key); } private CipherUti...
@Test public void testEncryptBlowfishToHex() throws Exception { System.out.println("encryptBlowfishToHex"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "123456á"; String expResult = clearText; String encrypted = CipherUtil.encryptBlowfishToHex(clearText, key); String decrypted = CipherUtil.decry...
CipherUtil { public static String decryptBlowfishFromHex(String encrypted, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, UnsupportedEncodingException { return decryptFromHex(CipherUtil.BLOWFISH, encrypted, key); } private Ciphe...
@Test public void testDecryptBlowfishFromHex() throws Exception { System.out.println("decryptBlowfishFromHex"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "123456Á"; String expResult = clearText; String encrypted = CipherUtil.encryptBlowfishToHex(clearText, key); String decrypted = CipherUtil.d...
CipherUtil { public static String encryptBlowfishToBase64(String clearText, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { return encryptToBase64(CipherUtil.BLOWFISH, clearText, key); } private Cip...
@Test public void testEncryptBlowfishToBase64() throws Exception { System.out.println("encryptBlowfishToBase64"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "123456á"; String expResult = clearText; String encrypted = CipherUtil.encryptBlowfishToBase64(clearText, key); System.out.println(encrypt...
CipherUtil { public static String decryptBlowfishFromBase64(String encrypted, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException, UnsupportedEncodingException { return decryptFromBase64(CipherUtil.BLOWFISH, encrypted, key); } private ...
@Test public void testDecryptBlowfishFromBase64() throws Exception { System.out.println("decryptBlowfishFromBase64"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "123456á"; String expResult = clearText; String encrypted = CipherUtil.encryptBlowfishToBase64(clearText, key); String decrypted = Cip...
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public Long getCount(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { LOGGER.debug(Strings.replicate("-", 50)); LOGGER.debug("getCount"); IDBLinkInfo dbLinkInfo = sessions.getD...
@Test public void test14GetCount() throws Exception { System.out.println("14-AbstractDAO - getCount"); String sessionid = null; if (error != null) { System.out.println(error); return; } Long rec = dao.getCount(sessionid, "select o FROM AppCompany o", null); assertTrue(rec > 0L); }
CipherUtil { public static byte[] encryptAES(String clearText, String key) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { return encrypt_AES_CBC(clearText, key); } private C...
@Test public void testEncryptAES() throws Exception{ System.out.println("encryptAES"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "012345678901234567890123456789á"; String expResult = clearText; byte[] encrypted = CipherUtil.encryptAES(clearText, key); String decrypted = CipherUtil.decryptAES(e...
CipherUtil { public static String decryptAES(byte[] encrypted, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { return new String(decrypt_AES_CBC(encrypted, key)); } private CipherUtil(); stati...
@Test public void testDecryptAES() throws Exception{ System.out.println("decryptAES"); byte[] text = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyzáéíóú".getBytes(); String clearText = new String(text); String key = "012345678901234567890123456789á"; String expResult = clearText; byte[] encrypted = CipherUtil....
CipherUtil { public static String encryptAES_ToHex(String clearText, String key) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { return Fn.bytesToHex(encrypt_AES_CBC(clearText...
@Test public void testEncryptAES_ToHex() throws Exception { System.out.println("encryptAES_ToHex"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "012345678901234567890123456789"; String expResult = clearText; String encrypted = CipherUtil.encryptAES_ToHex(clearText, key); String decrypted = Ciphe...
CipherUtil { public static String encryptAES_ToBase64(String clearText, String key) throws UnsupportedEncodingException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { return Fn.bytesToBase64(encrypt_AES_CBC(cle...
@Test public void testEncryptAES_ToBase64() throws Exception { System.out.println("encryptAES_ToBase64"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "012345678901234567890123456789"; String expResult = clearText; String encrypted = CipherUtil.encryptAES_ToBase64(clearText, key); String decrypte...
CipherUtil { public static String decryptAES_FromHex(String encryptedHex, String key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { return new String(decrypt_AES_CBC(Fn.hexToByte(encryptedHex), key)); } ...
@Test public void testDecryptAES_FromHex() throws Exception { System.out.println("decryptAES_FromHex"); String clearText = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "012345678901234567890123456789"; String expResult = clearText; String encrypted = CipherUtil.encryptAES_ToHex(clearText, key); String decrypted = C...
CipherUtil { public static SecretKey getSecureRandomKey(String algoritm, int keyBitSize) throws NoSuchAlgorithmException { KeyGenerator keyGenerator = KeyGenerator.getInstance(algoritm); SecureRandom secureRandom = new SecureRandom(); keyGenerator.init(keyBitSize, secureRandom); return keyGenerator.generateKey(); } pri...
@Test public void testGetSecureRandomKey_String_int() throws Exception { System.out.println("getSecureRandomKey"); String algoritm = "AES"; int keyBitSize = 256; SecretKey result = CipherUtil.getSecureRandomKey(algoritm, keyBitSize); assertNotNull(result); } @Test public void testGetSecureRandomKey_String() throws Exce...
DigestUtil { public static String md5(String msg) { try { return digestToHex("MD5", msg); } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private DigestUtil(); static String md5(String msg); static String sha256(String m...
@Test public void testMd5() throws Exception { System.out.println("md5"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String expResult = "5AD6F23DA25B3A54CD5AE716C401732D"; String result = DigestUtil.md5(msg).toUpperCase(); assertEquals(expResult, result); } @Test public void testDigestAuth_MD5() throws Exception ...
DigestUtil { public static String sha256(String msg){ try { return digestToHex("SHA-256", msg); } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private DigestUtil(); static String md5(String msg); static String sha256(St...
@Test public void testSha256() throws Exception { System.out.println("sha256"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String expResult = "4D9DC750077F316B7A9D2D5C4890B1D79ABC7B7C4261D7090CBF58501E2F723B"; String result = DigestUtil.sha256(msg).toUpperCase(); System.out.println(result); assertEquals(expResult...
DigestUtil { public static String sha512(String msg) { try { return digestToHex("SHA-512", msg); } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private DigestUtil(); static String md5(String msg); static String sha256(S...
@Test public void testSha512() throws Exception { System.out.println("sha512"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String expResult = "8CABE293B89951C158AC9B56ECDD518060BE89CB760ED7AD04CF72B9F10EB38401A8959E6CFCD3146A6A02AC126D76B3DAD653500239EF8A6BB4106238B9C37C"; String result = DigestUtil.sha512(msg).t...
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public Long getCount2(String sessionId, String queryString, Map<String, Object> parameters) throws Exception { LOGGER.debug(Strings.replicate("-", 50)); LOGGER.debug("getCount2"); IDBLinkInfo dbLinkInfo = sessions.ge...
@Test public void test15GetCount2() throws Exception { System.out.println("15-AbstractDAO - getCount2"); String sessionid = null; if (error != null) { System.out.println(error); return; } Long rec = dao.getCount2(sessionid, "select * FROM {schema}.empresa", null); assertTrue(rec > 0L); }
DigestUtil { public static String digestToHex(String algorithm, String msg) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest digest = MessageDigest.getInstance(algorithm); byte[] digestMessage = digest.digest(msg.getBytes("UTF-8")); return Fn.bytesToHex(digestMessage); } private DigestUtil...
@Test public void testDigestToHex() throws Exception { System.out.println("digestToHex"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String expResult = "8DD69CB915630B3DDE248FC13DBA97547BCED31E"; String result = DigestUtil.digestToHex(DigestUtil.SHA1, msg).toUpperCase(); assertEquals(expResult, result); expResult...
DigestUtil { public static String hmacSHA1(String msg, String key) { try { return digestHmacToHex("HmacSHA1", msg, key.getBytes("UTF-8")); } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private Dig...
@Test public void testHmacSha1() throws Exception { System.out.println("sha1"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "añ"; String expResult = "766efadbefecb8313cdd42f3d983b60707e019f7"; String result = DigestUtil.hmacSHA1(msg, key); System.out.println(result); assertEquals(expResult, result); }
DigestUtil { public static String hmacSHA256(String msg, String key) { try { return digestHmacToHex("HmacSHA256", msg, key.getBytes("UTF-8")); } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private ...
@Test public void testHmacSha256() throws Exception { System.out.println("sha256"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "añ"; String expResult = "efbc7d9e22c2e7063b929003a7e3b5469259175072c9e115636a86d5c7f198a6"; String result = DigestUtil.hmacSHA256(msg, key); System.out.println(result); asse...
DigestUtil { public static String hmacSHA512(String msg, String key) { try { return digestHmacToHex("HmacSHA512", msg, key.getBytes("UTF-8")); } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private ...
@Test public void testHmacSha512() throws Exception { System.out.println("sha512"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "añ"; String expResult = "873e13ff8d5a20104b2d6ddfbd1de7372f065e7a344cffa729f30b71c54df944416ced9cd7d62e2dad0b87806ed57d230487e5a492c67a5034ee3d4dd900cd5f"; String result = D...
DigestUtil { public static String hmacMD5(String msg, String key) { try { return digestHmacToHex("HmacMD5", msg, key.getBytes("UTF-8")); } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException ex) { Logger.getLogger(DigestUtil.class).error(ex.getMessage()); } return null; } private Diges...
@Test public void testHmacMD5() throws Exception { System.out.println("sha256"); String msg = "abcdefghijklmnñopqrstuvwxyzáéíóú"; String key = "añ"; String expResult = "2eab3f12c1db4b4f253c109281c0d3f8"; String result = DigestUtil.hmacMD5(msg, key); System.out.println(result); assertEquals(expResult, result); }
AbstractDAO implements IGenericDAO { @Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public Map<String, Object> getEntityManagerProp(String persistUnit) { EntityManager em = getEntityManager(getEntityId(persistUnit)); if (em == null) { LOGGER.info("Entity Manager Nulo"); return null; } return em.getP...
@Test public void test16GetEntityManagerProp() { System.out.println("16-AbstractDAO - getEntityManagerProp"); if (error != null) { System.out.println(error); return; } Map<String, Object> props = dao.getEntityManagerProp("PU1"); assertNotNull(props); }
IncrementUpdateAction extends SingleFieldUpdateAction implements ResolvedCallback<Boolean> { @Override public void apply(UpdatedToroDocumentBuilder builder) throws UpdateException { for (AttributeReference key : getModifiedField()) { if (increment(new ObjectBuilderCallback(builder), key, delta)) { builder.setUpdate...
@Test public void testNormal() throws UpdateException { UpdatedToroDocumentBuilder builder = UpdatedToroDocumentBuilder.create(); builder.newObject("f1") .newArray("f2") .setValue(3, KvInteger.of(3)); new IncrementUpdateAction( Lists.<AttributeReference>newArrayList(new AttributeReference( Lists.<AttributeReference.Key...
AbstractAnalyzedOp extends AnalyzedOp { @Override public AnalyzedOpType getType() { return type; } AbstractAnalyzedOp(KvValue<?> mongoDocId, AnalyzedOpType type, @Nullable Function<KvDocument, KvDocument> calculateFun); @Override abstract String toString(); @Override AnalyzedOpType getType(); @Override KvValue<?>...
@Test public void requiresToFetchToroIdTest() { AnalyzedOp op = getAnalyzedOp(defaultMongoDocId); assertEquals("", op.getType().requiresToFetchToroId(), op.requiresToFetchToroId()); } @Test public void requiresMatchTest() { AnalyzedOp op = getAnalyzedOp(defaultMongoDocId); assertEquals("", op.getType().requiresMatch(),...
ContinuousOplogFetcher implements OplogFetcher { @Override public OplogBatch fetch() throws StopReplicationException, RollbackReplicationException { if (state.isClosed()) { return FinishedOplogBatch.getInstance(); } try { return retrier.retry(() -> { try { if (state.isClosed()) { return FinishedOplogBatch.getInstance()...
@Test(expected = StopReplicationException.class) public void testEmptyOplog() throws Exception { List<OplogOperation> oplog = Collections.emptyList(); oplogSupplier = () -> oplog; ContinuousOplogFetcher fetcher = factory.createFetcher(0, OpTime.EPOCH); fetcher.fetch(); } @Test(expected = RollbackReplicationException.cl...
AbstractMongoOplogReader implements OplogReader { @Override public MongoCursor<OplogOperation> queryGte(OpTime lastFetchedOpTime) throws MongoException { BsonDocument query = DefaultBsonValues.newDocument( "ts", DefaultBsonValues.newDocument("$gte", lastFetchedOpTime.getTimestamp()) ); EnumSet<QueryOption> flags = Enum...
@Test public void testQueryGTE() throws Exception { }
AbstractMongoOplogReader implements OplogReader { @Override public OplogOperation getLastOp() throws OplogStartMissingException, OplogOperationUnsupported, MongoException { return getFirstOrLastOp(false); } @Override MongoCursor<OplogOperation> queryGte(OpTime lastFetchedOpTime); @Override OplogOperation getLastOp(); ...
@Test public void testGetLastOp() throws Exception { }
AbstractMongoOplogReader implements OplogReader { @Override public OplogOperation getFirstOp() throws OplogStartMissingException, OplogOperationUnsupported, MongoException { return getFirstOrLastOp(true); } @Override MongoCursor<OplogOperation> queryGte(OpTime lastFetchedOpTime); @Override OplogOperation getLastOp(); ...
@Test public void testGetFirstOp() throws Exception { }
AbstractMongoOplogReader implements OplogReader { @Override public MongoCursor<OplogOperation> between( OpTime from, boolean includeFrom, OpTime to, boolean includeTo) throws MongoException { BsonArrayBuilder conditions = new BsonArrayBuilder(); conditions.add( DefaultBsonValues.newDocument( "ts", DefaultBsonValues.new...
@Test public void testBetween() throws Exception { }
AbstractMongoOplogReader implements OplogReader { public MongoCursor<OplogOperation> query(BsonDocument query, EnumSet<QueryOption> flags, BsonDocument sortBy) throws MongoException { Preconditions.checkState(!isClosed(), "You have to connect this client before"); MongoConnection connection = consumeConnection(); Mongo...
@Test public void testQuery() throws Exception { }
SimpleRegExpDecoder { public static Pattern decode(String simpleRegExp) { StringBuilder resultPatternBuilder = new StringBuilder(); boolean quoted = false; final int length = simpleRegExp.length(); for (int index = 0; index < length; index++) { char simpleRegExpChar = simpleRegExp.charAt(index); if (simpleRegExpChar ==...
@Test public void decodeTest() { Assert .assertEquals("\\Qmine_and_your\\E", SimpleRegExpDecoder.decode("mine_and_your").pattern()); Assert.assertEquals("\\Qmine_\\E.*\\Q_your\\E", SimpleRegExpDecoder.decode("mine_*_your") .pattern()); Assert.assertEquals("\\Qmine_*_your\\E", SimpleRegExpDecoder.decode("mine_\\*_your")...
BatchMetaDocPart implements MutableMetaDocPart { @Override public ImmutableMetaField addMetaField(String name, String identifier, FieldType type) throws IllegalArgumentException { ImmutableMetaField newMetaField = delegate.addMetaField(name, identifier, type); fieldsChangesOnBatch.add(newMetaField); changeConsumer.acce...
@Test public void testAddMetaField() { String fieldName = "aFieldName"; String fieldId = "aFieldID"; FieldType fieldType = FieldType.INTEGER; assertNull(delegate.getMetaFieldByIdentifier(fieldId)); assertNull(delegate.getMetaFieldByNameAndType(fieldName, fieldType)); assertNull(docPart.getMetaFieldByIdentifier(fieldId)...