Search Results

Search found 2673 results on 107 pages for 'michael maddox'.

Page 88/107 | < Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >

  • Setup database for Unit tests with Spring, Hibernate and Spring Transaction Support

    - by Michael Bulla
    I want to test integration of dao-layer with my service-layer in a unit-test. So I need to setup some data in my database (hsql). For this setup I need an own transaction at the begining of my testcase to ensure that all my setup is really commited to database before starting my testcase. So here's what I want to achieve: // NotTranactional public void doTest { // transaction begins setup database // commit transaction service.doStuff() // doStuff is annotated @Transactional(propagation=Propagation.REQUIRED) } Here is my not working code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"/asynchUnit.xml"}) @DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD) public class ReceiptServiceTest implements ApplicationContextAware { @Autowired(required=true) private UserHome userHome; private ApplicationContext context; @Before @Transactional(propagation=Propagation.REQUIRED) public void init() throws Exception { User user = InitialCreator.createUser(); userHome.persist(user); } @Test public void testDoSomething() { ... } } Leading to this exception: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63) at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687) at de.diandan.asynch.modell.GenericHome.getSession(GenericHome.java:40) at de.diandan.asynch.modell.GenericHome.persist(GenericHome.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at $Proxy28.persist(Unknown Source) at de.diandan.asynch.service.ReceiptServiceTest.init(ReceiptServiceTest.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) I dont know whats the right way to get the transaction around setup database. What I tried: @Before @Transactional(propagation=Propagation.REQUIRED) public void setup() { setup database } - Spring seems not to start transaction in @Before-annotated methods. Beyond that, thats not what I really want, cause there are a lot merhods in my testclass which needs a slightly differnt setup, so I need several of that init-methods. @Transactional(propagation=Propagation.REQUIRED) public void setup() { setup database } public void doTest { init(); service.doStuff() // doStuff is annotated @Transactional(propagation=Propagation.REQUIRED) } -- init seems not to get started in transaction What I dont want to do: public void doTest { // doing my own transaction-handling setup database // doing my own transaction-handling service.doStuff() // doStuff is annotated @Transactional(propagation=Propagation.REQUIRED) } -- start mixing springs transaction-handling and my own seems to get pain in the ass. @Transactional(propagation=Propagation.REQUIRED) public void doTest { setup database service.doStuff() } -- I want to test as real as possible situation, so my service should start with a clean session and no transaction opened So whats the right way to setup database for my testcase?

    Read the article

  • Problem with thread after SCREEN_OFF in Android

    - by michael
    I’m doing an application that listens to the android.intent.action.SCREEN_OFF in a Service (if that matter) and then it is supposed to wait a few seconds and launch an action, I’ve tried a timer schedule method, thread and handler postDelay method but all of them seems to fail, they are never executed on a device, it seems like it’s being freezed/killed after phone is locked. It works on emulator and on device attached to USB, but never with device working on battery only, which actually is a main scenario. Do you know any solutions to this?

    Read the article

  • Script-Based Configuration in .net?

    - by Michael Stum
    One of the downsides of web.config/app.config is that it's just Magic Strings everywhere, since it's just an XML file. Interpreted languages like PHP or Ruby have the advantage that the configuration is just code that is executed. In .net, doing stuff in code requires a redeployment, which defeats the purpose. Now, before I build my own web.config replacement based on Boo or PowerShell I wanted to know if there is an existing one?

    Read the article

  • What should be DefaultLocation property of VS2010 setup to install application in C:\Users\[username

    - by Michael
    I have to install windows service using Visual Studio. Target location for the install is handled by “DefaultLocation” property in Visual Studio setup project. I had used [AppDataFolder] tag to install the application. As the result, it has been installed in “C:\Users[username]\AppData*Roaming*” folder. I can not figure out how to modify “DefaultLocation” property in such a way that application will be installed in C:\Users[username]\AppData*Local* folder. Any idea how to accomplish that?

    Read the article

  • How do I show the selected item in an HTML <select> at the top

    - by Michael Meadows
    I have an HTML select that looks something like this (values are fake) <select size="40"> <option value="1">What would you do if I sang out of tune,</option> <option value="2">Would you stand up and walk out on me?</option> ... more <option value="156">Lend me your ears, and I'll sing you a song,</option> <option selected="selected" value="157">I will try not to sing out of key.</option> <option value="158">Oh, I get by with a little help from my friends.</option> ... more <option value="507">I get high with a little help from my friends.</option> <option value="509">Gonna' try with a little from my friends.</option> </select> The problem that I have is that when displaying the list after loading the page and the selected option is in the middle of the very long list, IE scrolls the selected option to the top of the list (which is what I want). Firefox, Chrome, Opera, and Safari show it at the bottom (which I don't want). I have to assume that IE is doing it wrong since everyone else shows it at the bottom. How can I force the browsers to display the selected item at the top of the list. I do not want to put it at the top of the list, I just want it to scroll such that the selected option is at the top. bonus, it would be even better if I can put it fourth from the top, but I can live without that if it's too difficult.

    Read the article

  • javascript simple question

    - by Michael
    window.addEventListener('unload', function(e) { MyClass.shutdown(); window.removeEventListener('unload', /* how to reference the function itself here? */); }, false); The question in the comment.

    Read the article

  • GDI+ not clearing my window on repaint for vista

    - by Michael
    on WM_PAINT i do the following: //RectF mNameRect; //WCHAR* mName; //HWND mWin; // this is the window handle { PAINTSTRUCT ps; HDC hdc = BeginPaint(mWin, &ps); Graphics g(hdc); g.Clear(Color::White); StringFormat stringForm; stringForm.SetLineAlignment(StringAlignmentCenter); stringForm.SetAlignment(StringAlignmentCenter); // set the rectangle to the size of the whole window mNameRect.Width = static_cast<float>(size.cx); mNameRect.Height = static_cast<float>(size.cy); g.DrawString(mName, -1, &mNameFont, mNameRect, &stringForm, &mNameBrush); EndPaint(mWin, &ps); } In XP this works fine, the mName is displayed in the middle of the window. However on Vista the text doesn't move, it stays in its location no matter how I resize the window. the g.Clear(Color::White) doesn't seem to do any difference. The text doesn't even change position when the window is hidden behind another window and on focus needs to be repainted again. How do I make mName change position in Vista?

    Read the article

  • When can I find out the width/height of my view

    - by michael
    When is the earliest I can find out the actual (after layout) width/height of my view? I tried to do that @Override protected void onFinishInflate() { super.onFinishInflate(); w = getWidth(); h = getHeight(); } But it gives me 0. I have cases in which the view is invisible in the beginning and that programmically become visible. I think I can do that in onDraw(), but i dont' want to do that in everything I draw() something.

    Read the article

  • Best way to run multiple queries per second on database, performance wise?

    - by Michael Joell
    I am currently using Java to insert and update data multiple times per second. Never having used databases with Java, I am not sure what is required, and how to get the best performance. I currently have a method for each type of query I need to do (for example, update a row in a database). I also have a method to create the database connection. Below is my simplified code. public static void addOneForUserInChannel(String channel, String username) throws SQLException { Connection dbConnection = null; PreparedStatement ps = null; String updateSQL = "UPDATE " + channel + "_count SET messages = messages + 1 WHERE username = ?"; try { dbConnection = getDBConnection(); ps = dbConnection.prepareStatement(updateSQL); ps.setString(1, username); ps.executeUpdate(); } catch(SQLException e) { System.out.println(e.getMessage()); } finally { if(ps != null) { ps.close(); } if(dbConnection != null) { dbConnection.close(); } } } And my DB connection private static Connection getDBConnection() { Connection dbConnection = null; try { Class.forName(DB_DRIVER); } catch (ClassNotFoundException e) { System.out.println(e.getMessage()); } try { dbConnection = DriverManager.getConnection(DB_CONNECTION, DB_USER,DB_PASSWORD); return dbConnection; } catch (SQLException e) { System.out.println(e.getMessage()); } return dbConnection; } This seems to be working fine for now, with about 1-2 queries per second, but I am worried that once I expand and it is running many more, I might have some issues. My questions: Is there a way to have a persistent database connection throughout the entire run time of the process? If so, should I do this? Are there any other optimizations that I should do to help with performance? Thanks

    Read the article

  • How to change the text of a div tag

    - by michael
    Hi, I have a simple div tag. Can you please tell me how can I change the text to 'mouse in' in my onmouseover handler? and 'mouse out' in my onmouseout handler? <div id="div1" onmouseover="alert(1);" width="100px" height="200px" border="1"> test </div> and why the width/height and border attributes do not work? I want to set the border to be 1 pixel with width = 100 pixels and height = 200 pixels. Thank you.

    Read the article

  • Why is Zend Framework (Zend_Db_table) rejecting this SQL Query?

    - by Michael T. Smith
    I'm working on a simple JOIN of two tables (urls and companies). I am using this query call: print $this->_db->select()->from(array('u' => 'urls'), array('id', 'url', 'company_id')) ->join(array('c' => 'companies'), 'u.company_id = c.id'); which is out putting this query: SELECT `u`.`id`, `u`.`url`, `u`.`company_id`, `c`.* FROM `urls` AS `u` INNER JOIN `companies` AS `c` ON u.company_id = c.id Now, I'd prefer the c.* to not actually appear, but either way it doesn't matter. ZF dies with this error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1" but I can run that query perfectly fine in my MySQL CLI. Any ideas how to fix up this query?

    Read the article

  • Is there a way to create a WCF DataContract on a third party type?

    - by Michael Hedgpeth
    I am migrating to wcf and trying to figure out how I'm going to declare my Data Contracts properly. Some of the types I have been demoting are from a third party that I am unable to change. Are attributes the only way to explicitly declare data contracts in wcf? I know about the auto data contract functionality in 3.5, but the books I'm readin discourage that. And besides, that way assumes all state is publically available, which is oftentimes not the case.

    Read the article

  • jQuery resize event for div children

    - by Frank Michael Kraft
    $("div.content-left > *, div.content-main > *" ).live('resize',function(){alert("Size changed")}); does not work, because the resize event only applies to window resizes. But in my case the divs change size late, because the content is loaded late by an ajax request - or by clicking a panel menu. I definatley need to avoid to register on all individual events of the children (ajax, click), because that can be very many different events and then it is not maintainable.

    Read the article

  • How can I interpolate literal \t and \n in Perl strings?

    - by Michael
    Say I have an environment variable myvar: myvar=\tapple\n When the following command will print out this variable perl -e 'print "$ENV{myvar}"' I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it? In the real world $ENV residing in substitution, but I hope the answer will cover that.

    Read the article

  • How to maintain 2 lists of object

    - by michael
    Hi, My c++ program needs to maintain 2 list of objects. list inuse; list free; So objects A can even in 'inuse' list or in 'free' list, but not both. http://www.cplusplus.com/reference/stl/list/ I am think of using 'list' as the data structure for my lists. My questions are 1. why i can't randomly access an elmenet in the list, I look at the above api, I don't see a way to get inuse[2]; 2. How can I remove an element in the list? There is an erase(), but how can I use it to remove element #2? And after I remove element 2? will STL list fill the erased spot automatically? e.g. #3 will become #2, #4 will become #3 and so on? Thank you.

    Read the article

  • CSS Compressor with @include support

    - by Michael
    Is there any CSS compressor that supports the @include directive? I have a bunch of css files that have one main file and are linked via those @include directives. Now that I want to compress the CSS files I'm looking for a compression tool that supports that. I cannot change the original files not to use includes because those are centrally developed ones.

    Read the article

  • Framework for Web Services in PHP?

    - by Michael Stum
    I need to implement a Web Service in PHP, but I've never written one in it (I nowadays use ASP.net which handles all that SOAP/WSDL/Disco stuff for me). Are there any libraries/Frameworks for that? Should be as lightweight as possible as they wire into an existing system.

    Read the article

  • Convert octet string to human readable

    - by Michael Lang
    Using the pysnmp framework i get some values doing a snmp walk. Unfortunately for the oid 1.3.6.1.21.69.1.5.8.1.2 (DOCS-CABLE-DEVICE-MIB) i get a weird result which i cant correctly print here since it contains ascii chars like BEL ACK When doing a repr i get: OctetString('\x07\xd8\t\x17\x03\x184\x00') But the output should look like: 2008-9-23,3:24:52.0 the format is called "DateAndTime". How can i translate the OctetString output to a "human readable" date/time ?

    Read the article

  • C#: How to unit test a method that relies on another method within the same class?

    - by michael paul
    I have a class similar to the following: public class MyProxy : ClientBase<IService>, IService { public MyProxy(String endpointConfiguration) : base(endpointConfiguration) { } public int DoSomething(int x) { int result = DoSomethingToX(x); //This passes unit testing int result2 = ((IService)this).DoWork(x) //do I have to extract this part into a separate method just //to test it even though it's only a couple of lines? //Do something on result2 int result3 = result2 ... return result3; } int IService.DoWork(int x) { return base.Channel.DoWork(x); } } The problem lies in the fact that when testing I don't know how to mock the result2 item without extracting the part that gets result3 using result2 into a separate method. And, because it is unit testing I don't want to go that deep as to test what result2 comes back as... I'd rather mock the data somehow... like, be able to call the function and replace just that one call.

    Read the article

  • C# Unit Testing: How do I set a Lazy<T>.ValueCreated to false?

    - by michael paul
    Basically, I have a unit test that gets a singleton instance of a class. Some of my tests required me to mock this singleton, so when I do Foo.Instance I get a different type of instance. The problem is that my checks are passing individually, but failing overall because one test is interfering with another. I tried to do a TestCleanup where I set: Foo_Accessor._instance = null; but that didn't work. What I really need is Foo_Accessor._instance.IsValueCreated = false; (_instance is a Lazy). Any way to unset the Lazy object that I didn't think of?

    Read the article

< Previous Page | 84 85 86 87 88 89 90 91 92 93 94 95  | Next Page >