Project

General

Profile

Revision beb18173

IDbeb1817395363f32851c4554649618574d7c1155
Parent a0d6f613
Child eeafa6f5

Added by Andreas Müller about 1 year ago

adapt TestModelUpdate to run for all 3 H2 DBs

View differences:

cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestModelUpdate.java
42 42

  
43 43

  
44 44
	private void testSelectedDb(){
45
		DbSchemaValidation schema = DbSchemaValidation.VALIDATE;
45
		DbSchemaValidation schema = DbSchemaValidation.CREATE;
46 46

  
47 47
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
48 48

  
......
84 84
 		    e.printStackTrace();
85 85
 		}
86 86
 		System.out.println("Ready");
87
		System.exit(0);
88 87
	}
89 88

  
90 89

  
......
132 131
	@SuppressWarnings("unused")  //enable only if needed
133 132
	private void updateRemoteWebappTestH2(){
134 133
	    String pathToProject = "C:\\Users\\a.mueller\\eclipse\\git\\cdmlib\\cdmlib-remote-webapp\\";
135
//	    String pathToProject = "C:\\Users\\a.mueller\\eclipse\\git\\cdm-vaadin\\";
136
//	    String pathToProject = "C:\\Users\\a.mueller\\eclipse\\git\\taxeditor2\\eu.etaxonomy.taxeditor.test\\";
134
	    updateH2(pathToProject);
135
	}
136

  
137
    /**
138
     * Updates the H2 test database in TaxEditor.
139
     * Requires that the local path to the database is adapted
140
     */
141
    @SuppressWarnings("unused")  //enable only if needed
142
    private void updateTaxEditorH2(){
143
        String pathToProject = "C:\\Users\\a.mueller\\eclipse\\git\\taxeditor2\\eu.etaxonomy.taxeditor.test\\";
144

  
145
        updateH2(pathToProject);
146
    }
147

  
148
    /**
149
     * Updates the H2 test database in CDM vaadin.
150
     * Requires that the local path to the database is adapted
151
     */
152
    @SuppressWarnings("unused")  //enable only if needed
153
    private void updateVaadinH2(){
154
        String pathToProject = "C:\\Users\\a.mueller\\eclipse\\git\\cdm-vaadin\\";
155

  
156
        updateH2(pathToProject);
157
    }
137 158

  
138
	    String pathInProject = "src\\test\\resources\\h2";
159

  
160
    /**
161
     * @param pathToProject
162
     */
163
    private void updateH2(String pathToProject) {
164
        String pathInProject = "src\\test\\resources\\h2";
139 165

  
140 166
	    String path = pathToProject + pathInProject;
141 167
		ICdmDataSource dataSource = CdmDataSource.NewH2EmbeddedInstance("cdmTest", "sa", "", path);
......
154 180
		appCtr = CdmApplicationController.NewInstance(dataSource,DbSchemaValidation.VALIDATE);
155 181
		appCtr.close();
156 182
		System.out.println("\nEnd Datasource");
157
		System.exit(0);
158
	}
183
    }
184

  
185

  
186
    @SuppressWarnings("unused")  //enable only if needed
187
    private void updateEdaphobasePostgres(){
188
       String serverSql = "130.133.70.26";
189
       String database = "cdm_edaphobase";
190
       int port = 5433;
191
       String username = "edaphobase";
192
       String password = AccountStore.readOrStorePassword(database, serverSql, username, null);
193

  
194
       ICdmDataSource dataSource = CdmDataSource.NewPostgreSQLInstance(serverSql,
195
                database, port, username, password);
196

  
197
        try {
198
            CdmUpdater updater = new CdmUpdater();
199
            SchemaUpdateResult result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
200
            System.out.println(result.createReport());
201
        } catch (Exception e) {
202
            e.printStackTrace();
203
        }
159 204

  
160
	   @SuppressWarnings("unused")  //enable only if needed
161
	    private void updateEdaphobasePostgres(){
162
	       String serverSql = "130.133.70.26";
163
	       String database = "cdm_edaphobase";
164
	       int port = 5433;
165
	       String username = "edaphobase";
166
	       String password = AccountStore.readOrStorePassword(database, serverSql, username, null);
167

  
168
	       ICdmDataSource dataSource = CdmDataSource.NewPostgreSQLInstance(serverSql,
169
	                database, port, username, password);
170

  
171
	        try {
172
	            CdmUpdater updater = new CdmUpdater();
173
	            SchemaUpdateResult result = updater.updateToCurrentVersion(dataSource, DefaultProgressMonitor.NewInstance());
174
	            System.out.println(result.createReport());
175
	        } catch (Exception e) {
176
	            e.printStackTrace();
177
	        }
178

  
179
	        //CdmPersistentDataSource.save(dataSource.getName(), dataSource);
180
	        CdmApplicationController appCtr;
181
	        appCtr = CdmApplicationController.NewInstance(dataSource,DbSchemaValidation.VALIDATE);
182
	        appCtr.close();
183
	        System.out.println("\nEnd Datasource");
184
	        System.exit(0);
185
	    }
205
        //CdmPersistentDataSource.save(dataSource.getName(), dataSource);
206
        CdmApplicationController appCtr;
207
        appCtr = CdmApplicationController.NewInstance(dataSource,DbSchemaValidation.VALIDATE);
208
        appCtr.close();
209
        System.out.println("\nEnd Datasource");
210
    }
186 211

  
187 212

  
188 213
	private void test(){
......
190 215
		testSelectedDb();
191 216

  
192 217
//		updateRemoteWebappTestH2();  //also updates vaadin and taxeditor model
218
//		updateAllTesetH2();
193 219
//      updateEdaphobasePostgres();
194 220

  
195 221
		System.out.println("\nEnd Datasource");
196 222
	}
197 223

  
198 224
	/**
225
     * Updates all
226
     */
227
    private void updateAllTesetH2() {
228
        updateRemoteWebappTestH2();
229
        updateTaxEditorH2();
230
        updateVaadinH2();
231
    }
232

  
233

  
234

  
235
    /**
199 236
	 * @param args
200 237
	 */
201 238
	public static void  main(String[] args) {
202 239
		TestModelUpdate cc = new TestModelUpdate();
203 240
    	cc.test();
241
    	System.exit(0);
204 242
	}
205 243

  
206 244
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)