use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ClusterDaoTest method testXmlFileNotFound.
@Ignore
@Test
public void testXmlFileNotFound() {
String testXmlPath = "./src/resources/";
xmlFileLoader.setXmlPath(testXmlPath);
try {
clusterDao.afterPropertiesSet();
} catch (Exception e) {
e.printStackTrace();
}
ClusterDO cluster = DOFactory.getCluster();
clusterDao.addCluster(cluster);
Assert.assertNull(clusterDao.getClusterById(1L));
xmlFileLoader.setXmlPath(testXmlPath);
try {
clusterDao.afterPropertiesSet();
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertNull(clusterDao.getClusterById(1L));
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class ClusterDaoTest method testModifyClusterNameToExistName.
@Test
public void testModifyClusterNameToExistName() {
int insertClusterNum = 3;
for (int i = 0; i < insertClusterNum; i++) {
ClusterDO cluster = DOFactory.getCluster();
cluster.setName("test" + i);
clusterDao.addCluster(cluster);
}
ClusterDO clusterTemp = clusterDao.getClusterById(1);
clusterTemp.setName("test1");
Assert.assertFalse(clusterDao.modifyCluster(clusterTemp));
read();
clusterTemp = clusterDao.getClusterById(1);
Assert.assertEquals("test0", clusterTemp.getName());
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class XmlFile method initCluster.
private void initCluster() {
String path = this.xmlPath + System.getProperty("file.separator") + "cluster.xml";
init(path, "clusters");
ClusterDAOImple clusterDAO = new ClusterDAOImple();
clusterDAO.setXmlFileLoader(xmlFileLoader);
try {
clusterDAO.afterPropertiesSet();
} catch (Exception e) {
logger.error(e.getMessage(), e);
Assert.fail();
}
ClusterDO cluster = new ClusterDO();
cluster.setDeployContact("utest");
cluster.setDeployDesc("utest");
cluster.setMaintContact("utest");
cluster.setName("cluster");
cluster.setOnlineTime("2011-01-01");
clusterDAO.addCluster(cluster);
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class DOFactory method getCluster.
public static ClusterDO getCluster() {
ClusterDO cluster = new ClusterDO();
cluster.setDeployContact("deployContact");
cluster.setDeployDesc("deployDesc");
cluster.setMaintContact("13456789123");
cluster.setName("name");
cluster.setOnlineTime("OnlineTime");
return cluster;
}
use of com.alibaba.cobar.manager.dataobject.xml.ClusterDO in project cobar by alibaba.
the class AddCobarPage method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
UserDO user = (UserDO) request.getSession().getAttribute("user");
long clusterId = Long.parseLong(request.getParameter("clusterId"));
List<ClusterDO> cList;
if (-1 == clusterId) {
cList = this.xmlAccesser.getClusterDAO().listAllCluster();
} else {
ClusterDO cluster = xmlAccesser.getClusterDAO().getClusterById(clusterId);
if (null == cluster) {
logger.error("cluster doesn't exsit by id : " + clusterId);
}
cList = new ArrayList<ClusterDO>();
cList.add(cluster);
}
ListSortUtil.sortClusterByName(cList);
List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
for (ClusterDO e : cList) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", e.getId());
map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
clusterList.add(map);
}
return new ModelAndView("m_addCobar", new FluenceHashMap<String, Object>().putKeyValue("cList", clusterList).putKeyValue("user", user));
}
Aggregations